dynamic-multikey-map 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/lib/index.js +1 -4
- package/lib/src/MultiKeyMap.d.ts +66 -0
- package/lib/src/index.d.ts +1 -0
- package/package.json +7 -5
package/lib/index.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
|
|
8
5
|
// src/MultiKeyMap.ts
|
|
9
6
|
var MultiKeyMap = class {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
type ExtractorFunction<T, K> = (value: T) => K;
|
|
2
|
+
export declare class MultiKeyMap<ObjectType, KeyValueTypes extends unknown> {
|
|
3
|
+
extractors: ExtractorFunction<ObjectType, KeyValueTypes>[];
|
|
4
|
+
protected valueKeys: Map<ObjectType, KeyValueTypes[]>;
|
|
5
|
+
protected map: Map<KeyValueTypes, ObjectType>;
|
|
6
|
+
constructor(extractors: ExtractorFunction<ObjectType, KeyValueTypes>[]);
|
|
7
|
+
get size(): number;
|
|
8
|
+
/**
|
|
9
|
+
* Clears the map keys and values
|
|
10
|
+
*/
|
|
11
|
+
clear: () => void;
|
|
12
|
+
/**
|
|
13
|
+
* Adds a value to the map
|
|
14
|
+
* @param value
|
|
15
|
+
*/
|
|
16
|
+
add: (value: ObjectType) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Removes a value from the map by value
|
|
19
|
+
* @param value
|
|
20
|
+
* @returns false if the value was not found in the map, true if successfull
|
|
21
|
+
*/
|
|
22
|
+
deleteByValue: (value: ObjectType) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Removes a value from the map by key
|
|
25
|
+
* @param key
|
|
26
|
+
* @returns false if the key was not found in the map, true if successfull
|
|
27
|
+
*/
|
|
28
|
+
deleteByKey: (key: KeyValueTypes) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @param key
|
|
31
|
+
* @returns if a key exists in the map
|
|
32
|
+
*/
|
|
33
|
+
has: (key: KeyValueTypes) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Finds he value for a specified key
|
|
36
|
+
* @param key
|
|
37
|
+
* @returns associated value
|
|
38
|
+
*/
|
|
39
|
+
get: (key: KeyValueTypes) => ObjectType | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Replaces the value of a specific key. It will update all previously associated keys to match
|
|
42
|
+
* @param key
|
|
43
|
+
* @param value
|
|
44
|
+
* @returns true if successfull, false if not found
|
|
45
|
+
*/
|
|
46
|
+
replace: (key: KeyValueTypes, value: ObjectType) => boolean;
|
|
47
|
+
/**
|
|
48
|
+
* @returns an iterator for the map keys
|
|
49
|
+
*/
|
|
50
|
+
keys: () => IterableIterator<KeyValueTypes[]>;
|
|
51
|
+
/**
|
|
52
|
+
* @returns an iterator for the map entries
|
|
53
|
+
*/
|
|
54
|
+
entries: () => IterableIterator<[KeyValueTypes[], ObjectType]>;
|
|
55
|
+
/**
|
|
56
|
+
* @returns an iterator for the map values
|
|
57
|
+
*/
|
|
58
|
+
values: () => IterableIterator<ObjectType>;
|
|
59
|
+
/**
|
|
60
|
+
* Loops over the map with a callback
|
|
61
|
+
* @param callbackfn
|
|
62
|
+
* @param thisArg
|
|
63
|
+
*/
|
|
64
|
+
forEach: (callbackfn: (value: ObjectType, key: KeyValueTypes[], map: this) => void, thisArg?: any) => void;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MultiKeyMap } from "./MultiKeyMap.js";
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dynamic-multikey-map",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"packageManager": "bun@1.
|
|
5
|
-
"version": "1.0.
|
|
4
|
+
"packageManager": "bun@1.3.11",
|
|
5
|
+
"version": "1.0.2",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"module": "./lib/index.js",
|
|
7
9
|
"exports": {
|
|
8
10
|
".": {
|
|
9
11
|
"types": "./lib/index.d.ts",
|
|
@@ -12,11 +14,11 @@
|
|
|
12
14
|
},
|
|
13
15
|
"files": ["lib", "LICENSE"],
|
|
14
16
|
"devDependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
+
"typescript": "^6.0.2",
|
|
18
|
+
"esbuild": "^0.27.4",
|
|
19
|
+
"vitest": "^4.1.2"
|
|
17
20
|
},
|
|
18
21
|
"peerDependencies": {
|
|
19
|
-
"typescript": "^5.0.0"
|
|
20
22
|
},
|
|
21
23
|
"scripts": {
|
|
22
24
|
"test": "vitest",
|