Socket
Socket
Sign inDemoInstall

@blackglory/structures

Package Overview
Dependencies
23
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.13.4 to 0.14.0

6

lib/box.js
export class Box {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
constructor(value) {
this.value = value;
}
get [Symbol.toStringTag]() {
return this.constructor.name;
}
set(value) {

@@ -9,0 +9,0 @@ this.value = value;

import { assert } from '@blackglory/errors';
export class DynamicTypedArray {
constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
this.typedArrayConstructor = typedArrayConstructor;
this._length = 0;
assert(Number.isInteger(capacity), 'capacity must be an integer');
assert(capacity >= 0, 'capacity must be greater than or equal to 0');
assert(growthFactor >= 1, 'growthFactory must be greater than or equal to 1');
this.initialCapacity = capacity;
this.array = new typedArrayConstructor(capacity);
this.growthFactor = growthFactor;
}
get internalTypedArray() {

@@ -28,2 +18,12 @@ return this.array;

}
constructor(typedArrayConstructor, { capacity = 0, growthFactor = 1.5 } = {}) {
this.typedArrayConstructor = typedArrayConstructor;
this._length = 0;
assert(Number.isInteger(capacity), 'capacity must be an integer');
assert(capacity >= 0, 'capacity must be greater than or equal to 0');
assert(growthFactor >= 1, 'growthFactory must be greater than or equal to 1');
this.initialCapacity = capacity;
this.array = new typedArrayConstructor(capacity);
this.growthFactor = growthFactor;
}
set(index, value) {

@@ -30,0 +30,0 @@ if (index >= this.capacity) {

@@ -1,2 +0,2 @@

declare type Listener<Args extends unknown[]> = (...args: Args) => void;
type Listener<Args extends unknown[]> = (...args: Args) => void;
export declare class Emitter<EventToArgs extends Record<Event, unknown[]> = Record<string | number | symbol, unknown[]>, Event extends string | number | symbol = keyof EventToArgs> {

@@ -3,0 +3,0 @@ private map;

export class HashMap {
constructor(hash) {
this.hash = hash;
this.map = new Map();
}
get [Symbol.toStringTag]() {

@@ -12,2 +8,6 @@ return this.constructor.name;

}
constructor(hash) {
this.hash = hash;
this.map = new Map();
}
set(key, value) {

@@ -14,0 +14,0 @@ this.map.set(this.hash(key), value);

export class HashSet {
constructor(hash) {
this.hash = hash;
this.map = new Map();
}
get [Symbol.toStringTag]() {

@@ -15,2 +11,6 @@ return this.constructor.name;

}
constructor(hash) {
this.hash = hash;
this.map = new Map();
}
add(value) {

@@ -17,0 +17,0 @@ this.map.set(this.hash(value), value);

import { assert } from '@blackglory/errors';
import { first } from 'iterable-operator';
export class LRUMap {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return this.map.size;
}
constructor(limit) {

@@ -10,8 +16,2 @@ this.map = new Map();

}
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return this.map.size;
}
set(key, value) {

@@ -18,0 +18,0 @@ if (this.map.has(key)) {

import { SkipList } from "./utils/skip-list.js";
import { map } from 'iterable-operator';
export class SortedSet {
constructor(compare) {
this.skipList = new SkipList(compare);
}
get [Symbol.toStringTag]() {

@@ -13,2 +10,5 @@ return this.constructor.name;

}
constructor(compare) {
this.skipList = new SkipList(compare);
}
values() {

@@ -15,0 +15,0 @@ return map(this.skipList.elements(), node => node.value);

export class SparseSet {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
[Symbol.iterator]() {
return this.indexToValue[Symbol.iterator]();
}
get size() {
return this.indexToValue.length;
}
constructor(array = []) {

@@ -12,11 +21,2 @@ this.indexToValue = [];

}
get [Symbol.toStringTag]() {
return this.constructor.name;
}
[Symbol.iterator]() {
return this.indexToValue[Symbol.iterator]();
}
get size() {
return this.indexToValue.length;
}
values() {

@@ -23,0 +23,0 @@ return this.indexToValue[Symbol.iterator]();

@@ -32,3 +32,3 @@ import { zip, toArray, map } from 'iterable-operator';

values() {
return map(this.entries(), ([_, value]) => value);
return map(this.entries(), ([, value]) => value);
}

@@ -35,0 +35,0 @@ set(key, value) {

@@ -5,2 +5,8 @@ import { assert } from '@blackglory/errors';

export class TLRUMap {
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return this.map.size;
}
constructor(limit) {

@@ -13,8 +19,2 @@ this.map = new Map();

}
get [Symbol.toStringTag]() {
return this.constructor.name;
}
get size() {
return this.map.size;
}
set(key, value, timeToLive = Infinity) {

@@ -21,0 +21,0 @@ if (this.map.has(key)) {

@@ -32,3 +32,3 @@ import { zip, toArray, map } from 'iterable-operator';

values() {
return map(this.entries(), ([_, value]) => value);
return map(this.entries(), ([, value]) => value);
}

@@ -35,0 +35,0 @@ set(key, value) {

import { assert } from '@blackglory/errors';
export class TypedSparseMap {
constructor(array) {
this.keyToIndex = [];
this.indexToKey = [];
assert(array.length === 0, 'array should be empty');
this.indexToValue = array;
}
get [Symbol.toStringTag]() {

@@ -18,2 +12,8 @@ return this.constructor.name;

}
constructor(array) {
this.keyToIndex = [];
this.indexToKey = [];
assert(array.length === 0, 'array should be empty');
this.indexToValue = array;
}
*entries() {

@@ -20,0 +20,0 @@ for (let i = 0; i < this.indexToKey.length; i++) {

@@ -12,2 +12,5 @@ import { isntNull } from 'extra-utils';

export class SkipList {
get size() {
return this._size;
}
constructor(compare) {

@@ -22,5 +25,2 @@ this.compare = compare;

}
get size() {
return this._size;
}
*elements() {

@@ -27,0 +27,0 @@ let currentNode = this.head;

{
"name": "@blackglory/structures",
"version": "0.13.4",
"version": "0.14.0",
"description": "",

@@ -17,3 +17,3 @@ "files": [

"engines": {
"node": ">=16"
"node": ">=18.17.0"
},

@@ -30,4 +30,4 @@ "scripts": {

"bench": "run-s bench:*",
"bench:bit-set": "ts-node --require tsconfig-paths/register benches/bit-set.ts",
"bench:sparse-map": "ts-node --require tsconfig-paths/register benches/sparse-map.ts",
"bench:bit-set": "tsx benches/bit-set.ts",
"bench:sparse-map": "tsx benches/sparse-map.ts",
"release": "standard-version"

@@ -42,37 +42,36 @@ },

"devDependencies": {
"@blackglory/jest-resolver": "^0.3.0",
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@types/jest": "^29.5.0",
"@blackglory/jest-resolver": "^0.3.1",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@types/jest": "^29.5.12",
"@types/node": "16",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"cross-env": "^7.0.3",
"eslint": "^8.36.0",
"extra-benchmark": "^0.2.2",
"extra-generator": "^0.4.0",
"extra-promise": "^6.0.5",
"eslint": "^8.56.0",
"extra-benchmark": "^0.2.3",
"extra-generator": "^0.5.4",
"extra-promise": "^6.2.0",
"husky": "^4.3.8",
"jest": "^29.5.0",
"jest-resolve": "^29.5.0",
"jest": "^29.7.0",
"jest-resolve": "^29.7.0",
"npm-run-all": "^4.1.5",
"return-style": "^3.0.0",
"rimraf": "^4.4.0",
"return-style": "^3.0.1",
"rimraf": "^5.0.5",
"standard-version": "^9.5.0",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"ts-patch": "^2.1.0",
"tsconfig-paths": "^4.1.2",
"tslib": "^2.5.0",
"typescript": "4.8",
"ts-jest": "^29.1.2",
"ts-patch": "^3.1.2",
"tslib": "^2.6.2",
"tsx": "^4.7.1",
"typescript": "5.3.3",
"typescript-transform-paths": "^3.4.6"
},
"dependencies": {
"@blackglory/errors": "^3.0.0",
"@blackglory/go": "^1.1.2",
"extra-timers": "^0.2.5",
"extra-utils": "^5.1.0",
"iterable-operator": "^4.0.3",
"justypes": "^4.2.0"
"@blackglory/errors": "^3.0.3",
"@blackglory/go": "^1.1.3",
"extra-timers": "^0.2.6",
"extra-utils": "^5.6.0",
"iterable-operator": "^5.0.0",
"justypes": "^4.2.1"
}
}

@@ -37,3 +37,3 @@ import { zip, toArray, map } from 'iterable-operator'

values(): IterableIterator<T> {
return map(this.entries(), ([_, value]) => value)
return map(this.entries(), ([, value]) => value)
}

@@ -40,0 +40,0 @@

@@ -37,3 +37,3 @@ import { zip, toArray, map } from 'iterable-operator'

values(): IterableIterator<V> {
return map(this.entries(), ([_, value]) => value)
return map(this.entries(), ([, value]) => value)
}

@@ -40,0 +40,0 @@

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

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