@oozcitak/util
Advanced tools
Comparing version 8.3.4 to 8.3.5
@@ -16,3 +16,3 @@ "use strict"; | ||
*/ | ||
class CompareCache { | ||
var CompareCache = /** @class */ (function () { | ||
/** | ||
@@ -24,3 +24,4 @@ * Initializes a new instance of `CompareCache`. | ||
*/ | ||
constructor(limit = 1000) { | ||
function CompareCache(limit) { | ||
if (limit === void 0) { limit = 1000; } | ||
this._items = new Map(); | ||
@@ -36,3 +37,3 @@ this._limit = limit; | ||
*/ | ||
check(objA, objB) { | ||
CompareCache.prototype.check = function (objA, objB) { | ||
if (this._items.get(objA) === objB) | ||
@@ -42,3 +43,3 @@ return true; | ||
return false; | ||
const result = (Math.random() < 0.5); | ||
var result = (Math.random() < 0.5); | ||
if (result) { | ||
@@ -51,12 +52,13 @@ this._items.set(objA, objB); | ||
if (this._items.size > this._limit) { | ||
const it = this._items.keys().next(); | ||
var it_1 = this._items.keys().next(); | ||
/* istanbul ignore else */ | ||
if (!it.done) { | ||
this._items.delete(it.value); | ||
if (!it_1.done) { | ||
this._items.delete(it_1.value); | ||
} | ||
} | ||
return result; | ||
} | ||
} | ||
}; | ||
return CompareCache; | ||
}()); | ||
exports.CompareCache = CompareCache; | ||
//# sourceMappingURL=CompareCache.js.map |
"use strict"; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,3 +44,3 @@ /** | ||
*/ | ||
class FixedSizeSet { | ||
var FixedSizeSet = /** @class */ (function () { | ||
/** | ||
@@ -14,3 +52,4 @@ * Initializes a new instance of `FixedSizeSet`. | ||
*/ | ||
constructor(limit = 1000) { | ||
function FixedSizeSet(limit) { | ||
if (limit === void 0) { limit = 1000; } | ||
this._items = new Set(); | ||
@@ -24,13 +63,13 @@ this._limit = limit; | ||
*/ | ||
add(item) { | ||
FixedSizeSet.prototype.add = function (item) { | ||
this._items.add(item); | ||
if (this._items.size > this._limit) { | ||
const it = this._items.values().next(); | ||
var it_1 = this._items.values().next(); | ||
/* istanbul ignore else */ | ||
if (!it.done) { | ||
this._items.delete(it.value); | ||
if (!it_1.done) { | ||
this._items.delete(it_1.value); | ||
} | ||
} | ||
return this; | ||
} | ||
}; | ||
/** | ||
@@ -41,5 +80,5 @@ * Removes an item from the set. | ||
*/ | ||
delete(item) { | ||
FixedSizeSet.prototype.delete = function (item) { | ||
return this._items.delete(item); | ||
} | ||
}; | ||
/** | ||
@@ -50,53 +89,91 @@ * Determines if an item is in the set. | ||
*/ | ||
has(item) { | ||
FixedSizeSet.prototype.has = function (item) { | ||
return this._items.has(item); | ||
} | ||
}; | ||
/** | ||
* Removes all items from the set. | ||
*/ | ||
clear() { | ||
FixedSizeSet.prototype.clear = function () { | ||
this._items.clear(); | ||
} | ||
}; | ||
Object.defineProperty(FixedSizeSet.prototype, "size", { | ||
/** | ||
* Gets the number of items in the set. | ||
*/ | ||
get: function () { return this._items.size; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Gets the number of items in the set. | ||
*/ | ||
get size() { return this._items.size; } | ||
/** | ||
* Applies the given callback function to all elements of the set. | ||
*/ | ||
forEach(callback, thisArg) { | ||
this._items.forEach(e => callback.call(thisArg, e, e, this)); | ||
} | ||
FixedSizeSet.prototype.forEach = function (callback, thisArg) { | ||
var _this = this; | ||
this._items.forEach(function (e) { return callback.call(thisArg, e, e, _this); }); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*keys() { | ||
yield* this._items.keys(); | ||
} | ||
FixedSizeSet.prototype.keys = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items.keys())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*values() { | ||
yield* this._items.values(); | ||
} | ||
FixedSizeSet.prototype.values = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items.values())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*entries() { | ||
yield* this._items.entries(); | ||
} | ||
FixedSizeSet.prototype.entries = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items.entries())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*[Symbol.iterator]() { | ||
yield* this._items; | ||
} | ||
/** | ||
* Returns the string tag of the set. | ||
*/ | ||
get [Symbol.toStringTag]() { | ||
return "FixedSizeSet"; | ||
} | ||
} | ||
FixedSizeSet.prototype[Symbol.iterator] = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
Object.defineProperty(FixedSizeSet.prototype, Symbol.toStringTag, { | ||
/** | ||
* Returns the string tag of the set. | ||
*/ | ||
get: function () { | ||
return "FixedSizeSet"; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return FixedSizeSet; | ||
}()); | ||
exports.FixedSizeSet = FixedSizeSet; | ||
//# sourceMappingURL=FixedSizeSet.js.map |
"use strict"; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -20,7 +31,11 @@ var FixedSizeSet_1 = require("./FixedSizeSet"); | ||
*/ | ||
function applyMixin(baseClass, mixinClass, ...overrides) { | ||
Object.getOwnPropertyNames(mixinClass.prototype).forEach(name => { | ||
function applyMixin(baseClass, mixinClass) { | ||
var overrides = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
overrides[_i - 2] = arguments[_i]; | ||
} | ||
Object.getOwnPropertyNames(mixinClass.prototype).forEach(function (name) { | ||
if (name !== "constructor") { | ||
if (overrides.includes(name)) { | ||
const orgPropDesc = Object.getOwnPropertyDescriptor(baseClass.prototype, name); | ||
var orgPropDesc = Object.getOwnPropertyDescriptor(baseClass.prototype, name); | ||
/* istanbul ignore else */ | ||
@@ -31,3 +46,3 @@ if (orgPropDesc) { | ||
} | ||
const propDesc = Object.getOwnPropertyDescriptor(mixinClass.prototype, name); | ||
var propDesc = Object.getOwnPropertyDescriptor(mixinClass.prototype, name); | ||
/* istanbul ignore else */ | ||
@@ -49,5 +64,6 @@ if (propDesc) { | ||
*/ | ||
function applyDefaults(obj, defaults, overwrite = false) { | ||
const result = clone(obj || {}); | ||
forEachObject(defaults, (key, val) => { | ||
function applyDefaults(obj, defaults, overwrite) { | ||
if (overwrite === void 0) { overwrite = false; } | ||
var result = clone(obj || {}); | ||
forEachObject(defaults, function (key, val) { | ||
if (isPlainObject(val)) { | ||
@@ -85,6 +101,6 @@ result[key] = applyDefaults(result[key], val, overwrite); | ||
if (isMap(obj)) { | ||
obj.forEach((value, key) => callback.call(thisArg, key, value)); | ||
obj.forEach(function (value, key) { return callback.call(thisArg, key, value); }); | ||
} | ||
else { | ||
for (const key in obj) { | ||
for (var key in obj) { | ||
/* istanbul ignore else */ | ||
@@ -162,2 +178,3 @@ if (obj.hasOwnProperty(key)) { | ||
function clone(obj) { | ||
var e_1, _a; | ||
if (isFunction(obj)) { | ||
@@ -167,14 +184,24 @@ return obj; | ||
else if (isArray(obj)) { | ||
const result = []; | ||
for (const item of obj) { | ||
result.push(clone(item)); | ||
var result = []; | ||
try { | ||
for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { | ||
var item = obj_1_1.value; | ||
result.push(clone(item)); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return result; | ||
} | ||
else if (isObject(obj)) { | ||
const result = {}; | ||
for (const key in obj) { | ||
var result = {}; | ||
for (var key in obj) { | ||
/* istanbul ignore next */ | ||
if (obj.hasOwnProperty(key)) { | ||
const val = obj[key]; | ||
var val = obj[key]; | ||
result[key] = clone(val); | ||
@@ -234,3 +261,3 @@ } | ||
function isObject(x) { | ||
const type = typeof x; | ||
var type = typeof x; | ||
return !!x && (type === 'function' || type === 'object'); | ||
@@ -282,3 +309,3 @@ } | ||
else if (isObject(x)) { | ||
for (const key in x) { | ||
for (var key in x) { | ||
if (x.hasOwnProperty(key)) { | ||
@@ -300,4 +327,4 @@ return false; | ||
if (isObject(x)) { | ||
const proto = Object.getPrototypeOf(x); | ||
const ctor = proto.constructor; | ||
var proto = Object.getPrototypeOf(x); | ||
var ctor = proto.constructor; | ||
return proto && ctor && | ||
@@ -337,6 +364,6 @@ (typeof ctor === 'function') && (ctor instanceof ctor) && | ||
function utf8Encode(input) { | ||
const bytes = new Uint8Array(input.length * 4); | ||
let byteIndex = 0; | ||
for (let i = 0; i < input.length; i++) { | ||
let char = input.charCodeAt(i); | ||
var bytes = new Uint8Array(input.length * 4); | ||
var byteIndex = 0; | ||
for (var i = 0; i < input.length; i++) { | ||
var char = input.charCodeAt(i); | ||
if (char < 128) { | ||
@@ -354,3 +381,3 @@ bytes[byteIndex++] = char; | ||
} | ||
const c2 = input.charCodeAt(i); | ||
var c2 = input.charCodeAt(i); | ||
if (c2 < 0xdc00 || c2 > 0xdfff) { | ||
@@ -379,4 +406,4 @@ throw new Error("Invalid surrogate character."); | ||
function utf8Decode(bytes) { | ||
let result = ""; | ||
let i = 0; | ||
var result = ""; | ||
var i = 0; | ||
while (i < bytes.length) { | ||
@@ -383,0 +410,0 @@ var c = bytes[i++]; |
@@ -6,3 +6,3 @@ "use strict"; | ||
*/ | ||
class Lazy { | ||
var Lazy = /** @class */ (function () { | ||
/** | ||
@@ -13,3 +13,3 @@ * Initializes a new instance of `Lazy`. | ||
*/ | ||
constructor(initFunc) { | ||
function Lazy(initFunc) { | ||
this._initialized = false; | ||
@@ -19,14 +19,19 @@ this._value = undefined; | ||
} | ||
/** | ||
* Gets the value of the object. | ||
*/ | ||
get value() { | ||
if (!this._initialized) { | ||
this._value = this._initFunc(); | ||
this._initialized = true; | ||
} | ||
return this._value; | ||
} | ||
} | ||
Object.defineProperty(Lazy.prototype, "value", { | ||
/** | ||
* Gets the value of the object. | ||
*/ | ||
get: function () { | ||
if (!this._initialized) { | ||
this._value = this._initFunc(); | ||
this._initialized = true; | ||
} | ||
return this._value; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return Lazy; | ||
}()); | ||
exports.Lazy = Lazy; | ||
//# sourceMappingURL=Lazy.js.map |
"use strict"; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -6,3 +44,3 @@ /** | ||
*/ | ||
class ObjectCache { | ||
var ObjectCache = /** @class */ (function () { | ||
/** | ||
@@ -14,3 +52,4 @@ * Initializes a new instance of `ObjectCache`. | ||
*/ | ||
constructor(limit = 1000) { | ||
function ObjectCache(limit) { | ||
if (limit === void 0) { limit = 1000; } | ||
this._items = new Map(); | ||
@@ -24,5 +63,5 @@ this._limit = limit; | ||
*/ | ||
get(key) { | ||
ObjectCache.prototype.get = function (key) { | ||
return this._items.get(key); | ||
} | ||
}; | ||
/** | ||
@@ -34,12 +73,12 @@ * Adds a new item to the cache. | ||
*/ | ||
set(key, value) { | ||
ObjectCache.prototype.set = function (key, value) { | ||
this._items.set(key, value); | ||
if (this._items.size > this._limit) { | ||
const it = this._items.keys().next(); | ||
var it_1 = this._items.keys().next(); | ||
/* istanbul ignore else */ | ||
if (!it.done) { | ||
this._items.delete(it.value); | ||
if (!it_1.done) { | ||
this._items.delete(it_1.value); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
@@ -50,5 +89,5 @@ * Removes an item from the cache. | ||
*/ | ||
delete(key) { | ||
ObjectCache.prototype.delete = function (key) { | ||
return this._items.delete(key); | ||
} | ||
}; | ||
/** | ||
@@ -59,53 +98,90 @@ * Determines if an item is in the cache. | ||
*/ | ||
has(key) { | ||
ObjectCache.prototype.has = function (key) { | ||
return this._items.has(key); | ||
} | ||
}; | ||
/** | ||
* Removes all items from the cache. | ||
*/ | ||
clear() { | ||
ObjectCache.prototype.clear = function () { | ||
this._items.clear(); | ||
} | ||
}; | ||
Object.defineProperty(ObjectCache.prototype, "size", { | ||
/** | ||
* Gets the number of items in the cache. | ||
*/ | ||
get: function () { return this._items.size; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
* Gets the number of items in the cache. | ||
*/ | ||
get size() { return this._items.size; } | ||
/** | ||
* Applies the given callback function to all elements of the cache. | ||
*/ | ||
forEach(callback, thisArg) { | ||
this._items.forEach((v, k) => callback.call(thisArg, k, v)); | ||
} | ||
ObjectCache.prototype.forEach = function (callback, thisArg) { | ||
this._items.forEach(function (v, k) { return callback.call(thisArg, k, v); }); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*keys() { | ||
yield* this._items.keys(); | ||
} | ||
ObjectCache.prototype.keys = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items.keys())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*values() { | ||
yield* this._items.values(); | ||
} | ||
ObjectCache.prototype.values = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items.values())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*entries() { | ||
yield* this._items.entries(); | ||
} | ||
ObjectCache.prototype.entries = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items.entries())]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
/** | ||
* Iterates through the items in the set. | ||
*/ | ||
*[Symbol.iterator]() { | ||
yield* this._items; | ||
} | ||
/** | ||
* Returns the string tag of the cache. | ||
*/ | ||
get [Symbol.toStringTag]() { | ||
return "ObjectCache"; | ||
} | ||
} | ||
ObjectCache.prototype[Symbol.iterator] = function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [5 /*yield**/, __values(this._items)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}; | ||
Object.defineProperty(ObjectCache.prototype, Symbol.toStringTag, { | ||
/** | ||
* Returns the string tag of the cache. | ||
*/ | ||
get: function () { | ||
return "ObjectCache"; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return ObjectCache; | ||
}()); | ||
exports.ObjectCache = ObjectCache; | ||
//# sourceMappingURL=ObjectCache.js.map |
{ | ||
"name": "@oozcitak/util", | ||
"version": "8.3.4", | ||
"version": "8.3.5", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "util", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54684
1242