mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-23 00:45:16 +00:00
69 lines
2.2 KiB
JavaScript
69 lines
2.2 KiB
JavaScript
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
|
||
|
|
||
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
||
|
|
||
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||
|
|
||
|
// for environments without Set we fallback to arrays with unique members
|
||
|
var SetLike = /*#__PURE__*/function () {
|
||
|
function SetLike() {
|
||
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||
|
|
||
|
_classCallCheck(this, SetLike);
|
||
|
|
||
|
_defineProperty(this, "items", void 0);
|
||
|
|
||
|
this.items = items;
|
||
|
}
|
||
|
|
||
|
_createClass(SetLike, [{
|
||
|
key: "add",
|
||
|
value: function add(value) {
|
||
|
if (this.has(value) === false) {
|
||
|
this.items.push(value);
|
||
|
}
|
||
|
|
||
|
return this;
|
||
|
}
|
||
|
}, {
|
||
|
key: "clear",
|
||
|
value: function clear() {
|
||
|
this.items = [];
|
||
|
}
|
||
|
}, {
|
||
|
key: "delete",
|
||
|
value: function _delete(value) {
|
||
|
var previousLength = this.items.length;
|
||
|
this.items = this.items.filter(function (item) {
|
||
|
return item !== value;
|
||
|
});
|
||
|
return previousLength !== this.items.length;
|
||
|
}
|
||
|
}, {
|
||
|
key: "forEach",
|
||
|
value: function forEach(callbackfn) {
|
||
|
var _this = this;
|
||
|
|
||
|
this.items.forEach(function (item) {
|
||
|
callbackfn(item, item, _this);
|
||
|
});
|
||
|
}
|
||
|
}, {
|
||
|
key: "has",
|
||
|
value: function has(value) {
|
||
|
return this.items.indexOf(value) !== -1;
|
||
|
}
|
||
|
}, {
|
||
|
key: "size",
|
||
|
get: function get() {
|
||
|
return this.items.length;
|
||
|
}
|
||
|
}]);
|
||
|
|
||
|
return SetLike;
|
||
|
}();
|
||
|
|
||
|
export default typeof Set === "undefined" ? Set : SetLike;
|
||
|
//# sourceMappingURL=SetLike.mjs.map
|