mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
Fixed compiled version
Downgraded babel until a working solution found
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
"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"); } }
|
||||
|
||||
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) {
|
||||
@@ -14,115 +10,95 @@ var Cache = (function (_Array) {
|
||||
function Cache(discrim, limit) {
|
||||
_classCallCheck(this, Cache);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Cache).call(this));
|
||||
|
||||
_this.discrim = discrim || "id";
|
||||
return _this;
|
||||
_Array.call(this);
|
||||
this.discrim = discrim || "id";
|
||||
}
|
||||
|
||||
_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;
|
||||
Cache.prototype.get = 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;
|
||||
};
|
||||
|
||||
try {
|
||||
for (var _iterator = this[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var item = _step.value;
|
||||
Cache.prototype.has = function has(key, value) {
|
||||
return !!this.get(key, 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;
|
||||
}
|
||||
}
|
||||
Cache.prototype.getAll = 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;
|
||||
};
|
||||
|
||||
Cache.prototype.add = function 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;
|
||||
}
|
||||
|
||||
if (exit) {
|
||||
return exit;
|
||||
} else {
|
||||
if (this.limit && this.length >= this.limit) {
|
||||
this.splice(0, 1);
|
||||
}
|
||||
this.push(data);
|
||||
return data;
|
||||
var item = _ref;
|
||||
|
||||
if (item[this.discrim] === data[this.discrim]) {
|
||||
exit = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
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;
|
||||
if (exit) {
|
||||
return exit;
|
||||
} else {
|
||||
if (this.limit && this.length >= this.limit) {
|
||||
this.splice(0, 1);
|
||||
}
|
||||
this.push(data);
|
||||
return data;
|
||||
}
|
||||
}, {
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Cache.prototype.update = 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;
|
||||
}
|
||||
}]);
|
||||
};
|
||||
|
||||
Cache.prototype.random = function random() {
|
||||
return this[Math.floor(Math.random() * this.length)];
|
||||
};
|
||||
|
||||
Cache.prototype.remove = 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;
|
||||
};
|
||||
|
||||
return Cache;
|
||||
})(Array);
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
"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
|
||||
@@ -15,27 +9,30 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
||||
|
||||
Instead, use objectThatExtendsEquality.equals()
|
||||
*/
|
||||
"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"); } }
|
||||
|
||||
var Equality = (function () {
|
||||
function Equality() {
|
||||
_classCallCheck(this, Equality);
|
||||
}
|
||||
|
||||
Equality.prototype.equals = function equals(object) {
|
||||
if (object && object[this.eqDiscriminator] == this[this.eqDiscriminator]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
Equality.prototype.equalsStrict = function equalsStrict(object) {
|
||||
// override per class type
|
||||
return;
|
||||
};
|
||||
|
||||
_createClass(Equality, [{
|
||||
key: "equals",
|
||||
value: function equals(object) {
|
||||
if (object && object[this.eqDiscriminator] == this[this.eqDiscriminator]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, {
|
||||
key: "equalsStrict",
|
||||
value: function equalsStrict(object) {
|
||||
// override per class type
|
||||
return;
|
||||
}
|
||||
}, {
|
||||
key: "eqDiscriminator",
|
||||
get: function get() {
|
||||
return "id";
|
||||
|
||||
Reference in New Issue
Block a user