Comparing version 1.1.1 to 1.1.2
@@ -1,2 +0,1 @@ | ||
declare const inspectSymbol: unique symbol; | ||
export declare class GoodDAG<T = string> implements DAGEntry<T> { | ||
@@ -6,3 +5,2 @@ readonly data: DAGData<T>; | ||
constructor(rootValue: T, blockSize?: number); | ||
[inspectSymbol](): string; | ||
/** | ||
@@ -38,3 +36,2 @@ * get the parent entry to this one (returns undefined, this is the root) | ||
constructor(dag: DAGData<T>, index: number); | ||
[inspectSymbol](): string; | ||
/** | ||
@@ -77,3 +74,2 @@ * get the value that this DAG entry stores | ||
constructor(blockSize: number, rootValue: T, parentDAG?: DAGData<T>, parentIndex?: number); | ||
[inspectSymbol](): string; | ||
rootData(): DAGData<T>; | ||
@@ -80,0 +76,0 @@ size(): number; |
@@ -8,4 +8,2 @@ "use strict"; | ||
exports.DAGEntry = exports.GoodDAG = void 0; | ||
const inspectSymbol = Symbol.for('nodejs.util.inspect.custom'); | ||
const util_1 = require("util"); | ||
// exported class is a DAGEntry that creates its data storage | ||
@@ -20,5 +18,2 @@ // and is the root entry. | ||
} | ||
[inspectSymbol]() { | ||
return formatEntry(this); | ||
} | ||
/** | ||
@@ -70,5 +65,2 @@ * get the parent entry to this one (returns undefined, this is the root) | ||
} | ||
[inspectSymbol]() { | ||
return formatEntry(this); | ||
} | ||
/** | ||
@@ -119,12 +111,2 @@ * get the value that this DAG entry stores | ||
const isPosLongInt = (i) => i && isLongInt(i); | ||
const formatEntry = (entry) => { | ||
const p = entry.parent(); | ||
return (`GoodDAG ` + | ||
(0, util_1.format)({ | ||
'value()': entry.value(), | ||
...(p ? { 'parent()': entry.parent() } : {}), | ||
index: entry.index, | ||
data: entry.data, | ||
})); | ||
}; | ||
const max32 = Math.pow(2, 32); | ||
@@ -140,4 +122,2 @@ const max16 = Math.pow(2, 16); | ||
}; | ||
const dataInspectMap = new Map(); | ||
let blockIndex = 0; | ||
class DAGData { | ||
@@ -175,10 +155,2 @@ // these can grow up to blockSize | ||
} | ||
[inspectSymbol]() { | ||
const i = dataInspectMap.get(this) || { | ||
block: blockIndex++, | ||
}; | ||
i.nextFree = this.nextFree; | ||
dataInspectMap.set(this, i); | ||
return `DAGData ${this.blockSize} ${(0, util_1.format)(i)}`; | ||
} | ||
rootData() { | ||
@@ -185,0 +157,0 @@ let d = this; |
@@ -1,2 +0,1 @@ | ||
declare const inspectSymbol: unique symbol; | ||
export declare class GoodDAG<T = string> implements DAGEntry<T> { | ||
@@ -6,3 +5,2 @@ readonly data: DAGData<T>; | ||
constructor(rootValue: T, blockSize?: number); | ||
[inspectSymbol](): string; | ||
/** | ||
@@ -38,3 +36,2 @@ * get the parent entry to this one (returns undefined, this is the root) | ||
constructor(dag: DAGData<T>, index: number); | ||
[inspectSymbol](): string; | ||
/** | ||
@@ -77,3 +74,2 @@ * get the value that this DAG entry stores | ||
constructor(blockSize: number, rootValue: T, parentDAG?: DAGData<T>, parentIndex?: number); | ||
[inspectSymbol](): string; | ||
rootData(): DAGData<T>; | ||
@@ -80,0 +76,0 @@ size(): number; |
@@ -5,4 +5,2 @@ // a directed acyclic graph using a linked list | ||
// object and the index within it. | ||
const inspectSymbol = Symbol.for('nodejs.util.inspect.custom'); | ||
import { format } from 'util'; | ||
// exported class is a DAGEntry that creates its data storage | ||
@@ -17,5 +15,2 @@ // and is the root entry. | ||
} | ||
[inspectSymbol]() { | ||
return formatEntry(this); | ||
} | ||
/** | ||
@@ -66,5 +61,2 @@ * get the parent entry to this one (returns undefined, this is the root) | ||
} | ||
[inspectSymbol]() { | ||
return formatEntry(this); | ||
} | ||
/** | ||
@@ -114,12 +106,2 @@ * get the value that this DAG entry stores | ||
const isPosLongInt = (i) => i && isLongInt(i); | ||
const formatEntry = (entry) => { | ||
const p = entry.parent(); | ||
return (`GoodDAG ` + | ||
format({ | ||
'value()': entry.value(), | ||
...(p ? { 'parent()': entry.parent() } : {}), | ||
index: entry.index, | ||
data: entry.data, | ||
})); | ||
}; | ||
const max32 = Math.pow(2, 32); | ||
@@ -135,4 +117,2 @@ const max16 = Math.pow(2, 16); | ||
}; | ||
const dataInspectMap = new Map(); | ||
let blockIndex = 0; | ||
class DAGData { | ||
@@ -170,10 +150,2 @@ // these can grow up to blockSize | ||
} | ||
[inspectSymbol]() { | ||
const i = dataInspectMap.get(this) || { | ||
block: blockIndex++, | ||
}; | ||
i.nextFree = this.nextFree; | ||
dataInspectMap.set(this, i); | ||
return `DAGData ${this.blockSize} ${format(i)}`; | ||
} | ||
rootData() { | ||
@@ -180,0 +152,0 @@ let d = this; |
{ | ||
"name": "good-dag", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "fast expandable directed acyclic graph using linked lists", | ||
@@ -5,0 +5,0 @@ "author": "Isaac Z. Schlueter <i@izs.me> (https://blog.izs.me)", |
@@ -171,3 +171,4 @@ # good-dag | ||
more than 128kb per block: set `blockSize` to `65536`. Each | ||
block will allocate 128kb. | ||
block will allocate 128kb. (Set it smaller than that if 128kb | ||
is more than you want to spend.) | ||
- way more than 10m items (like billions), _and_ the DAG object | ||
@@ -174,0 +175,0 @@ is going to stick around for a long time (like a long-lived |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
209
35832
543