@cognite/underscore 1.0.1 → 1.48535.0
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/README.md +2 -0
- package/dist/arrays.d.ts +31 -31
- package/dist/arrays.js +53 -18
- package/dist/arrays.js.map +1 -0
- package/dist/assert.d.ts +6 -6
- package/dist/assert.js +12 -5
- package/dist/assert.js.map +1 -0
- package/dist/brand.d.ts +41 -38
- package/dist/brand.js +39 -0
- package/dist/brand.js.map +1 -0
- package/dist/chunk-and-process-in-parallel.d.ts +112 -106
- package/dist/chunk-and-process-in-parallel.js +138 -29
- package/dist/chunk-and-process-in-parallel.js.map +1 -0
- package/dist/chunk-array.d.ts +25 -25
- package/dist/chunk-array.js +34 -6
- package/dist/chunk-array.js.map +1 -0
- package/dist/class.d.ts +8 -8
- package/dist/class.js +11 -5
- package/dist/class.js.map +1 -0
- package/dist/exhaustive-guard.d.ts +15 -15
- package/dist/exhaustive-guard.js +19 -5
- package/dist/exhaustive-guard.js.map +1 -0
- package/dist/exponential-backoff-with-jitter.d.ts +13 -13
- package/dist/exponential-backoff-with-jitter.js +23 -7
- package/dist/exponential-backoff-with-jitter.js.map +1 -0
- package/dist/generate-unique-name.d.ts +17 -17
- package/dist/generate-unique-name.js +46 -10
- package/dist/generate-unique-name.js.map +1 -0
- package/dist/get-numbers-between.d.ts +15 -15
- package/dist/get-numbers-between.js +21 -5
- package/dist/get-numbers-between.js.map +1 -0
- package/dist/humanize-value.d.ts +3 -3
- package/dist/humanize-value.js +33 -15
- package/dist/humanize-value.js.map +1 -0
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -0
- package/dist/is-function.d.ts +5 -5
- package/dist/is-function.js +9 -5
- package/dist/is-function.js.map +1 -0
- package/dist/is-primitive.d.ts +7 -7
- package/dist/is-primitive.js +16 -6
- package/dist/is-primitive.js.map +1 -0
- package/dist/is-valid-url.d.ts +11 -14
- package/dist/is-valid-url.js +39 -16
- package/dist/is-valid-url.js.map +1 -0
- package/dist/iterators.d.ts +7 -7
- package/dist/iterators.js +16 -6
- package/dist/iterators.js.map +1 -0
- package/dist/math.d.ts +10 -10
- package/dist/math.js +16 -7
- package/dist/math.js.map +1 -0
- package/dist/random.d.ts +24 -24
- package/dist/random.js +52 -18
- package/dist/random.js.map +1 -0
- package/dist/react/use-debounce.d.ts +21 -21
- package/dist/react/use-debounce.js +39 -14
- package/dist/react/use-debounce.js.map +1 -0
- package/dist/react/use-derived-promise.d.ts +28 -29
- package/dist/react/use-derived-promise.js +70 -33
- package/dist/react/use-derived-promise.js.map +1 -0
- package/dist/react/use-stable-sync-external-store.d.ts +25 -25
- package/dist/react/use-stable-sync-external-store.js +52 -11
- package/dist/react/use-stable-sync-external-store.js.map +1 -0
- package/dist/react.d.ts +3 -3
- package/dist/react.js +5 -4
- package/dist/react.js.map +1 -0
- package/dist/repeat.d.ts +5 -5
- package/dist/repeat.js +11 -5
- package/dist/repeat.js.map +1 -0
- package/dist/retry-async.d.ts +87 -87
- package/dist/retry-async.js +88 -17
- package/dist/retry-async.js.map +1 -0
- package/dist/sleep.d.ts +5 -5
- package/dist/sleep.js +9 -5
- package/dist/sleep.js.map +1 -0
- package/dist/string.d.ts +35 -35
- package/dist/string.js +48 -9
- package/dist/string.js.map +1 -0
- package/dist/structMap/index.d.ts +3 -3
- package/dist/structMap/index.js +4 -0
- package/dist/structMap/index.js.map +1 -0
- package/dist/structMap/stableStringify.d.ts +21 -21
- package/dist/structMap/stableStringify.js +69 -22
- package/dist/structMap/stableStringify.js.map +1 -0
- package/dist/structMap/structMap.d.ts +111 -108
- package/dist/structMap/structMap.js +131 -28
- package/dist/structMap/structMap.js.map +1 -0
- package/dist/structMap/testUtils.d.ts +8 -8
- package/dist/structMap/testUtils.js +26 -0
- package/dist/structMap/testUtils.js.map +1 -0
- package/dist/structMap/types.d.ts +4 -4
- package/dist/structMap/types.js +5 -0
- package/dist/structMap/types.js.map +1 -0
- package/package.json +7 -4
|
@@ -1,24 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Stringifies any value using JSON.stringify under the hood, but treating certain cases differently.
|
|
3
|
+
* - Objects - Properties are sorted alphabetically to ensure stable output
|
|
4
|
+
* - Non-object values - plain JSON.stringify
|
|
5
|
+
* - Functions, symbols, undefined - removed during serialization
|
|
6
|
+
*
|
|
7
|
+
* @param value - A value to serialize into a string
|
|
8
|
+
* @returns Stringified version of the provided value
|
|
9
|
+
* @throws Throws when BigInt value is encountered at any point or a circular dependency is detected
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const fileId = { externalId: 'file-1', space: 's1' };
|
|
14
|
+
* const fileIdReversed = { space: 's1', externalId: 'file-1' };
|
|
15
|
+
*
|
|
16
|
+
* console.log(stableStringify(fileId) === stableStringify(fileIdReversed)); // true
|
|
17
|
+
*
|
|
18
|
+
* const user = { name: 'Bob', age: 35, pets: ['Felix', 'Alex'] };
|
|
19
|
+
*
|
|
20
|
+
* console.log(stableStringify(user)); // {"age":35,"name":"Bob","pets":["Felix","Alex"] }
|
|
21
|
+
* ```
|
|
22
|
+
*/ export function stableStringify(value) {
|
|
23
|
+
const seen = new WeakSet();
|
|
24
|
+
// Implementing stringify logic in an inner function in order to keep track of seen objects across recursive calls
|
|
25
|
+
function internalStringify(val) {
|
|
26
|
+
if (isInvalidJson(val)) return;
|
|
27
|
+
// Non-object values can be stringified in a simple way
|
|
28
|
+
if (val === null || typeof val !== 'object') {
|
|
29
|
+
return JSON.stringify(val);
|
|
30
|
+
}
|
|
31
|
+
// Check if the current array or object has been encountered before to avoid circular references
|
|
32
|
+
if (seen.has(val)) {
|
|
33
|
+
throw new TypeError('Converting circular structure to JSON');
|
|
34
|
+
}
|
|
35
|
+
seen.add(val);
|
|
36
|
+
// Use toJSON for objects that have it, like Date
|
|
37
|
+
if ('toJSON' in val && typeof val.toJSON === 'function') {
|
|
38
|
+
return internalStringify(val.toJSON());
|
|
39
|
+
}
|
|
40
|
+
// Stringify array items recursively and join into a string
|
|
41
|
+
if (Array.isArray(val)) {
|
|
42
|
+
const normalizedItems = val.map((item)=>{
|
|
43
|
+
var _internalStringify;
|
|
44
|
+
return (_internalStringify = internalStringify(item)) !== null && _internalStringify !== void 0 ? _internalStringify : 'null' // JSON.stringify turns undefined into 'null' in arrays
|
|
45
|
+
;
|
|
46
|
+
});
|
|
47
|
+
return `[${normalizedItems.join(',')}]`;
|
|
48
|
+
}
|
|
49
|
+
// Stringify objects recursively and join into a string
|
|
50
|
+
const obj = val;
|
|
51
|
+
const sortedKeys = Object.keys(obj).sort();
|
|
52
|
+
const keyValuePairs = [];
|
|
53
|
+
for (const key of sortedKeys){
|
|
54
|
+
const keyValue = obj[key];
|
|
55
|
+
// JSON.stringify ignores keys with invalid values
|
|
56
|
+
if (isInvalidJson(keyValue)) continue;
|
|
57
|
+
keyValuePairs.push(`${JSON.stringify(key)}:${internalStringify(keyValue)}`);
|
|
58
|
+
}
|
|
59
|
+
return `{${keyValuePairs.join(',')}}`;
|
|
60
|
+
}
|
|
61
|
+
return internalStringify(value);
|
|
18
62
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
63
|
+
function isInvalidJson(value) {
|
|
64
|
+
if (typeof value === 'bigint') {
|
|
65
|
+
// Throw for BigInt like native JSON.stringify
|
|
66
|
+
throw new TypeError('Do not know how to serialize a BigInt');
|
|
67
|
+
}
|
|
68
|
+
return typeof value === 'function' || typeof value === 'symbol' || typeof value === 'undefined';
|
|
22
69
|
}
|
|
23
|
-
|
|
24
|
-
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=stableStringify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structMap/stableStringify.ts"],"sourcesContent":["/**\n * Stringifies any value using JSON.stringify under the hood, but treating certain cases differently.\n * - Objects - Properties are sorted alphabetically to ensure stable output\n * - Non-object values - plain JSON.stringify\n * - Functions, symbols, undefined - removed during serialization\n *\n * @param value - A value to serialize into a string\n * @returns Stringified version of the provided value\n * @throws Throws when BigInt value is encountered at any point or a circular dependency is detected\n *\n * @example\n * ```ts\n * const fileId = { externalId: 'file-1', space: 's1' };\n * const fileIdReversed = { space: 's1', externalId: 'file-1' };\n *\n * console.log(stableStringify(fileId) === stableStringify(fileIdReversed)); // true\n *\n * const user = { name: 'Bob', age: 35, pets: ['Felix', 'Alex'] };\n *\n * console.log(stableStringify(user)); // {\"age\":35,\"name\":\"Bob\",\"pets\":[\"Felix\",\"Alex\"] }\n * ```\n */\nexport function stableStringify(value: unknown): string | undefined {\n const seen = new WeakSet();\n\n // Implementing stringify logic in an inner function in order to keep track of seen objects across recursive calls\n function internalStringify(val: unknown): string | undefined {\n if (isInvalidJson(val)) return;\n\n // Non-object values can be stringified in a simple way\n if (val === null || typeof val !== 'object') {\n return JSON.stringify(val);\n }\n\n // Check if the current array or object has been encountered before to avoid circular references\n if (seen.has(val)) {\n throw new TypeError('Converting circular structure to JSON');\n }\n seen.add(val);\n\n // Use toJSON for objects that have it, like Date\n if ('toJSON' in val && typeof val.toJSON === 'function') {\n return internalStringify(val.toJSON());\n }\n\n // Stringify array items recursively and join into a string\n if (Array.isArray(val)) {\n const normalizedItems = val.map(\n (item) => internalStringify(item) ?? 'null' // JSON.stringify turns undefined into 'null' in arrays\n );\n\n return `[${normalizedItems.join(',')}]`;\n }\n\n // Stringify objects recursively and join into a string\n const obj = val as Record<string, unknown>;\n const sortedKeys = Object.keys(obj).sort();\n const keyValuePairs: string[] = [];\n\n for (const key of sortedKeys) {\n const keyValue: unknown = obj[key];\n\n // JSON.stringify ignores keys with invalid values\n if (isInvalidJson(keyValue)) continue;\n\n keyValuePairs.push(\n `${JSON.stringify(key)}:${internalStringify(keyValue)}`\n );\n }\n\n return `{${keyValuePairs.join(',')}}`;\n }\n\n return internalStringify(value);\n}\n\nfunction isInvalidJson(value: unknown): boolean {\n if (typeof value === 'bigint') {\n // Throw for BigInt like native JSON.stringify\n throw new TypeError('Do not know how to serialize a BigInt');\n }\n\n return (\n typeof value === 'function' ||\n typeof value === 'symbol' ||\n typeof value === 'undefined'\n );\n}\n"],"names":["stableStringify","value","seen","WeakSet","internalStringify","val","isInvalidJson","JSON","stringify","has","TypeError","add","toJSON","Array","isArray","normalizedItems","map","item","join","obj","sortedKeys","Object","keys","sort","keyValuePairs","key","keyValue","push"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASA,gBAAgBC,KAAc;IAC5C,MAAMC,OAAO,IAAIC;IAEjB,kHAAkH;IAClH,SAASC,kBAAkBC,GAAY;QACrC,IAAIC,cAAcD,MAAM;QAExB,uDAAuD;QACvD,IAAIA,QAAQ,QAAQ,OAAOA,QAAQ,UAAU;YAC3C,OAAOE,KAAKC,SAAS,CAACH;QACxB;QAEA,gGAAgG;QAChG,IAAIH,KAAKO,GAAG,CAACJ,MAAM;YACjB,MAAM,IAAIK,UAAU;QACtB;QACAR,KAAKS,GAAG,CAACN;QAET,iDAAiD;QACjD,IAAI,YAAYA,OAAO,OAAOA,IAAIO,MAAM,KAAK,YAAY;YACvD,OAAOR,kBAAkBC,IAAIO,MAAM;QACrC;QAEA,2DAA2D;QAC3D,IAAIC,MAAMC,OAAO,CAACT,MAAM;YACtB,MAAMU,kBAAkBV,IAAIW,GAAG,CAC7B,CAACC;oBAASb;wBAAAA,qBAAAA,kBAAkBa,mBAAlBb,gCAAAA,qBAA2B,OAAO,uDAAuD;;;YAGrG,OAAO,CAAC,CAAC,EAAEW,gBAAgBG,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC;QAEA,uDAAuD;QACvD,MAAMC,MAAMd;QACZ,MAAMe,aAAaC,OAAOC,IAAI,CAACH,KAAKI,IAAI;QACxC,MAAMC,gBAA0B,EAAE;QAElC,KAAK,MAAMC,OAAOL,WAAY;YAC5B,MAAMM,WAAoBP,GAAG,CAACM,IAAI;YAElC,kDAAkD;YAClD,IAAInB,cAAcoB,WAAW;YAE7BF,cAAcG,IAAI,CAChB,GAAGpB,KAAKC,SAAS,CAACiB,KAAK,CAAC,EAAErB,kBAAkBsB,WAAW;QAE3D;QAEA,OAAO,CAAC,CAAC,EAAEF,cAAcN,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC;IAEA,OAAOd,kBAAkBH;AAC3B;AAEA,SAASK,cAAcL,KAAc;IACnC,IAAI,OAAOA,UAAU,UAAU;QAC7B,8CAA8C;QAC9C,MAAM,IAAIS,UAAU;IACtB;IAEA,OACE,OAAOT,UAAU,cACjB,OAAOA,UAAU,YACjB,OAAOA,UAAU;AAErB"}
|
|
@@ -1,110 +1,113 @@
|
|
|
1
|
-
import { KeySerializer } from
|
|
1
|
+
import type { KeySerializer } from "./types";
|
|
2
2
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export declare class StructMap<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
3
|
+
* Custom data structure that builds on top of the native `Map` class.
|
|
4
|
+
* Unlike `Map`, it enables proper usage of objects as keys by comparing them structurally, instead of by reference.
|
|
5
|
+
* By default, objects are serialized using `stableStringify` function to ensure consistent key representation.
|
|
6
|
+
*
|
|
7
|
+
* @template K - Type of keys in the StructMap
|
|
8
|
+
* @template V - Type of values in the StructMap
|
|
9
|
+
* @param entries - Initial key-value pairs to populate the StructMap
|
|
10
|
+
* @param serializer - Custom serializer to convert keys to strings and back
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Basic case with a Data Modeling-like scenario
|
|
15
|
+
*
|
|
16
|
+
* // Simplified list of DM-like objects
|
|
17
|
+
* const dmFiles = [
|
|
18
|
+
* { externalId: 'f1', space: 's1', properties: { name: 'file-1' } },
|
|
19
|
+
* { externalId: 'f2', space: 's1', properties: { name: 'file-2' } },
|
|
20
|
+
* ];
|
|
21
|
+
*
|
|
22
|
+
* // To create a map, we first need entries - a list of [key, value] pairs
|
|
23
|
+
* const fileEntries = dmFiles.map((file) => [
|
|
24
|
+
* { externalId: file.externalId, space: file.space }, // This object will be a key for each entry
|
|
25
|
+
* file, // Each file object will be a value in the map
|
|
26
|
+
* ]);
|
|
27
|
+
*
|
|
28
|
+
* const filesMap = new StructMap(fileEntries);
|
|
29
|
+
*
|
|
30
|
+
* // Set new values
|
|
31
|
+
* const newFile = { externalId: 'f3', space: 's2', properties: { name: 'file-3' } };
|
|
32
|
+
*
|
|
33
|
+
* filesMap.set({ externalId: 'f3', space: 's2' }, newFile);
|
|
34
|
+
*
|
|
35
|
+
* // Get an existing value
|
|
36
|
+
* const file = filesMap.get({ space: 's2', externalId: 'f3' }); // By default, order of object properties is ignored
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Using a custom key serializer
|
|
42
|
+
*
|
|
43
|
+
* // Custom serializer that lowercases keys and values
|
|
44
|
+
* const lowerCaseSerializer: KeySerializer<PreferencesKey> = {
|
|
45
|
+
* serialize: (key) =>
|
|
46
|
+
* JSON.stringify({
|
|
47
|
+
* user: key.user.toLowerCase(),
|
|
48
|
+
* setting: key.setting.toLowerCase(),
|
|
49
|
+
* }),
|
|
50
|
+
* deserialize: (keyString) => JSON.parse(keyString),
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* // Create a StructMap with our custom serializer
|
|
54
|
+
* const preferences = new StructMap<PreferencesKey, string>([], lowerCaseSerializer);
|
|
55
|
+
*
|
|
56
|
+
* // Store preferences
|
|
57
|
+
* preferences.set({ user: 'Alice', setting: 'Theme' }, 'dark');
|
|
58
|
+
* preferences.set({ user: 'Bob', setting: 'Theme' }, 'light');
|
|
59
|
+
*
|
|
60
|
+
* // Retrieve values with keys of any casing
|
|
61
|
+
* console.log(preferences.get({ user: 'alice', setting: 'theme' })); // dark
|
|
62
|
+
* console.log(preferences.get({ user: 'BOB', setting: 'THEME' })); // light
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare class StructMap<
|
|
66
|
+
K extends object,
|
|
67
|
+
V
|
|
68
|
+
> {
|
|
69
|
+
private map;
|
|
70
|
+
private serializer;
|
|
71
|
+
constructor(entries?: Iterable<[K, V]>, serializer?: KeySerializer<K>);
|
|
72
|
+
/**
|
|
73
|
+
* Returns the number of elements in the map.
|
|
74
|
+
*/
|
|
75
|
+
get size(): number;
|
|
76
|
+
/**
|
|
77
|
+
* Removes all elements from the map.
|
|
78
|
+
*/
|
|
79
|
+
clear: () => void;
|
|
80
|
+
/**
|
|
81
|
+
* Removes an element associated with the given key and returns true if element existed, false otherwise.
|
|
82
|
+
*/
|
|
83
|
+
delete: (key: K) => boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Returns an iterable of key, value pairs for every entry in the map..
|
|
86
|
+
*/
|
|
87
|
+
entries(): IterableIterator<[K, V]>;
|
|
88
|
+
/**
|
|
89
|
+
* Executes a provided function once per each key/value pair in the Map, in insertion order.
|
|
90
|
+
*/
|
|
91
|
+
forEach: (callbackFn: (value: V, key: K, map: StructMap<K, V>) => void) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Returns an element associated with the given key, or undefined if the key doesn't exist.
|
|
94
|
+
*/
|
|
95
|
+
get: (key: K) => V | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Checks if an element with the given key exists in the map.
|
|
98
|
+
*/
|
|
99
|
+
has: (key: K) => boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Returns an iterable of keys in the map.
|
|
102
|
+
*/
|
|
103
|
+
keys(): IterableIterator<K>;
|
|
104
|
+
/**
|
|
105
|
+
* Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
|
|
106
|
+
* @returns this
|
|
107
|
+
*/
|
|
108
|
+
set: (key: K, value: V) => this;
|
|
109
|
+
/**
|
|
110
|
+
* Returns an iterable of values in the map.
|
|
111
|
+
*/
|
|
112
|
+
values: () => IterableIterator<V>;
|
|
110
113
|
}
|
|
@@ -1,29 +1,132 @@
|
|
|
1
|
-
import { stableStringify
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { stableStringify } from "./stableStringify.js";
|
|
2
|
+
/**
|
|
3
|
+
* Custom data structure that builds on top of the native `Map` class.
|
|
4
|
+
* Unlike `Map`, it enables proper usage of objects as keys by comparing them structurally, instead of by reference.
|
|
5
|
+
* By default, objects are serialized using `stableStringify` function to ensure consistent key representation.
|
|
6
|
+
*
|
|
7
|
+
* @template K - Type of keys in the StructMap
|
|
8
|
+
* @template V - Type of values in the StructMap
|
|
9
|
+
* @param entries - Initial key-value pairs to populate the StructMap
|
|
10
|
+
* @param serializer - Custom serializer to convert keys to strings and back
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Basic case with a Data Modeling-like scenario
|
|
15
|
+
*
|
|
16
|
+
* // Simplified list of DM-like objects
|
|
17
|
+
* const dmFiles = [
|
|
18
|
+
* { externalId: 'f1', space: 's1', properties: { name: 'file-1' } },
|
|
19
|
+
* { externalId: 'f2', space: 's1', properties: { name: 'file-2' } },
|
|
20
|
+
* ];
|
|
21
|
+
*
|
|
22
|
+
* // To create a map, we first need entries - a list of [key, value] pairs
|
|
23
|
+
* const fileEntries = dmFiles.map((file) => [
|
|
24
|
+
* { externalId: file.externalId, space: file.space }, // This object will be a key for each entry
|
|
25
|
+
* file, // Each file object will be a value in the map
|
|
26
|
+
* ]);
|
|
27
|
+
*
|
|
28
|
+
* const filesMap = new StructMap(fileEntries);
|
|
29
|
+
*
|
|
30
|
+
* // Set new values
|
|
31
|
+
* const newFile = { externalId: 'f3', space: 's2', properties: { name: 'file-3' } };
|
|
32
|
+
*
|
|
33
|
+
* filesMap.set({ externalId: 'f3', space: 's2' }, newFile);
|
|
34
|
+
*
|
|
35
|
+
* // Get an existing value
|
|
36
|
+
* const file = filesMap.get({ space: 's2', externalId: 'f3' }); // By default, order of object properties is ignored
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Using a custom key serializer
|
|
42
|
+
*
|
|
43
|
+
* // Custom serializer that lowercases keys and values
|
|
44
|
+
* const lowerCaseSerializer: KeySerializer<PreferencesKey> = {
|
|
45
|
+
* serialize: (key) =>
|
|
46
|
+
* JSON.stringify({
|
|
47
|
+
* user: key.user.toLowerCase(),
|
|
48
|
+
* setting: key.setting.toLowerCase(),
|
|
49
|
+
* }),
|
|
50
|
+
* deserialize: (keyString) => JSON.parse(keyString),
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* // Create a StructMap with our custom serializer
|
|
54
|
+
* const preferences = new StructMap<PreferencesKey, string>([], lowerCaseSerializer);
|
|
55
|
+
*
|
|
56
|
+
* // Store preferences
|
|
57
|
+
* preferences.set({ user: 'Alice', setting: 'Theme' }, 'dark');
|
|
58
|
+
* preferences.set({ user: 'Bob', setting: 'Theme' }, 'light');
|
|
59
|
+
*
|
|
60
|
+
* // Retrieve values with keys of any casing
|
|
61
|
+
* console.log(preferences.get({ user: 'alice', setting: 'theme' })); // dark
|
|
62
|
+
* console.log(preferences.get({ user: 'BOB', setting: 'THEME' })); // light
|
|
63
|
+
* ```
|
|
64
|
+
*/ export class StructMap {
|
|
65
|
+
/**
|
|
66
|
+
* Returns the number of elements in the map.
|
|
67
|
+
*/ get size() {
|
|
68
|
+
return this.map.size;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns an iterable of key, value pairs for every entry in the map..
|
|
72
|
+
*/ *entries() {
|
|
73
|
+
for (const [key, value] of this.map.entries()){
|
|
74
|
+
yield [
|
|
75
|
+
this.serializer.deserialize(key),
|
|
76
|
+
value
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Returns an iterable of keys in the map.
|
|
82
|
+
*/ *keys() {
|
|
83
|
+
for (const key of this.map.keys()){
|
|
84
|
+
yield this.serializer.deserialize(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
constructor(entries = [], serializer = getDefaultSerializer()){
|
|
88
|
+
this.map = new Map();
|
|
89
|
+
/**
|
|
90
|
+
* Removes all elements from the map.
|
|
91
|
+
*/ this.clear = ()=>this.map.clear();
|
|
92
|
+
/**
|
|
93
|
+
* Removes an element associated with the given key and returns true if element existed, false otherwise.
|
|
94
|
+
*/ this.delete = (key)=>this.map.delete(this.serializer.serialize(key));
|
|
95
|
+
/**
|
|
96
|
+
* Executes a provided function once per each key/value pair in the Map, in insertion order.
|
|
97
|
+
*/ this.forEach = (callbackFn)=>{
|
|
98
|
+
this.map.forEach((value, keyString)=>{
|
|
99
|
+
const key = this.serializer.deserialize(keyString);
|
|
100
|
+
callbackFn(value, key, this);
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Returns an element associated with the given key, or undefined if the key doesn't exist.
|
|
105
|
+
*/ this.get = (key)=>this.map.get(this.serializer.serialize(key));
|
|
106
|
+
/**
|
|
107
|
+
* Checks if an element with the given key exists in the map.
|
|
108
|
+
*/ this.has = (key)=>this.map.has(this.serializer.serialize(key));
|
|
109
|
+
/**
|
|
110
|
+
* Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
|
|
111
|
+
* @returns this
|
|
112
|
+
*/ this.set = (key, value)=>{
|
|
113
|
+
this.map.set(this.serializer.serialize(key), value);
|
|
114
|
+
return this;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Returns an iterable of values in the map.
|
|
118
|
+
*/ this.values = ()=>this.map.values();
|
|
119
|
+
this.serializer = serializer;
|
|
120
|
+
for (const [key, value] of entries){
|
|
121
|
+
this.set(key, value);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
27
124
|
}
|
|
28
|
-
|
|
29
|
-
|
|
125
|
+
function getDefaultSerializer() {
|
|
126
|
+
return {
|
|
127
|
+
serialize: (key)=>String(stableStringify(key)),
|
|
128
|
+
deserialize: JSON.parse
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=structMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structMap/structMap.ts"],"sourcesContent":["import { stableStringify } from './stableStringify';\nimport type { KeySerializer } from './types';\n\n/**\n * Custom data structure that builds on top of the native `Map` class.\n * Unlike `Map`, it enables proper usage of objects as keys by comparing them structurally, instead of by reference.\n * By default, objects are serialized using `stableStringify` function to ensure consistent key representation.\n *\n * @template K - Type of keys in the StructMap\n * @template V - Type of values in the StructMap\n * @param entries - Initial key-value pairs to populate the StructMap\n * @param serializer - Custom serializer to convert keys to strings and back\n *\n * @example\n * ```ts\n * // Basic case with a Data Modeling-like scenario\n *\n * // Simplified list of DM-like objects\n * const dmFiles = [\n * { externalId: 'f1', space: 's1', properties: { name: 'file-1' } },\n * { externalId: 'f2', space: 's1', properties: { name: 'file-2' } },\n * ];\n *\n * // To create a map, we first need entries - a list of [key, value] pairs\n * const fileEntries = dmFiles.map((file) => [\n * { externalId: file.externalId, space: file.space }, // This object will be a key for each entry\n * file, // Each file object will be a value in the map\n * ]);\n *\n * const filesMap = new StructMap(fileEntries);\n *\n * // Set new values\n * const newFile = { externalId: 'f3', space: 's2', properties: { name: 'file-3' } };\n *\n * filesMap.set({ externalId: 'f3', space: 's2' }, newFile);\n *\n * // Get an existing value\n * const file = filesMap.get({ space: 's2', externalId: 'f3' }); // By default, order of object properties is ignored\n * ```\n *\n * @example\n * ```ts\n * // Using a custom key serializer\n *\n * // Custom serializer that lowercases keys and values\n * const lowerCaseSerializer: KeySerializer<PreferencesKey> = {\n * serialize: (key) =>\n * JSON.stringify({\n * user: key.user.toLowerCase(),\n * setting: key.setting.toLowerCase(),\n * }),\n * deserialize: (keyString) => JSON.parse(keyString),\n * };\n *\n * // Create a StructMap with our custom serializer\n * const preferences = new StructMap<PreferencesKey, string>([], lowerCaseSerializer);\n *\n * // Store preferences\n * preferences.set({ user: 'Alice', setting: 'Theme' }, 'dark');\n * preferences.set({ user: 'Bob', setting: 'Theme' }, 'light');\n *\n * // Retrieve values with keys of any casing\n * console.log(preferences.get({ user: 'alice', setting: 'theme' })); // dark\n * console.log(preferences.get({ user: 'BOB', setting: 'THEME' })); // light\n * ```\n */\nexport class StructMap<K extends object, V> {\n private map = new Map<string, V>();\n private serializer: KeySerializer<K>;\n\n public constructor(\n entries: Iterable<[K, V]> = [],\n serializer: KeySerializer<K> = getDefaultSerializer<K>()\n ) {\n this.serializer = serializer;\n for (const [key, value] of entries) {\n this.set(key, value);\n }\n }\n\n /**\n * Returns the number of elements in the map.\n */\n public get size(): number {\n return this.map.size;\n }\n\n /**\n * Removes all elements from the map.\n */\n public clear = (): void => this.map.clear();\n\n /**\n * Removes an element associated with the given key and returns true if element existed, false otherwise.\n */\n public delete = (key: K): boolean =>\n this.map.delete(this.serializer.serialize(key));\n\n /**\n * Returns an iterable of key, value pairs for every entry in the map..\n */\n public *entries(): IterableIterator<[K, V]> {\n for (const [key, value] of this.map.entries()) {\n yield [this.serializer.deserialize(key), value];\n }\n }\n\n /**\n * Executes a provided function once per each key/value pair in the Map, in insertion order.\n */\n public forEach = (\n callbackFn: (value: V, key: K, map: StructMap<K, V>) => void\n ): void => {\n this.map.forEach((value, keyString) => {\n const key = this.serializer.deserialize(keyString);\n callbackFn(value, key, this);\n });\n };\n\n /**\n * Returns an element associated with the given key, or undefined if the key doesn't exist.\n */\n public get = (key: K): V | undefined =>\n this.map.get(this.serializer.serialize(key));\n\n /**\n * Checks if an element with the given key exists in the map.\n */\n public has = (key: K): boolean =>\n this.map.has(this.serializer.serialize(key));\n\n /**\n * Returns an iterable of keys in the map.\n */\n public *keys(): IterableIterator<K> {\n for (const key of this.map.keys()) {\n yield this.serializer.deserialize(key);\n }\n }\n\n /**\n * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.\n * @returns this\n */\n public set = (key: K, value: V): this => {\n this.map.set(this.serializer.serialize(key), value);\n return this;\n };\n\n /**\n * Returns an iterable of values in the map.\n */\n public values = (): IterableIterator<V> => this.map.values();\n}\n\nfunction getDefaultSerializer<K>(): KeySerializer<K> {\n return {\n serialize: (key: K) => String(stableStringify(key)),\n deserialize: JSON.parse,\n };\n}\n"],"names":["stableStringify","StructMap","size","map","entries","key","value","serializer","deserialize","keys","getDefaultSerializer","Map","clear","delete","serialize","forEach","callbackFn","keyString","get","has","set","values","String","JSON","parse"],"mappings":"AAAA,SAASA,eAAe,QAAQ,uBAAoB;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8DC,GACD,OAAO,MAAMC;IAcX;;GAEC,GACD,IAAWC,OAAe;QACxB,OAAO,IAAI,CAACC,GAAG,CAACD,IAAI;IACtB;IAaA;;GAEC,GACD,CAAQE,UAAoC;QAC1C,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAI,IAAI,CAACH,GAAG,CAACC,OAAO,GAAI;YAC7C,MAAM;gBAAC,IAAI,CAACG,UAAU,CAACC,WAAW,CAACH;gBAAMC;aAAM;QACjD;IACF;IA0BA;;GAEC,GACD,CAAQG,OAA4B;QAClC,KAAK,MAAMJ,OAAO,IAAI,CAACF,GAAG,CAACM,IAAI,GAAI;YACjC,MAAM,IAAI,CAACF,UAAU,CAACC,WAAW,CAACH;QACpC;IACF;IApEA,YACED,UAA4B,EAAE,EAC9BG,aAA+BG,sBAAyB,CACxD;aANMP,MAAM,IAAIQ;QAoBlB;;GAEC,QACMC,QAAQ,IAAY,IAAI,CAACT,GAAG,CAACS,KAAK;QAEzC;;GAEC,QACMC,SAAS,CAACR,MACf,IAAI,CAACF,GAAG,CAACU,MAAM,CAAC,IAAI,CAACN,UAAU,CAACO,SAAS,CAACT;QAW5C;;GAEC,QACMU,UAAU,CACfC;YAEA,IAAI,CAACb,GAAG,CAACY,OAAO,CAAC,CAACT,OAAOW;gBACvB,MAAMZ,MAAM,IAAI,CAACE,UAAU,CAACC,WAAW,CAACS;gBACxCD,WAAWV,OAAOD,KAAK,IAAI;YAC7B;QACF;QAEA;;GAEC,QACMa,MAAM,CAACb,MACZ,IAAI,CAACF,GAAG,CAACe,GAAG,CAAC,IAAI,CAACX,UAAU,CAACO,SAAS,CAACT;QAEzC;;GAEC,QACMc,MAAM,CAACd,MACZ,IAAI,CAACF,GAAG,CAACgB,GAAG,CAAC,IAAI,CAACZ,UAAU,CAACO,SAAS,CAACT;QAWzC;;;GAGC,QACMe,MAAM,CAACf,KAAQC;YACpB,IAAI,CAACH,GAAG,CAACiB,GAAG,CAAC,IAAI,CAACb,UAAU,CAACO,SAAS,CAACT,MAAMC;YAC7C,OAAO,IAAI;QACb;QAEA;;GAEC,QACMe,SAAS,IAA2B,IAAI,CAAClB,GAAG,CAACkB,MAAM;QA9ExD,IAAI,CAACd,UAAU,GAAGA;QAClB,KAAK,MAAM,CAACF,KAAKC,MAAM,IAAIF,QAAS;YAClC,IAAI,CAACgB,GAAG,CAACf,KAAKC;QAChB;IACF;AA2EF;AAEA,SAASI;IACP,OAAO;QACLI,WAAW,CAACT,MAAWiB,OAAOtB,gBAAgBK;QAC9CG,aAAae,KAAKC,KAAK;IACzB;AACF"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export type DmsId = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
externalId: string;
|
|
3
|
+
space: string;
|
|
4
4
|
};
|
|
5
5
|
export type MockCogniteFile = DmsId & {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
createdTime: number;
|
|
7
|
+
lastUpdatedTime: number;
|
|
8
|
+
name: string;
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare function createMockCogniteFile({ externalId, space, name, createdTime, lastUpdatedTime
|
|
11
|
+
* Streamlines creation of a DM CogniteFile-like mock instance by hiding unnecessary details and providing smart defaults.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createMockCogniteFile({ externalId, space, name, createdTime, lastUpdatedTime }?: Partial<MockCogniteFile>): MockCogniteFile;
|
|
14
14
|
/** Helper to convert a DM-like object to a DmsId. */
|
|
15
15
|
export declare function toDmsId<T extends DmsId>(item: T): DmsId;
|
|
16
16
|
/** Helper to convert a list of DM-like items to a list of initial entries for StructMap. */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { randomString } from "../random.js";
|
|
2
|
+
/**
|
|
3
|
+
* Streamlines creation of a DM CogniteFile-like mock instance by hiding unnecessary details and providing smart defaults.
|
|
4
|
+
*/ export function createMockCogniteFile({ externalId = randomString(32), space = randomString(32), name = randomString(32), createdTime = Date.now(), lastUpdatedTime = Date.now() } = {}) {
|
|
5
|
+
return {
|
|
6
|
+
externalId,
|
|
7
|
+
space,
|
|
8
|
+
name,
|
|
9
|
+
createdTime,
|
|
10
|
+
lastUpdatedTime
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Helper to convert a DM-like object to a DmsId. */ export function toDmsId(item) {
|
|
14
|
+
return {
|
|
15
|
+
externalId: item.externalId,
|
|
16
|
+
space: item.space
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Helper to convert a list of DM-like items to a list of initial entries for StructMap. */ export function toDmsIdEntries(items) {
|
|
20
|
+
return items.map((it)=>[
|
|
21
|
+
toDmsId(it),
|
|
22
|
+
it
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=testUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structMap/testUtils.ts"],"sourcesContent":["import { randomString } from '../random';\n\nexport type DmsId = {\n externalId: string;\n space: string;\n};\n\nexport type MockCogniteFile = DmsId & {\n createdTime: number;\n lastUpdatedTime: number;\n name: string;\n};\n\n/**\n * Streamlines creation of a DM CogniteFile-like mock instance by hiding unnecessary details and providing smart defaults.\n */\nexport function createMockCogniteFile({\n externalId = randomString(32),\n space = randomString(32),\n name = randomString(32),\n createdTime = Date.now(),\n lastUpdatedTime = Date.now(),\n}: Partial<MockCogniteFile> = {}): MockCogniteFile {\n return {\n externalId,\n space,\n name,\n createdTime,\n lastUpdatedTime,\n };\n}\n\n/** Helper to convert a DM-like object to a DmsId. */\nexport function toDmsId<T extends DmsId>(item: T): DmsId {\n return {\n externalId: item.externalId,\n space: item.space,\n };\n}\n\n/** Helper to convert a list of DM-like items to a list of initial entries for StructMap. */\nexport function toDmsIdEntries<T extends DmsId>(items: T[]): [DmsId, T][] {\n return items.map((it) => [toDmsId(it), it]);\n}\n"],"names":["randomString","createMockCogniteFile","externalId","space","name","createdTime","Date","now","lastUpdatedTime","toDmsId","item","toDmsIdEntries","items","map","it"],"mappings":"AAAA,SAASA,YAAY,QAAQ,eAAY;AAazC;;CAEC,GACD,OAAO,SAASC,sBAAsB,EACpCC,aAAaF,aAAa,GAAG,EAC7BG,QAAQH,aAAa,GAAG,EACxBI,OAAOJ,aAAa,GAAG,EACvBK,cAAcC,KAAKC,GAAG,EAAE,EACxBC,kBAAkBF,KAAKC,GAAG,EAAE,EACH,GAAG,CAAC,CAAC;IAC9B,OAAO;QACLL;QACAC;QACAC;QACAC;QACAG;IACF;AACF;AAEA,mDAAmD,GACnD,OAAO,SAASC,QAAyBC,IAAO;IAC9C,OAAO;QACLR,YAAYQ,KAAKR,UAAU;QAC3BC,OAAOO,KAAKP,KAAK;IACnB;AACF;AAEA,0FAA0F,GAC1F,OAAO,SAASQ,eAAgCC,KAAU;IACxD,OAAOA,MAAMC,GAAG,CAAC,CAACC,KAAO;YAACL,QAAQK;YAAKA;SAAG;AAC5C"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
* Holds functions to serialize a key into a string and deserialize the string back into its original form.
|
|
3
|
+
*/
|
|
4
4
|
export type KeySerializer<K> = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
serialize(key: K): string;
|
|
6
|
+
deserialize(keyString: string): K;
|
|
7
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/structMap/types.ts"],"sourcesContent":["/**\n * Holds functions to serialize a key into a string and deserialize the string back into its original form.\n */\nexport type KeySerializer<K> = {\n serialize(key: K): string;\n deserialize(keyString: string): K;\n};\n"],"names":[],"mappings":"AAAA;;CAEC,GACD,WAGE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cognite/underscore",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.48535.0",
|
|
4
4
|
"description": "A collection of useful plain TypeScript utility functions.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@nx/devkit": "22.7.8",
|
|
26
|
-
"@nx/eslint-plugin": "22.7.8",
|
|
27
25
|
"@testing-library/react": "16.0.1",
|
|
28
26
|
"@types/lodash-es": "^4.17.12",
|
|
29
27
|
"@types/react": "18.3.14",
|
|
@@ -34,12 +32,17 @@
|
|
|
34
32
|
"typedoc": "^0.27.6",
|
|
35
33
|
"typedoc-plugin-markdown": "^4.4.1",
|
|
36
34
|
"typescript": "6.0.3",
|
|
37
|
-
"vite": "8.2.
|
|
35
|
+
"vite": "8.2.4",
|
|
38
36
|
"vite-plugin-dts": "^4.5.4",
|
|
39
37
|
"vitest": "^4.1.10"
|
|
40
38
|
},
|
|
41
39
|
"peerDependencies": {
|
|
42
40
|
"lodash-es": "^4.18.1",
|
|
43
41
|
"react": "^18.3.1"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/cognitedata/infrastructure.git",
|
|
46
|
+
"directory": "lib/ts/shared/underscore"
|
|
44
47
|
}
|
|
45
48
|
}
|