@keyv/bigmap 1.0.0 → 1.0.2
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.
- package/dist/index.cjs +15 -4
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +15 -4
- package/package.json +11 -9
package/dist/index.cjs
CHANGED
|
@@ -39,7 +39,10 @@ function djb2Hash(string_, min = 0, max = 10) {
|
|
|
39
39
|
}
|
|
40
40
|
var BigMap = class extends import_hookified.Hookified {
|
|
41
41
|
_storeSize = 4;
|
|
42
|
-
_store = Array.from(
|
|
42
|
+
_store = Array.from(
|
|
43
|
+
{ length: this._storeSize },
|
|
44
|
+
() => /* @__PURE__ */ new Map()
|
|
45
|
+
);
|
|
43
46
|
_storeHashFunction;
|
|
44
47
|
/**
|
|
45
48
|
* Creates an instance of BigMap.
|
|
@@ -105,7 +108,9 @@ var BigMap = class extends import_hookified.Hookified {
|
|
|
105
108
|
*/
|
|
106
109
|
getStoreMap(index) {
|
|
107
110
|
if (index < 0 || index >= this._storeSize) {
|
|
108
|
-
throw new Error(
|
|
111
|
+
throw new Error(
|
|
112
|
+
`Index out of bounds: ${index}. Valid range is 0 to ${this._storeSize - 1}.`
|
|
113
|
+
);
|
|
109
114
|
}
|
|
110
115
|
return this._store[index];
|
|
111
116
|
}
|
|
@@ -114,7 +119,10 @@ var BigMap = class extends import_hookified.Hookified {
|
|
|
114
119
|
* This method is called when the BigMap instance is created.
|
|
115
120
|
*/
|
|
116
121
|
initStore() {
|
|
117
|
-
this._store = Array.from(
|
|
122
|
+
this._store = Array.from(
|
|
123
|
+
{ length: this._storeSize },
|
|
124
|
+
() => /* @__PURE__ */ new Map()
|
|
125
|
+
);
|
|
118
126
|
}
|
|
119
127
|
/**
|
|
120
128
|
* Gets the store for a specific key.
|
|
@@ -128,7 +136,10 @@ var BigMap = class extends import_hookified.Hookified {
|
|
|
128
136
|
return this.getStoreMap(0);
|
|
129
137
|
}
|
|
130
138
|
const storeSize = this._storeSize - 1;
|
|
131
|
-
const index = this._storeHashFunction ? this._storeHashFunction(String(key), storeSize) :
|
|
139
|
+
const index = this._storeHashFunction ? this._storeHashFunction(String(key), storeSize) : (
|
|
140
|
+
/* c8 ignore next */
|
|
141
|
+
defaultHashFunction(String(key), storeSize)
|
|
142
|
+
);
|
|
132
143
|
return this.getStoreMap(index);
|
|
133
144
|
}
|
|
134
145
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -13,10 +13,10 @@ type MapInterfacee<K, V> = {
|
|
|
13
13
|
has(key: K): boolean;
|
|
14
14
|
set(key: K, value: V): Map<K, V>;
|
|
15
15
|
};
|
|
16
|
-
type StoreHashFunction = (
|
|
16
|
+
type StoreHashFunction = (key: string, storeSize: number) => number;
|
|
17
17
|
declare function defaultHashFunction(key: string, storeSize: number): number;
|
|
18
18
|
declare function djb2Hash(string_: string, min?: number, max?: number): number;
|
|
19
|
-
type BigMapOptions
|
|
19
|
+
type BigMapOptions = {
|
|
20
20
|
/**
|
|
21
21
|
* Optional size of the store. The default is 4 maps objects.
|
|
22
22
|
* @default 4
|
|
@@ -36,7 +36,7 @@ declare class BigMap<K, V> extends Hookified implements MapInterfacee<K, V> {
|
|
|
36
36
|
* Creates an instance of BigMap.
|
|
37
37
|
* @param {BigMapOptions<K, V>} [options] - Optional configuration options for the BigMap.
|
|
38
38
|
*/
|
|
39
|
-
constructor(options?: BigMapOptions
|
|
39
|
+
constructor(options?: BigMapOptions);
|
|
40
40
|
/**
|
|
41
41
|
* Gets the number of maps in the store.
|
|
42
42
|
* @returns {number} The number of maps in the store.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,10 +13,10 @@ type MapInterfacee<K, V> = {
|
|
|
13
13
|
has(key: K): boolean;
|
|
14
14
|
set(key: K, value: V): Map<K, V>;
|
|
15
15
|
};
|
|
16
|
-
type StoreHashFunction = (
|
|
16
|
+
type StoreHashFunction = (key: string, storeSize: number) => number;
|
|
17
17
|
declare function defaultHashFunction(key: string, storeSize: number): number;
|
|
18
18
|
declare function djb2Hash(string_: string, min?: number, max?: number): number;
|
|
19
|
-
type BigMapOptions
|
|
19
|
+
type BigMapOptions = {
|
|
20
20
|
/**
|
|
21
21
|
* Optional size of the store. The default is 4 maps objects.
|
|
22
22
|
* @default 4
|
|
@@ -36,7 +36,7 @@ declare class BigMap<K, V> extends Hookified implements MapInterfacee<K, V> {
|
|
|
36
36
|
* Creates an instance of BigMap.
|
|
37
37
|
* @param {BigMapOptions<K, V>} [options] - Optional configuration options for the BigMap.
|
|
38
38
|
*/
|
|
39
|
-
constructor(options?: BigMapOptions
|
|
39
|
+
constructor(options?: BigMapOptions);
|
|
40
40
|
/**
|
|
41
41
|
* Gets the number of maps in the store.
|
|
42
42
|
* @returns {number} The number of maps in the store.
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,10 @@ function djb2Hash(string_, min = 0, max = 10) {
|
|
|
13
13
|
}
|
|
14
14
|
var BigMap = class extends Hookified {
|
|
15
15
|
_storeSize = 4;
|
|
16
|
-
_store = Array.from(
|
|
16
|
+
_store = Array.from(
|
|
17
|
+
{ length: this._storeSize },
|
|
18
|
+
() => /* @__PURE__ */ new Map()
|
|
19
|
+
);
|
|
17
20
|
_storeHashFunction;
|
|
18
21
|
/**
|
|
19
22
|
* Creates an instance of BigMap.
|
|
@@ -79,7 +82,9 @@ var BigMap = class extends Hookified {
|
|
|
79
82
|
*/
|
|
80
83
|
getStoreMap(index) {
|
|
81
84
|
if (index < 0 || index >= this._storeSize) {
|
|
82
|
-
throw new Error(
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Index out of bounds: ${index}. Valid range is 0 to ${this._storeSize - 1}.`
|
|
87
|
+
);
|
|
83
88
|
}
|
|
84
89
|
return this._store[index];
|
|
85
90
|
}
|
|
@@ -88,7 +93,10 @@ var BigMap = class extends Hookified {
|
|
|
88
93
|
* This method is called when the BigMap instance is created.
|
|
89
94
|
*/
|
|
90
95
|
initStore() {
|
|
91
|
-
this._store = Array.from(
|
|
96
|
+
this._store = Array.from(
|
|
97
|
+
{ length: this._storeSize },
|
|
98
|
+
() => /* @__PURE__ */ new Map()
|
|
99
|
+
);
|
|
92
100
|
}
|
|
93
101
|
/**
|
|
94
102
|
* Gets the store for a specific key.
|
|
@@ -102,7 +110,10 @@ var BigMap = class extends Hookified {
|
|
|
102
110
|
return this.getStoreMap(0);
|
|
103
111
|
}
|
|
104
112
|
const storeSize = this._storeSize - 1;
|
|
105
|
-
const index = this._storeHashFunction ? this._storeHashFunction(String(key), storeSize) :
|
|
113
|
+
const index = this._storeHashFunction ? this._storeHashFunction(String(key), storeSize) : (
|
|
114
|
+
/* c8 ignore next */
|
|
115
|
+
defaultHashFunction(String(key), storeSize)
|
|
116
|
+
);
|
|
106
117
|
return this.getStoreMap(index);
|
|
107
118
|
}
|
|
108
119
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/bigmap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Bigmap for Keyv",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/jaredwray/keyv",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"hookified": "^1.
|
|
35
|
+
"hookified": "^1.12.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@
|
|
38
|
+
"@biomejs/biome": "^2.2.4",
|
|
39
|
+
"@faker-js/faker": "^10.0.0",
|
|
39
40
|
"@vitest/coverage-v8": "^3.2.4",
|
|
40
41
|
"rimraf": "^6.0.1",
|
|
41
|
-
"tsd": "^0.
|
|
42
|
-
"vitest": "^3.2.4"
|
|
43
|
-
"xo": "^1.1.1"
|
|
42
|
+
"tsd": "^0.33.0",
|
|
43
|
+
"vitest": "^3.2.4"
|
|
44
44
|
},
|
|
45
45
|
"tsd": {
|
|
46
46
|
"directory": "test"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">= 18"
|
|
50
50
|
},
|
|
51
51
|
"files": [
|
|
52
52
|
"dist",
|
|
@@ -54,8 +54,10 @@
|
|
|
54
54
|
],
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
57
|
+
"lint": "biome check --write --error-on-warnings",
|
|
58
|
+
"lint:ci": "biome check --error-on-warnings",
|
|
59
|
+
"test": "pnpm lint && vitest run --coverage",
|
|
60
|
+
"test:ci": "pnpm lint:ci && vitest --run --sequence.setupFiles=list --coverage",
|
|
59
61
|
"clean": "rimraf ./node_modules ./coverage ./dist"
|
|
60
62
|
}
|
|
61
63
|
}
|