Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@blackglory/structures

Package Overview
Dependencies
11
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.0 to 0.5.1

2

lib/es2015/box.d.ts
export declare class Box<T> {
#private;
private value;
constructor(value: T);

@@ -4,0 +4,0 @@ set(value: T): void;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Box_value;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,14 +6,12 @@ exports.Box = void 0;

constructor(value) {
_Box_value.set(this, void 0);
__classPrivateFieldSet(this, _Box_value, value, "f");
this.value = value;
}
set(value) {
__classPrivateFieldSet(this, _Box_value, value, "f");
this.value = value;
}
get() {
return __classPrivateFieldGet(this, _Box_value, "f");
return this.value;
}
}
exports.Box = Box;
_Box_value = new WeakMap();
//# sourceMappingURL=box.js.map
declare type Handler<Args extends unknown[]> = (...args: Args) => void;
export declare class Emitter<EventToArgs extends Record<string, unknown[]>> {
#private;
private map;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ on<T extends keyof EventToArgs>(event: T, handler: Handler<EventToArgs[T]>): void;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Emitter_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -12,27 +6,27 @@ exports.Emitter = void 0;

constructor() {
_Emitter_map.set(this, new Map());
this.map = new Map();
}
get [(_Emitter_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
on(event, handler) {
if (!__classPrivateFieldGet(this, _Emitter_map, "f").has(event)) {
__classPrivateFieldGet(this, _Emitter_map, "f").set(event, new Set());
if (!this.map.has(event)) {
this.map.set(event, new Set());
}
const set = __classPrivateFieldGet(this, _Emitter_map, "f").get(event);
const set = this.map.get(event);
set.add(handler);
}
off(event, handler) {
if (!__classPrivateFieldGet(this, _Emitter_map, "f").has(event))
if (!this.map.has(event))
return;
const handlers = __classPrivateFieldGet(this, _Emitter_map, "f").get(event);
const handlers = this.map.get(event);
handlers.delete(handler);
if (handlers.size === 0) {
__classPrivateFieldGet(this, _Emitter_map, "f").delete(event);
this.map.delete(event);
}
}
emit(event, ...args) {
if (!__classPrivateFieldGet(this, _Emitter_map, "f").has(event))
if (!this.map.has(event))
return;
__classPrivateFieldGet(this, _Emitter_map, "f").get(event).forEach(cb => cb(...args));
this.map.get(event).forEach(cb => cb(...args));
}

@@ -39,0 +33,0 @@ }

export declare class ExpirableMap<K, V> {
#private;
private map;
private cancelClearTimeout?;
itemMetadataSortedByExpirationTime: Array<{

@@ -4,0 +5,0 @@ key: K;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _ExpirableMap_map, _ExpirableMap_cancelClearTimeout;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,14 +7,13 @@ exports.ExpirableMap = void 0;

constructor() {
_ExpirableMap_map.set(this, new Map());
_ExpirableMap_cancelClearTimeout.set(this, void 0);
this.map = new Map();
this.itemMetadataSortedByExpirationTime = [];
}
get [(_ExpirableMap_map = new WeakMap(), _ExpirableMap_cancelClearTimeout = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _ExpirableMap_map, "f").size;
return this.map.size;
}
set(key, value, maxAge) {
__classPrivateFieldGet(this, _ExpirableMap_map, "f").set(key, value);
this.map.set(key, value);
this.removeItemMetadata(key);

@@ -37,9 +24,9 @@ this.addItemMetadata(key, Date.now() + maxAge);

has(key) {
return __classPrivateFieldGet(this, _ExpirableMap_map, "f").has(key);
return this.map.has(key);
}
get(key) {
return __classPrivateFieldGet(this, _ExpirableMap_map, "f").get(key);
return this.map.get(key);
}
delete(key) {
const exists = __classPrivateFieldGet(this, _ExpirableMap_map, "f").delete(key);
const exists = this.map.delete(key);
if (exists) {

@@ -56,4 +43,4 @@ const index = this.itemMetadataSortedByExpirationTime.findIndex(x => x.key === key);

var _a;
__classPrivateFieldGet(this, _ExpirableMap_map, "f").clear();
(_a = __classPrivateFieldGet(this, _ExpirableMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
this.map.clear();
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
this.itemMetadataSortedByExpirationTime = [];

@@ -91,7 +78,7 @@ }

: this.itemMetadataSortedByExpirationTime.splice(0, this.itemMetadataSortedByExpirationTime.length);
expiredItemKeys.forEach(x => __classPrivateFieldGet(this, _ExpirableMap_map, "f").delete(x.key));
expiredItemKeys.forEach(x => this.map.delete(x.key));
}
rescheduleClearTimeout() {
var _a;
(_a = __classPrivateFieldGet(this, _ExpirableMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
if (this.itemMetadataSortedByExpirationTime.length > 0) {

@@ -104,6 +91,6 @@ const item = this.itemMetadataSortedByExpirationTime[0];

});
__classPrivateFieldSet(this, _ExpirableMap_cancelClearTimeout, () => {
this.cancelClearTimeout = () => {
cancel();
__classPrivateFieldSet(this, _ExpirableMap_cancelClearTimeout, undefined, "f");
}, "f");
this.cancelClearTimeout = undefined;
};
}

@@ -110,0 +97,0 @@ }

import { CustomError } from '@blackglory/errors';
export declare type IFiniteStateMachineSchema<State extends string, Event extends string> = Record<State, Partial<Record<Event, State>>>;
export declare class FiniteStateMachine<State extends string, Event extends string> {
#private;
protected schema: IFiniteStateMachineSchema<State, Event>;
private _state;
get state(): State;

@@ -7,0 +7,0 @@ constructor(schema: IFiniteStateMachineSchema<State, Event>, initialState: State);

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _FiniteStateMachine_state;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,10 +8,9 @@ exports.BadEventError = exports.FiniteStateMachine = void 0;

this.schema = schema;
_FiniteStateMachine_state.set(this, void 0);
__classPrivateFieldSet(this, _FiniteStateMachine_state, initialState, "f");
this._state = initialState;
}
get state() {
return __classPrivateFieldGet(this, _FiniteStateMachine_state, "f");
return this._state;
}
matches(state) {
return __classPrivateFieldGet(this, _FiniteStateMachine_state, "f") === state;
return this._state === state;
}

@@ -35,3 +22,3 @@ can(event) {

if (this.can(event)) {
__classPrivateFieldSet(this, _FiniteStateMachine_state, this.schema[this.state][event], "f");
this._state = this.schema[this.state][event];
}

@@ -44,3 +31,2 @@ else {

exports.FiniteStateMachine = FiniteStateMachine;
_FiniteStateMachine_state = new WeakMap();
class BadEventError extends errors_1.CustomError {

@@ -47,0 +33,0 @@ constructor(state, event) {

export declare class HashMap<K, V, H = unknown> {
#private;
private hash;
private map;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ get size(): number;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _HashMap_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,25 +7,25 @@ exports.HashMap = void 0;

this.hash = hash;
_HashMap_map.set(this, new Map());
this.map = new Map();
}
get [(_HashMap_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _HashMap_map, "f").size;
return this.map.size;
}
set(key, value) {
__classPrivateFieldGet(this, _HashMap_map, "f").set(this.hash(key), value);
this.map.set(this.hash(key), value);
return this;
}
has(key) {
return __classPrivateFieldGet(this, _HashMap_map, "f").has(this.hash(key));
return this.map.has(this.hash(key));
}
get(key) {
return __classPrivateFieldGet(this, _HashMap_map, "f").get(this.hash(key));
return this.map.get(this.hash(key));
}
delete(key) {
return __classPrivateFieldGet(this, _HashMap_map, "f").delete(this.hash(key));
return this.map.delete(this.hash(key));
}
clear() {
__classPrivateFieldGet(this, _HashMap_map, "f").clear();
this.map.clear();
}

@@ -38,0 +32,0 @@ }

export declare class HashSet<V, H = unknown> implements Iterable<V> {
#private;
private hash;
private map;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ get size(): number;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _HashSet_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,28 +7,28 @@ exports.HashSet = void 0;

this.hash = hash;
_HashSet_map.set(this, new Map());
this.map = new Map();
}
get [(_HashSet_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _HashSet_map, "f").size;
return this.map.size;
}
[Symbol.iterator]() {
return __classPrivateFieldGet(this, _HashSet_map, "f").values();
return this.map.values();
}
add(value) {
__classPrivateFieldGet(this, _HashSet_map, "f").set(this.hash(value), value);
this.map.set(this.hash(value), value);
return this;
}
delete(value) {
return __classPrivateFieldGet(this, _HashSet_map, "f").delete(this.hash(value));
return this.map.delete(this.hash(value));
}
has(value) {
return __classPrivateFieldGet(this, _HashSet_map, "f").has(this.hash(value));
return this.map.has(this.hash(value));
}
clear() {
__classPrivateFieldGet(this, _HashSet_map, "f").clear();
this.map.clear();
}
values() {
return __classPrivateFieldGet(this, _HashSet_map, "f").values();
return this.map.values();
}

@@ -41,0 +35,0 @@ }

export declare class LRUMap<K, V> {
#private;
private limit;
private map;
get [Symbol.toStringTag](): string;

@@ -4,0 +5,0 @@ get size(): number;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _LRUMap_limit, _LRUMap_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,23 +8,22 @@ exports.LRUMap = void 0;

constructor(limit) {
_LRUMap_limit.set(this, void 0);
_LRUMap_map.set(this, new Map());
this.map = new Map();
(0, errors_1.assert)(Number.isInteger(limit), 'The parameter limit must be an integer');
(0, errors_1.assert)(limit > 0, 'The parameter limit must be a positive value');
__classPrivateFieldSet(this, _LRUMap_limit, limit, "f");
this.limit = limit;
}
get [(_LRUMap_limit = new WeakMap(), _LRUMap_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _LRUMap_map, "f").size;
return this.map.size;
}
set(key, value) {
if (__classPrivateFieldGet(this, _LRUMap_map, "f").has(key)) {
if (this.map.has(key)) {
this.updateItem(key, value);
}
else {
if (__classPrivateFieldGet(this, _LRUMap_map, "f").size === __classPrivateFieldGet(this, _LRUMap_limit, "f")) {
__classPrivateFieldGet(this, _LRUMap_map, "f").delete(this.getColdestKey());
if (this.map.size === this.limit) {
this.map.delete(this.getColdestKey());
}
__classPrivateFieldGet(this, _LRUMap_map, "f").set(key, value);
this.map.set(key, value);
}

@@ -46,3 +33,3 @@ return this;

has(key) {
return __classPrivateFieldGet(this, _LRUMap_map, "f").has(key);
return this.map.has(key);
}

@@ -52,3 +39,3 @@ get(key) {

return undefined;
const value = __classPrivateFieldGet(this, _LRUMap_map, "f").get(key);
const value = this.map.get(key);
this.updateItem(key, value);

@@ -58,13 +45,13 @@ return value;

delete(key) {
return __classPrivateFieldGet(this, _LRUMap_map, "f").delete(key);
return this.map.delete(key);
}
clear() {
__classPrivateFieldGet(this, _LRUMap_map, "f").clear();
this.map.clear();
}
updateItem(key, value) {
__classPrivateFieldGet(this, _LRUMap_map, "f").delete(key);
__classPrivateFieldGet(this, _LRUMap_map, "f").set(key, value);
this.map.delete(key);
this.map.set(key, value);
}
getColdestKey() {
return (0, iterable_operator_1.first)(__classPrivateFieldGet(this, _LRUMap_map, "f").keys());
return (0, iterable_operator_1.first)(this.map.keys());
}

@@ -71,0 +58,0 @@ }

export declare class Queue<T> {
#private;
private items;
get [Symbol.toStringTag](): string;

@@ -4,0 +4,0 @@ get size(): number;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Queue_items;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -12,23 +6,23 @@ exports.Queue = void 0;

constructor() {
_Queue_items.set(this, []);
this.items = [];
}
get [(_Queue_items = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _Queue_items, "f").length;
return this.items.length;
}
empty() {
__classPrivateFieldGet(this, _Queue_items, "f").length = 0;
this.items.length = 0;
}
enqueue(...items) {
__classPrivateFieldGet(this, _Queue_items, "f").push(...items);
this.items.push(...items);
}
dequeue() {
return __classPrivateFieldGet(this, _Queue_items, "f").shift();
return this.items.shift();
}
remove(item) {
let index;
while ((index = __classPrivateFieldGet(this, _Queue_items, "f").indexOf(item)) >= 0) {
__classPrivateFieldGet(this, _Queue_items, "f").splice(index, 1);
while ((index = this.items.indexOf(item)) >= 0) {
this.items.splice(index, 1);
}

@@ -35,0 +29,0 @@ }

export declare class TLRUMap<K, V> {
#private;
itemMetadataSortedByExpirationTime: Array<{
private limit;
private map;
private cancelClearTimeout?;
protected itemMetadataSortedByExpirationTime: Array<{
key: K;

@@ -5,0 +7,0 @@ expirationTime: number;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _TLRUMap_limit, _TLRUMap_map, _TLRUMap_cancelClearTimeout;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -21,18 +9,16 @@ exports.TLRUMap = void 0;

constructor(limit) {
_TLRUMap_limit.set(this, void 0);
_TLRUMap_map.set(this, new Map());
_TLRUMap_cancelClearTimeout.set(this, void 0);
this.map = new Map();
this.itemMetadataSortedByExpirationTime = [];
(0, errors_1.assert)(Number.isInteger(limit), 'The parameter limit must be an integer');
(0, errors_1.assert)(limit > 0, 'The parameter limit must be a positive value');
__classPrivateFieldSet(this, _TLRUMap_limit, limit, "f");
this.limit = limit;
}
get [(_TLRUMap_limit = new WeakMap(), _TLRUMap_map = new WeakMap(), _TLRUMap_cancelClearTimeout = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _TLRUMap_map, "f").size;
return this.map.size;
}
set(key, value, maxAge) {
if (__classPrivateFieldGet(this, _TLRUMap_map, "f").has(key)) {
if (this.map.has(key)) {
this.updateItem(key, value);

@@ -43,6 +29,6 @@ this.removeItemMetadata(key);

else {
if (__classPrivateFieldGet(this, _TLRUMap_map, "f").size === __classPrivateFieldGet(this, _TLRUMap_limit, "f")) {
__classPrivateFieldGet(this, _TLRUMap_map, "f").delete(this.getColdestKey());
if (this.map.size === this.limit) {
this.map.delete(this.getColdestKey());
}
__classPrivateFieldGet(this, _TLRUMap_map, "f").set(key, value);
this.map.set(key, value);
this.addItemMetadata(key, Date.now() + maxAge);

@@ -53,7 +39,7 @@ }

has(key) {
return __classPrivateFieldGet(this, _TLRUMap_map, "f").has(key);
return this.map.has(key);
}
get(key) {
if (this.has(key)) {
const value = __classPrivateFieldGet(this, _TLRUMap_map, "f").get(key);
const value = this.map.get(key);
this.updateItem(key, value);

@@ -67,3 +53,3 @@ return value;

delete(key) {
const result = __classPrivateFieldGet(this, _TLRUMap_map, "f").delete(key);
const result = this.map.delete(key);
if (result) {

@@ -80,9 +66,9 @@ const index = this.itemMetadataSortedByExpirationTime.findIndex(x => x.key === key);

var _a;
__classPrivateFieldGet(this, _TLRUMap_map, "f").clear();
(_a = __classPrivateFieldGet(this, _TLRUMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
this.map.clear();
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
this.itemMetadataSortedByExpirationTime = [];
}
updateItem(key, value) {
__classPrivateFieldGet(this, _TLRUMap_map, "f").delete(key);
__classPrivateFieldGet(this, _TLRUMap_map, "f").set(key, value);
this.map.delete(key);
this.map.set(key, value);
}

@@ -119,7 +105,7 @@ addItemMetadata(key, expirationTime) {

: this.itemMetadataSortedByExpirationTime.splice(0, this.itemMetadataSortedByExpirationTime.length);
expiredItemKeys.forEach(x => __classPrivateFieldGet(this, _TLRUMap_map, "f").delete(x.key));
expiredItemKeys.forEach(x => this.map.delete(x.key));
}
rescheduleClearTimeout() {
var _a;
(_a = __classPrivateFieldGet(this, _TLRUMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
if (this.itemMetadataSortedByExpirationTime.length > 0) {

@@ -132,6 +118,6 @@ const item = this.itemMetadataSortedByExpirationTime[0];

});
__classPrivateFieldSet(this, _TLRUMap_cancelClearTimeout, () => {
this.cancelClearTimeout = () => {
cancel();
__classPrivateFieldSet(this, _TLRUMap_cancelClearTimeout, undefined, "f");
}, "f");
this.cancelClearTimeout = undefined;
};
}

@@ -141,3 +127,3 @@ }

getColdestKey() {
return (0, iterable_operator_1.first)(__classPrivateFieldGet(this, _TLRUMap_map, "f").keys());
return (0, iterable_operator_1.first)(this.map.keys());
}

@@ -144,0 +130,0 @@ }

import { UnpackedIterable } from 'justypes';
export declare class TrieMap<K extends Iterable<T>, V, T = UnpackedIterable<K>> {
#private;
private root;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ set(key: K, value: V): this;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _TrieMap_root;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,9 +13,9 @@ exports.TrieMap = void 0;

constructor() {
_TrieMap_root.set(this, new TrieNode());
this.root = new TrieNode();
}
get [(_TrieMap_root = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
set(key, value) {
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -37,3 +31,3 @@ if (!node.children.has(part)) {

has(key) {
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -50,3 +44,3 @@ if (node.children.has(part)) {

get(key) {
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -64,3 +58,3 @@ if (node.children.has(part)) {

const parentNodes = [];
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -67,0 +61,0 @@ if (node.children.has(part)) {

export declare class Box<T> {
#private;
private value;
constructor(value: T);

@@ -4,0 +4,0 @@ set(value: T): void;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Box_value;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,14 +6,12 @@ exports.Box = void 0;

constructor(value) {
_Box_value.set(this, void 0);
__classPrivateFieldSet(this, _Box_value, value, "f");
this.value = value;
}
set(value) {
__classPrivateFieldSet(this, _Box_value, value, "f");
this.value = value;
}
get() {
return __classPrivateFieldGet(this, _Box_value, "f");
return this.value;
}
}
exports.Box = Box;
_Box_value = new WeakMap();
//# sourceMappingURL=box.js.map
declare type Handler<Args extends unknown[]> = (...args: Args) => void;
export declare class Emitter<EventToArgs extends Record<string, unknown[]>> {
#private;
private map;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ on<T extends keyof EventToArgs>(event: T, handler: Handler<EventToArgs[T]>): void;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Emitter_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -12,27 +6,27 @@ exports.Emitter = void 0;

constructor() {
_Emitter_map.set(this, new Map());
this.map = new Map();
}
get [(_Emitter_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
on(event, handler) {
if (!__classPrivateFieldGet(this, _Emitter_map, "f").has(event)) {
__classPrivateFieldGet(this, _Emitter_map, "f").set(event, new Set());
if (!this.map.has(event)) {
this.map.set(event, new Set());
}
const set = __classPrivateFieldGet(this, _Emitter_map, "f").get(event);
const set = this.map.get(event);
set.add(handler);
}
off(event, handler) {
if (!__classPrivateFieldGet(this, _Emitter_map, "f").has(event))
if (!this.map.has(event))
return;
const handlers = __classPrivateFieldGet(this, _Emitter_map, "f").get(event);
const handlers = this.map.get(event);
handlers.delete(handler);
if (handlers.size === 0) {
__classPrivateFieldGet(this, _Emitter_map, "f").delete(event);
this.map.delete(event);
}
}
emit(event, ...args) {
if (!__classPrivateFieldGet(this, _Emitter_map, "f").has(event))
if (!this.map.has(event))
return;
__classPrivateFieldGet(this, _Emitter_map, "f").get(event).forEach(cb => cb(...args));
this.map.get(event).forEach(cb => cb(...args));
}

@@ -39,0 +33,0 @@ }

export declare class ExpirableMap<K, V> {
#private;
private map;
private cancelClearTimeout?;
itemMetadataSortedByExpirationTime: Array<{

@@ -4,0 +5,0 @@ key: K;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _ExpirableMap_map, _ExpirableMap_cancelClearTimeout;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,14 +7,13 @@ exports.ExpirableMap = void 0;

constructor() {
_ExpirableMap_map.set(this, new Map());
_ExpirableMap_cancelClearTimeout.set(this, void 0);
this.map = new Map();
this.itemMetadataSortedByExpirationTime = [];
}
get [(_ExpirableMap_map = new WeakMap(), _ExpirableMap_cancelClearTimeout = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _ExpirableMap_map, "f").size;
return this.map.size;
}
set(key, value, maxAge) {
__classPrivateFieldGet(this, _ExpirableMap_map, "f").set(key, value);
this.map.set(key, value);
this.removeItemMetadata(key);

@@ -37,9 +24,9 @@ this.addItemMetadata(key, Date.now() + maxAge);

has(key) {
return __classPrivateFieldGet(this, _ExpirableMap_map, "f").has(key);
return this.map.has(key);
}
get(key) {
return __classPrivateFieldGet(this, _ExpirableMap_map, "f").get(key);
return this.map.get(key);
}
delete(key) {
const exists = __classPrivateFieldGet(this, _ExpirableMap_map, "f").delete(key);
const exists = this.map.delete(key);
if (exists) {

@@ -56,4 +43,4 @@ const index = this.itemMetadataSortedByExpirationTime.findIndex(x => x.key === key);

var _a;
__classPrivateFieldGet(this, _ExpirableMap_map, "f").clear();
(_a = __classPrivateFieldGet(this, _ExpirableMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
this.map.clear();
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
this.itemMetadataSortedByExpirationTime = [];

@@ -91,7 +78,7 @@ }

: this.itemMetadataSortedByExpirationTime.splice(0, this.itemMetadataSortedByExpirationTime.length);
expiredItemKeys.forEach(x => __classPrivateFieldGet(this, _ExpirableMap_map, "f").delete(x.key));
expiredItemKeys.forEach(x => this.map.delete(x.key));
}
rescheduleClearTimeout() {
var _a;
(_a = __classPrivateFieldGet(this, _ExpirableMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
if (this.itemMetadataSortedByExpirationTime.length > 0) {

@@ -104,6 +91,6 @@ const item = this.itemMetadataSortedByExpirationTime[0];

});
__classPrivateFieldSet(this, _ExpirableMap_cancelClearTimeout, () => {
this.cancelClearTimeout = () => {
cancel();
__classPrivateFieldSet(this, _ExpirableMap_cancelClearTimeout, undefined, "f");
}, "f");
this.cancelClearTimeout = undefined;
};
}

@@ -110,0 +97,0 @@ }

import { CustomError } from '@blackglory/errors';
export declare type IFiniteStateMachineSchema<State extends string, Event extends string> = Record<State, Partial<Record<Event, State>>>;
export declare class FiniteStateMachine<State extends string, Event extends string> {
#private;
protected schema: IFiniteStateMachineSchema<State, Event>;
private _state;
get state(): State;

@@ -7,0 +7,0 @@ constructor(schema: IFiniteStateMachineSchema<State, Event>, initialState: State);

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _FiniteStateMachine_state;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,10 +8,9 @@ exports.BadEventError = exports.FiniteStateMachine = void 0;

this.schema = schema;
_FiniteStateMachine_state.set(this, void 0);
__classPrivateFieldSet(this, _FiniteStateMachine_state, initialState, "f");
this._state = initialState;
}
get state() {
return __classPrivateFieldGet(this, _FiniteStateMachine_state, "f");
return this._state;
}
matches(state) {
return __classPrivateFieldGet(this, _FiniteStateMachine_state, "f") === state;
return this._state === state;
}

@@ -35,3 +22,3 @@ can(event) {

if (this.can(event)) {
__classPrivateFieldSet(this, _FiniteStateMachine_state, this.schema[this.state][event], "f");
this._state = this.schema[this.state][event];
}

@@ -44,3 +31,2 @@ else {

exports.FiniteStateMachine = FiniteStateMachine;
_FiniteStateMachine_state = new WeakMap();
class BadEventError extends errors_1.CustomError {

@@ -47,0 +33,0 @@ constructor(state, event) {

export declare class HashMap<K, V, H = unknown> {
#private;
private hash;
private map;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ get size(): number;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _HashMap_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,25 +7,25 @@ exports.HashMap = void 0;

this.hash = hash;
_HashMap_map.set(this, new Map());
this.map = new Map();
}
get [(_HashMap_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _HashMap_map, "f").size;
return this.map.size;
}
set(key, value) {
__classPrivateFieldGet(this, _HashMap_map, "f").set(this.hash(key), value);
this.map.set(this.hash(key), value);
return this;
}
has(key) {
return __classPrivateFieldGet(this, _HashMap_map, "f").has(this.hash(key));
return this.map.has(this.hash(key));
}
get(key) {
return __classPrivateFieldGet(this, _HashMap_map, "f").get(this.hash(key));
return this.map.get(this.hash(key));
}
delete(key) {
return __classPrivateFieldGet(this, _HashMap_map, "f").delete(this.hash(key));
return this.map.delete(this.hash(key));
}
clear() {
__classPrivateFieldGet(this, _HashMap_map, "f").clear();
this.map.clear();
}

@@ -38,0 +32,0 @@ }

export declare class HashSet<V, H = unknown> implements Iterable<V> {
#private;
private hash;
private map;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ get size(): number;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _HashSet_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,28 +7,28 @@ exports.HashSet = void 0;

this.hash = hash;
_HashSet_map.set(this, new Map());
this.map = new Map();
}
get [(_HashSet_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _HashSet_map, "f").size;
return this.map.size;
}
[Symbol.iterator]() {
return __classPrivateFieldGet(this, _HashSet_map, "f").values();
return this.map.values();
}
add(value) {
__classPrivateFieldGet(this, _HashSet_map, "f").set(this.hash(value), value);
this.map.set(this.hash(value), value);
return this;
}
delete(value) {
return __classPrivateFieldGet(this, _HashSet_map, "f").delete(this.hash(value));
return this.map.delete(this.hash(value));
}
has(value) {
return __classPrivateFieldGet(this, _HashSet_map, "f").has(this.hash(value));
return this.map.has(this.hash(value));
}
clear() {
__classPrivateFieldGet(this, _HashSet_map, "f").clear();
this.map.clear();
}
values() {
return __classPrivateFieldGet(this, _HashSet_map, "f").values();
return this.map.values();
}

@@ -41,0 +35,0 @@ }

export declare class LRUMap<K, V> {
#private;
private limit;
private map;
get [Symbol.toStringTag](): string;

@@ -4,0 +5,0 @@ get size(): number;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _LRUMap_limit, _LRUMap_map;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,23 +8,22 @@ exports.LRUMap = void 0;

constructor(limit) {
_LRUMap_limit.set(this, void 0);
_LRUMap_map.set(this, new Map());
this.map = new Map();
(0, errors_1.assert)(Number.isInteger(limit), 'The parameter limit must be an integer');
(0, errors_1.assert)(limit > 0, 'The parameter limit must be a positive value');
__classPrivateFieldSet(this, _LRUMap_limit, limit, "f");
this.limit = limit;
}
get [(_LRUMap_limit = new WeakMap(), _LRUMap_map = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _LRUMap_map, "f").size;
return this.map.size;
}
set(key, value) {
if (__classPrivateFieldGet(this, _LRUMap_map, "f").has(key)) {
if (this.map.has(key)) {
this.updateItem(key, value);
}
else {
if (__classPrivateFieldGet(this, _LRUMap_map, "f").size === __classPrivateFieldGet(this, _LRUMap_limit, "f")) {
__classPrivateFieldGet(this, _LRUMap_map, "f").delete(this.getColdestKey());
if (this.map.size === this.limit) {
this.map.delete(this.getColdestKey());
}
__classPrivateFieldGet(this, _LRUMap_map, "f").set(key, value);
this.map.set(key, value);
}

@@ -46,3 +33,3 @@ return this;

has(key) {
return __classPrivateFieldGet(this, _LRUMap_map, "f").has(key);
return this.map.has(key);
}

@@ -52,3 +39,3 @@ get(key) {

return undefined;
const value = __classPrivateFieldGet(this, _LRUMap_map, "f").get(key);
const value = this.map.get(key);
this.updateItem(key, value);

@@ -58,13 +45,13 @@ return value;

delete(key) {
return __classPrivateFieldGet(this, _LRUMap_map, "f").delete(key);
return this.map.delete(key);
}
clear() {
__classPrivateFieldGet(this, _LRUMap_map, "f").clear();
this.map.clear();
}
updateItem(key, value) {
__classPrivateFieldGet(this, _LRUMap_map, "f").delete(key);
__classPrivateFieldGet(this, _LRUMap_map, "f").set(key, value);
this.map.delete(key);
this.map.set(key, value);
}
getColdestKey() {
return (0, iterable_operator_1.first)(__classPrivateFieldGet(this, _LRUMap_map, "f").keys());
return (0, iterable_operator_1.first)(this.map.keys());
}

@@ -71,0 +58,0 @@ }

export declare class Queue<T> {
#private;
private items;
get [Symbol.toStringTag](): string;

@@ -4,0 +4,0 @@ get size(): number;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Queue_items;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -12,23 +6,23 @@ exports.Queue = void 0;

constructor() {
_Queue_items.set(this, []);
this.items = [];
}
get [(_Queue_items = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _Queue_items, "f").length;
return this.items.length;
}
empty() {
__classPrivateFieldGet(this, _Queue_items, "f").length = 0;
this.items.length = 0;
}
enqueue(...items) {
__classPrivateFieldGet(this, _Queue_items, "f").push(...items);
this.items.push(...items);
}
dequeue() {
return __classPrivateFieldGet(this, _Queue_items, "f").shift();
return this.items.shift();
}
remove(item) {
let index;
while ((index = __classPrivateFieldGet(this, _Queue_items, "f").indexOf(item)) >= 0) {
__classPrivateFieldGet(this, _Queue_items, "f").splice(index, 1);
while ((index = this.items.indexOf(item)) >= 0) {
this.items.splice(index, 1);
}

@@ -35,0 +29,0 @@ }

export declare class TLRUMap<K, V> {
#private;
itemMetadataSortedByExpirationTime: Array<{
private limit;
private map;
private cancelClearTimeout?;
protected itemMetadataSortedByExpirationTime: Array<{
key: K;

@@ -5,0 +7,0 @@ expirationTime: number;

"use strict";
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _TLRUMap_limit, _TLRUMap_map, _TLRUMap_cancelClearTimeout;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -21,18 +9,16 @@ exports.TLRUMap = void 0;

constructor(limit) {
_TLRUMap_limit.set(this, void 0);
_TLRUMap_map.set(this, new Map());
_TLRUMap_cancelClearTimeout.set(this, void 0);
this.map = new Map();
this.itemMetadataSortedByExpirationTime = [];
(0, errors_1.assert)(Number.isInteger(limit), 'The parameter limit must be an integer');
(0, errors_1.assert)(limit > 0, 'The parameter limit must be a positive value');
__classPrivateFieldSet(this, _TLRUMap_limit, limit, "f");
this.limit = limit;
}
get [(_TLRUMap_limit = new WeakMap(), _TLRUMap_map = new WeakMap(), _TLRUMap_cancelClearTimeout = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return __classPrivateFieldGet(this, _TLRUMap_map, "f").size;
return this.map.size;
}
set(key, value, maxAge) {
if (__classPrivateFieldGet(this, _TLRUMap_map, "f").has(key)) {
if (this.map.has(key)) {
this.updateItem(key, value);

@@ -43,6 +29,6 @@ this.removeItemMetadata(key);

else {
if (__classPrivateFieldGet(this, _TLRUMap_map, "f").size === __classPrivateFieldGet(this, _TLRUMap_limit, "f")) {
__classPrivateFieldGet(this, _TLRUMap_map, "f").delete(this.getColdestKey());
if (this.map.size === this.limit) {
this.map.delete(this.getColdestKey());
}
__classPrivateFieldGet(this, _TLRUMap_map, "f").set(key, value);
this.map.set(key, value);
this.addItemMetadata(key, Date.now() + maxAge);

@@ -53,7 +39,7 @@ }

has(key) {
return __classPrivateFieldGet(this, _TLRUMap_map, "f").has(key);
return this.map.has(key);
}
get(key) {
if (this.has(key)) {
const value = __classPrivateFieldGet(this, _TLRUMap_map, "f").get(key);
const value = this.map.get(key);
this.updateItem(key, value);

@@ -67,3 +53,3 @@ return value;

delete(key) {
const result = __classPrivateFieldGet(this, _TLRUMap_map, "f").delete(key);
const result = this.map.delete(key);
if (result) {

@@ -80,9 +66,9 @@ const index = this.itemMetadataSortedByExpirationTime.findIndex(x => x.key === key);

var _a;
__classPrivateFieldGet(this, _TLRUMap_map, "f").clear();
(_a = __classPrivateFieldGet(this, _TLRUMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
this.map.clear();
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
this.itemMetadataSortedByExpirationTime = [];
}
updateItem(key, value) {
__classPrivateFieldGet(this, _TLRUMap_map, "f").delete(key);
__classPrivateFieldGet(this, _TLRUMap_map, "f").set(key, value);
this.map.delete(key);
this.map.set(key, value);
}

@@ -119,7 +105,7 @@ addItemMetadata(key, expirationTime) {

: this.itemMetadataSortedByExpirationTime.splice(0, this.itemMetadataSortedByExpirationTime.length);
expiredItemKeys.forEach(x => __classPrivateFieldGet(this, _TLRUMap_map, "f").delete(x.key));
expiredItemKeys.forEach(x => this.map.delete(x.key));
}
rescheduleClearTimeout() {
var _a;
(_a = __classPrivateFieldGet(this, _TLRUMap_cancelClearTimeout, "f")) === null || _a === void 0 ? void 0 : _a.call(this);
(_a = this.cancelClearTimeout) === null || _a === void 0 ? void 0 : _a.call(this);
if (this.itemMetadataSortedByExpirationTime.length > 0) {

@@ -132,6 +118,6 @@ const item = this.itemMetadataSortedByExpirationTime[0];

});
__classPrivateFieldSet(this, _TLRUMap_cancelClearTimeout, () => {
this.cancelClearTimeout = () => {
cancel();
__classPrivateFieldSet(this, _TLRUMap_cancelClearTimeout, undefined, "f");
}, "f");
this.cancelClearTimeout = undefined;
};
}

@@ -141,3 +127,3 @@ }

getColdestKey() {
return (0, iterable_operator_1.first)(__classPrivateFieldGet(this, _TLRUMap_map, "f").keys());
return (0, iterable_operator_1.first)(this.map.keys());
}

@@ -144,0 +130,0 @@ }

import { UnpackedIterable } from 'justypes';
export declare class TrieMap<K extends Iterable<T>, V, T = UnpackedIterable<K>> {
#private;
private root;
get [Symbol.toStringTag](): string;

@@ -5,0 +5,0 @@ set(key: K, value: V): this;

"use strict";
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _TrieMap_root;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -19,9 +13,9 @@ exports.TrieMap = void 0;

constructor() {
_TrieMap_root.set(this, new TrieNode());
this.root = new TrieNode();
}
get [(_TrieMap_root = new WeakMap(), Symbol.toStringTag)]() {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
set(key, value) {
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -37,3 +31,3 @@ if (!node.children.has(part)) {

has(key) {
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -50,3 +44,3 @@ if (node.children.has(part)) {

get(key) {
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -64,3 +58,3 @@ if (node.children.has(part)) {

const parentNodes = [];
let node = __classPrivateFieldGet(this, _TrieMap_root, "f");
let node = this.root;
for (const part of key) {

@@ -67,0 +61,0 @@ if (node.children.has(part)) {

{
"name": "@blackglory/structures",
"version": "0.5.0",
"version": "0.5.1",
"description": "",

@@ -5,0 +5,0 @@ "files": [

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc