@chainsafe/persistent-ts
Advanced tools
Comparing version
@@ -1,4 +0,3 @@ | ||
export * from "./List"; | ||
export * from "./Vector"; | ||
export * from "./MutableVector"; | ||
//# sourceMappingURL=index.d.ts.map | ||
export * from "./List.js"; | ||
export * from "./Vector.js"; | ||
export * from "./MutableVector.js"; |
@@ -1,15 +0,4 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./List"), exports); | ||
__exportStar(require("./Vector"), exports); | ||
__exportStar(require("./MutableVector"), exports); | ||
export * from "./List.js"; | ||
export * from "./Vector.js"; | ||
export * from "./MutableVector.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -105,2 +105,1 @@ /** | ||
} | ||
//# sourceMappingURL=List.d.ts.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.List = void 0; | ||
// We can share a single empty node between all lists. | ||
@@ -17,3 +14,4 @@ const EMPTY_NODE = { next: null }; | ||
*/ | ||
class List { | ||
export class List { | ||
_node; | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
@@ -197,2 +195,2 @@ constructor(_node) { | ||
} | ||
exports.List = List; | ||
//# sourceMappingURL=List.js.map |
@@ -1,2 +0,2 @@ | ||
import { PersistentVector, TransientVector } from "./Vector"; | ||
import { PersistentVector, TransientVector } from "./Vector.js"; | ||
/** | ||
@@ -8,2 +8,3 @@ * A mutable reference to a PersistentVector or TransientVector | ||
private constructor(); | ||
get length(): number; | ||
static empty<T>(): MutableVector<T>; | ||
@@ -13,3 +14,2 @@ static from<T>(values: Iterable<T>): MutableVector<T>; | ||
asPersistent(): this; | ||
get length(): number; | ||
get(index: number): T | undefined; | ||
@@ -26,2 +26,1 @@ set(index: number, value: T): void; | ||
} | ||
//# sourceMappingURL=MutableVector.d.ts.map |
@@ -1,17 +0,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MutableVector = void 0; | ||
const Vector_1 = require("./Vector"); | ||
import { PersistentVector } from "./Vector.js"; | ||
/** | ||
* A mutable reference to a PersistentVector or TransientVector | ||
*/ | ||
class MutableVector { | ||
export class MutableVector { | ||
vector; | ||
constructor(vector) { | ||
this.vector = vector; | ||
} | ||
get length() { | ||
return this.vector.length; | ||
} | ||
static empty() { | ||
return new MutableVector(Vector_1.PersistentVector.empty); | ||
return new MutableVector(PersistentVector.empty); | ||
} | ||
static from(values) { | ||
return new MutableVector(Vector_1.PersistentVector.from(values)); | ||
return new MutableVector(PersistentVector.from(values)); | ||
} | ||
@@ -30,5 +31,2 @@ asTransient() { | ||
} | ||
get length() { | ||
return this.vector.length; | ||
} | ||
get(index) { | ||
@@ -54,3 +52,3 @@ return this.vector.get(index); | ||
this.vector = this.vector.pop(); | ||
return last !== null && last !== void 0 ? last : undefined; | ||
return last ?? undefined; | ||
} | ||
@@ -74,2 +72,2 @@ *[Symbol.iterator]() { | ||
} | ||
exports.MutableVector = MutableVector; | ||
//# sourceMappingURL=MutableVector.js.map |
@@ -13,3 +13,3 @@ interface ILeaf<T> { | ||
} | ||
declare type INode<T> = ILeaf<T> | IBranch<T>; | ||
type INode<T> = ILeaf<T> | IBranch<T>; | ||
/** | ||
@@ -175,2 +175,1 @@ * A PersistentVector is a collection of values indexed by contiguous integers. | ||
export {}; | ||
//# sourceMappingURL=Vector.d.ts.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransientVector = exports.PersistentVector = void 0; | ||
const BIT_WIDTH = 5; | ||
@@ -30,3 +27,12 @@ const BIT_MASK = 0b11111; | ||
*/ | ||
class PersistentVector { | ||
export class PersistentVector { | ||
root; | ||
shift; | ||
tail; | ||
length; | ||
/** | ||
* The empty vector | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
static empty = new PersistentVector(emptyNode(), DEFAULT_LEVEL_SHIFT, Array(BRANCH_SIZE).fill(undefined), 0); | ||
constructor(root, shift, tail, length) { | ||
@@ -261,13 +267,11 @@ this.root = root; | ||
} | ||
exports.PersistentVector = PersistentVector; | ||
/** | ||
* The empty vector | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
PersistentVector.empty = new PersistentVector(emptyNode(), DEFAULT_LEVEL_SHIFT, Array(BRANCH_SIZE).fill(undefined), 0); | ||
/** | ||
* A TransientVector is a collection of values indexed by contiguous integers. | ||
* TransientVectors support access to items by index in log32N hops. | ||
*/ | ||
class TransientVector { | ||
export class TransientVector { | ||
root; | ||
shift; | ||
tail; | ||
length; | ||
constructor(root, shift, tail, length) { | ||
@@ -518,3 +522,2 @@ this.root = root; | ||
} | ||
exports.TransientVector = TransientVector; | ||
/** | ||
@@ -542,1 +545,2 @@ * Recursively loop through the nodes and push node to values array. | ||
} | ||
//# sourceMappingURL=Vector.js.map |
{ | ||
"name": "@chainsafe/persistent-ts", | ||
"version": "0.19.1", | ||
"version": "0.19.2", | ||
"description": "Persistent data structures for TypeScript.", | ||
"main": "lib/index.js", | ||
"type": "module", | ||
"main": "./lib/cjs/index.js", | ||
"module": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"files": [ | ||
"lib/**/*.d.ts", | ||
"lib/**/*.js", | ||
"lib/**/*.js.map" | ||
"lib/**/*.js.map", | ||
"lib/**/package.json" | ||
], | ||
"scripts": { | ||
"clean": "rm -rf lib && rm -f *.tsbuildinfo", | ||
"build": "tsc", | ||
"clean": "rm -rf lib", | ||
"build": "yarn build:cjs && yarn build:esm && yarn build:types", | ||
"build:esm": "tsc -p tsconfig.build.esm.json", | ||
"build:cjs": "tsc -p tsconfig.build.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/cjs/package.json", | ||
"build:types": "tsc -p tsconfig.build.types.json", | ||
"lint": "eslint --color --ext .ts src/", | ||
"prepublishOnly": "yarn build", | ||
"test:unit": "mocha 'test/unit/**/*.test.ts'", | ||
"test:perf": "mocha 'test/perf/**/*.test.ts'" | ||
"check-types": "tsc --noEmit", | ||
"test:unit": "vitest run --dir test/unit", | ||
"test:perf": "node --loader=ts-node/esm' benchmark 'test/perf/**/*.test.ts'" | ||
}, | ||
@@ -49,4 +56,3 @@ "repository": { | ||
"access": "public" | ||
}, | ||
"gitHead": "e677b6b34f3eaa75de08b209440afc1e16b3dcd2" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
110500
164.8%24
100%1944
72.95%0
-100%Yes
NaN