Built src again using the correct preset

This commit is contained in:
Amish Shah
2015-11-22 15:12:39 +00:00
parent 68b60c5464
commit b22995f254
27 changed files with 4288 additions and 3142 deletions

View File

@@ -1,3 +1,5 @@
"use strict";
exports.reg = function (c, a) {
return [c].concat(Array.prototype.slice.call(a));
};

View File

@@ -1,83 +1,130 @@
"use strict";
class Cache extends Array {
constructor(discrim, limit) {
super();
this.discrim = discrim || "id";
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Cache = (function (_Array) {
_inherits(Cache, _Array);
function Cache(discrim, limit) {
_classCallCheck(this, Cache);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Cache).call(this));
_this.discrim = discrim || "id";
return _this;
}
get(key, value) {
var found = null;
this.forEach((val, index, array) => {
if (val.hasOwnProperty(key) && val[key] == value) {
found = val;
return;
_createClass(Cache, [{
key: "get",
value: function get(key, value) {
var found = null;
this.forEach(function (val, index, array) {
if (val.hasOwnProperty(key) && val[key] == value) {
found = val;
return;
}
});
return found;
}
}, {
key: "has",
value: function has(key, value) {
return !!this.get(key, value);
}
}, {
key: "getAll",
value: function getAll(key, value) {
var found = new Cache(this.discrim);
this.forEach(function (val, index, array) {
if (val.hasOwnProperty(key) && val[key] == value) {
found.push(val);
return;
}
});
return found;
}
}, {
key: "add",
value: function add(data) {
var exit = false;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
if (item[this.discrim] === data[this.discrim]) {
exit = item;
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
});
return found;
}
has(key, value) {
return !!this.get(key, value);
}
getAll(key, value) {
var found = new Cache(this.discrim);
this.forEach((val, index, array) => {
if (val.hasOwnProperty(key) && val[key] == value) {
found.push(val);
return;
}
});
return found;
}
add(data) {
var exit = false;
for (var item of this) {
if (item[this.discrim] === data[this.discrim]) {
exit = item;
break;
if (exit) {
return exit;
} else {
if (this.limit && this.length >= this.limit) {
this.splice(0, 1);
}
this.push(data);
return data;
}
}
if (exit) {
return exit;
} else {
if (this.limit && this.length >= this.limit) {
this.splice(0, 1);
}, {
key: "update",
value: function update(old, data) {
var item = this.get(this.discrim, old[this.discrim]);
if (item) {
var index = this.indexOf(item);
this[index] = data;
return this[index];
} else {
return false;
}
this.push(data);
return data;
}
}
update(old, data) {
var item = this.get(this.discrim, old[this.discrim]);
if (item) {
var index = this.indexOf(item);
this[index] = data;
return this[index];
} else {
}, {
key: "random",
value: function random() {
return this[Math.floor(Math.random() * this.length)];
}
}, {
key: "remove",
value: function remove(data) {
var index = this.indexOf(data);
if (~index) {
this.splice(index, 1);
} else {
var item = this.get(this.discrim, data[this.discrim]);
if (item) {
this.splice(this.indexOf(item), 1);
}
}
return false;
}
}
}]);
random() {
return this[Math.floor(Math.random() * this.length)];
}
remove(data) {
var index = this.indexOf(data);
if (~index) {
this.splice(index, 1);
} else {
var item = this.get(this.discrim, data[this.discrim]);
if (item) {
this.splice(this.indexOf(item), 1);
}
}
return false;
}
}
return Cache;
})(Array);
module.exports = Cache;

View File

@@ -1,3 +1,9 @@
"use strict";
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*
The Equality Class is just used to show
that a Class has an ID that can be used to
@@ -9,24 +15,34 @@
Instead, use objectThatExtendsEquality.equals()
*/
class Equality {
constructor() {}
get eqDiscriminator() {
return "id";
var Equality = (function () {
function Equality() {
_classCallCheck(this, Equality);
}
equals(object) {
if (object && object[this.eqDiscriminator] == this[this.eqDiscriminator]) {
return true;
_createClass(Equality, [{
key: "equals",
value: function equals(object) {
if (object && object[this.eqDiscriminator] == this[this.eqDiscriminator]) {
return true;
}
return false;
}
return false;
}
}, {
key: "equalsStrict",
value: function equalsStrict(object) {
// override per class type
return;
}
}, {
key: "eqDiscriminator",
get: function get() {
return "id";
}
}]);
equalsStrict(object) {
// override per class type
return;
}
}
return Equality;
})();
module.exports = Equality;