serializable-bptree 5.1.6 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,9 +4,12 @@ import { ValueComparator } from './base/ValueComparator';
4
4
  import { SerializableData } from './base/SerializeStrategy';
5
5
  export declare class BPTreeAsync<K, V> extends BPTree<K, V> {
6
6
  protected readonly strategy: SerializeStrategyAsync<K, V>;
7
- protected readonly nodes: ReturnType<BPTreeAsync<K, V>['_createCachedNode']>;
7
+ protected readonly nodes: ReturnType<typeof this._createCachedNode>;
8
+ private readonly lock;
8
9
  constructor(strategy: SerializeStrategyAsync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
9
10
  private _createCachedNode;
11
+ private readLock;
12
+ private writeLock;
10
13
  protected getPairsRightToLeft(value: V, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, comparator: (nodeValue: V, value: V) => boolean): Promise<BPTreePair<K, V>>;
11
14
  protected getPairsLeftToRight(value: V, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, comparator: (nodeValue: V, value: V) => boolean): Promise<BPTreePair<K, V>>;
12
15
  protected getPairs(value: V, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, comparator: (nodeValue: V, value: V) => boolean, direction: 1 | -1): Promise<BPTreePair<K, V>>;
@@ -4,7 +4,7 @@ import { ValueComparator } from './base/ValueComparator';
4
4
  import { SerializableData } from './base/SerializeStrategy';
5
5
  export declare class BPTreeSync<K, V> extends BPTree<K, V> {
6
6
  protected readonly strategy: SerializeStrategySync<K, V>;
7
- protected readonly nodes: ReturnType<BPTreeSync<K, V>['_createCachedNode']>;
7
+ protected readonly nodes: ReturnType<typeof this._createCachedNode>;
8
8
  constructor(strategy: SerializeStrategySync<K, V>, comparator: ValueComparator<V>, option?: BPTreeConstructorOption);
9
9
  private _createCachedNode;
10
10
  protected getPairsRightToLeft(value: V, startNode: BPTreeLeafNode<K, V>, endNode: BPTreeLeafNode<K, V> | null, comparator: (nodeValue: V, value: V) => boolean): BPTreePair<K, V>;
@@ -1,4 +1,4 @@
1
- import { CacheEntanglementSync, CacheEntanglementAsync, type StringValue } from 'cache-entanglement';
1
+ import { CacheEntanglementSync, CacheEntanglementAsync } from 'cache-entanglement';
2
2
  import { ValueComparator } from './ValueComparator';
3
3
  import { SerializableData, SerializeStrategy } from './SerializeStrategy';
4
4
  type Sync<T> = T;
@@ -27,14 +27,11 @@ export type BPTreePair<K, V> = Map<K, V>;
27
27
  export type BPTreeUnknownNode<K, V> = BPTreeInternalNode<K, V> | BPTreeLeafNode<K, V>;
28
28
  export interface BPTreeConstructorOption {
29
29
  /**
30
- * The lifespan of the cached node.
31
- * This value is used to determine how long a cached node should be kept in memory.
32
- * If the lifespan is set to a positive number, the cached node will expire after the specified number of milliseconds.
33
- * If the lifespan is set to `0` or a negative number, the cache will not prevent garbage collection.
34
- * If the lifespan is set to a string, the string will be parsed as a time duration.
35
- * For example, '1m' means 1 minute, '1h' means 1 hour, '1d' means 1 day, '1w' means 1 week.
30
+ * The capacity of the cache.
31
+ * This value is used to determine how many nodes can be cached.
32
+ * If not specified, the default value is 1000.
36
33
  */
37
- lifespan?: StringValue | number;
34
+ capacity?: number;
38
35
  }
39
36
  export interface BPTreeNode<K, V> {
40
37
  id: string;
@@ -1,4 +1,4 @@
1
- export type { BPTreeNode, BPTreeCondition } from './base/BPTree';
1
+ export type { BPTreeNode, BPTreeInternalNode, BPTreeLeafNode, BPTreeNodeKey, BPTreePair, BPTreeUnknownNode, BPTreeCondition } from './base/BPTree';
2
2
  export type { SerializeStrategyHead, SerializableData } from './base/SerializeStrategy';
3
3
  export { ValueComparator, NumericComparator, StringComparator } from './base/ValueComparator';
4
4
  export { BPTreeSync } from './BPTreeSync';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serializable-bptree",
3
- "version": "5.1.6",
3
+ "version": "5.2.1",
4
4
  "description": "Store the B+tree flexibly, not only in-memory.",
5
5
  "types": "./dist/types/index.d.ts",
6
6
  "main": "./dist/cjs/index.cjs",
@@ -16,7 +16,7 @@
16
16
  "dist/**/*"
17
17
  ],
18
18
  "scripts": {
19
- "test": "jest -t",
19
+ "test": "jest",
20
20
  "build": "node build/index.js && tsc"
21
21
  },
22
22
  "author": "izure <admin@izure.org>",
@@ -36,13 +36,14 @@
36
36
  },
37
37
  "license": "MIT",
38
38
  "devDependencies": {
39
- "@types/jest": "^29.5.14",
40
- "esbuild": "^0.25.5",
41
- "jest": "^29.7.0",
42
- "ts-jest": "^29.4.0",
43
- "typescript": "^5.8.3"
39
+ "@types/jest": "^30.0.0",
40
+ "esbuild": "^0.27.2",
41
+ "jest": "^30.2.0",
42
+ "ts-jest": "^29.4.6",
43
+ "typescript": "^5.9.3"
44
44
  },
45
45
  "dependencies": {
46
- "cache-entanglement": "^1.6.0"
46
+ "cache-entanglement": "^1.7.1",
47
+ "ryoiki": "^1.2.0"
47
48
  }
48
- }
49
+ }