rebuilt files

This commit is contained in:
Amish Shah
2015-11-22 15:01:42 +00:00
parent cf33df18cf
commit 68b60c5464
27 changed files with 1023 additions and 1746 deletions

View File

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

View File

@@ -1,61 +1,40 @@
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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);
_Array.call(this);
class Cache extends Array {
constructor(discrim, limit) {
super();
this.discrim = discrim || "id";
}
Cache.prototype.get = function get(key, value) {
get(key, value) {
var found = null;
this.forEach(function (val, index, array) {
this.forEach((val, index, array) => {
if (val.hasOwnProperty(key) && val[key] == value) {
found = val;
return;
}
});
return found;
};
}
Cache.prototype.has = function has(key, value) {
has(key, value) {
return !!this.get(key, value);
};
}
Cache.prototype.getAll = function getAll(key, value) {
getAll(key, value) {
var found = new Cache(this.discrim);
this.forEach(function (val, index, array) {
this.forEach((val, index, array) => {
if (val.hasOwnProperty(key) && val[key] == value) {
found.push(val);
return;
}
});
return found;
};
}
Cache.prototype.add = function add(data) {
add(data) {
var exit = false;
for (var _iterator = this, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var item = _ref;
for (var item of this) {
if (item[this.discrim] === data[this.discrim]) {
exit = item;
break;
@@ -70,9 +49,9 @@ var Cache = (function (_Array) {
this.push(data);
return data;
}
};
}
Cache.prototype.update = function update(old, data) {
update(old, data) {
var item = this.get(this.discrim, old[this.discrim]);
if (item) {
var index = this.indexOf(item);
@@ -81,13 +60,13 @@ var Cache = (function (_Array) {
} else {
return false;
}
};
}
Cache.prototype.random = function random() {
random() {
return this[Math.floor(Math.random() * this.length)];
};
}
Cache.prototype.remove = function remove(data) {
remove(data) {
var index = this.indexOf(data);
if (~index) {
this.splice(index, 1);
@@ -98,9 +77,7 @@ var Cache = (function (_Array) {
}
}
return false;
};
return Cache;
})(Array);
}
}
module.exports = Cache;

View File

@@ -9,37 +9,24 @@
Instead, use objectThatExtendsEquality.equals()
*/
"use strict";
class Equality {
constructor() {}
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"); } }
var Equality = (function () {
function Equality() {
_classCallCheck(this, Equality);
get eqDiscriminator() {
return "id";
}
Equality.prototype.equals = function equals(object) {
equals(object) {
if (object && object[this.eqDiscriminator] == this[this.eqDiscriminator]) {
return true;
}
return false;
};
}
Equality.prototype.equalsStrict = function equalsStrict(object) {
equalsStrict(object) {
// override per class type
return;
};
_createClass(Equality, [{
key: "eqDiscriminator",
get: function get() {
return "id";
}
}]);
return Equality;
})();
}
}
module.exports = Equality;