@haneullabs/utils 0.1.0 → 0.3.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/b58.d.mts +6 -0
  3. package/dist/b58.d.mts.map +1 -0
  4. package/dist/{esm/b58.js → b58.mjs} +6 -5
  5. package/dist/b58.mjs.map +1 -0
  6. package/dist/b64.d.mts +6 -0
  7. package/dist/b64.d.mts.map +1 -0
  8. package/dist/b64.mjs +18 -0
  9. package/dist/b64.mjs.map +1 -0
  10. package/dist/chunk.d.mts +5 -0
  11. package/dist/chunk.d.mts.map +1 -0
  12. package/dist/chunk.mjs +10 -0
  13. package/dist/chunk.mjs.map +1 -0
  14. package/dist/dataloader.d.mts +139 -0
  15. package/dist/dataloader.d.mts.map +1 -0
  16. package/dist/dataloader.mjs +236 -0
  17. package/dist/dataloader.mjs.map +1 -0
  18. package/dist/hex.d.mts +6 -0
  19. package/dist/hex.d.mts.map +1 -0
  20. package/dist/hex.mjs +15 -0
  21. package/dist/hex.mjs.map +1 -0
  22. package/dist/index.d.mts +9 -0
  23. package/dist/index.mjs +9 -0
  24. package/dist/mitt.d.mts +32 -0
  25. package/dist/mitt.d.mts.map +1 -0
  26. package/dist/mitt.mjs +36 -0
  27. package/dist/mitt.mjs.map +1 -0
  28. package/dist/types.d.mts +6 -0
  29. package/dist/types.d.mts.map +1 -0
  30. package/dist/with-resolver.d.mts +10 -0
  31. package/dist/with-resolver.d.mts.map +1 -0
  32. package/dist/with-resolver.mjs +17 -0
  33. package/dist/with-resolver.mjs.map +1 -0
  34. package/package.json +18 -20
  35. package/src/dataloader.ts +8 -1
  36. package/src/index.ts +7 -0
  37. package/src/mitt.ts +118 -0
  38. package/src/types.ts +0 -1
  39. package/dist/cjs/b58.d.ts +0 -2
  40. package/dist/cjs/b58.js +0 -28
  41. package/dist/cjs/b58.js.map +0 -7
  42. package/dist/cjs/b64.d.ts +0 -2
  43. package/dist/cjs/b64.js +0 -40
  44. package/dist/cjs/b64.js.map +0 -7
  45. package/dist/cjs/chunk.d.ts +0 -1
  46. package/dist/cjs/chunk.js +0 -29
  47. package/dist/cjs/chunk.js.map +0 -7
  48. package/dist/cjs/dataloader.d.ts +0 -129
  49. package/dist/cjs/dataloader.js +0 -318
  50. package/dist/cjs/dataloader.js.map +0 -7
  51. package/dist/cjs/hex.d.ts +0 -2
  52. package/dist/cjs/hex.js +0 -37
  53. package/dist/cjs/hex.js.map +0 -7
  54. package/dist/cjs/index.d.ts +0 -7
  55. package/dist/cjs/index.js +0 -38
  56. package/dist/cjs/index.js.map +0 -7
  57. package/dist/cjs/package.json +0 -5
  58. package/dist/cjs/types.d.ts +0 -4
  59. package/dist/cjs/types.js +0 -17
  60. package/dist/cjs/types.js.map +0 -7
  61. package/dist/cjs/with-resolver.d.ts +0 -6
  62. package/dist/cjs/with-resolver.js +0 -37
  63. package/dist/cjs/with-resolver.js.map +0 -7
  64. package/dist/esm/b58.d.ts +0 -2
  65. package/dist/esm/b58.js.map +0 -7
  66. package/dist/esm/b64.d.ts +0 -2
  67. package/dist/esm/b64.js +0 -20
  68. package/dist/esm/b64.js.map +0 -7
  69. package/dist/esm/chunk.d.ts +0 -1
  70. package/dist/esm/chunk.js +0 -9
  71. package/dist/esm/chunk.js.map +0 -7
  72. package/dist/esm/dataloader.d.ts +0 -129
  73. package/dist/esm/dataloader.js +0 -298
  74. package/dist/esm/dataloader.js.map +0 -7
  75. package/dist/esm/hex.d.ts +0 -2
  76. package/dist/esm/hex.js +0 -17
  77. package/dist/esm/hex.js.map +0 -7
  78. package/dist/esm/index.d.ts +0 -7
  79. package/dist/esm/index.js +0 -18
  80. package/dist/esm/index.js.map +0 -7
  81. package/dist/esm/package.json +0 -5
  82. package/dist/esm/types.d.ts +0 -4
  83. package/dist/esm/types.js +0 -1
  84. package/dist/esm/types.js.map +0 -7
  85. package/dist/esm/with-resolver.d.ts +0 -6
  86. package/dist/esm/with-resolver.js +0 -17
  87. package/dist/esm/with-resolver.js.map +0 -7
  88. package/dist/tsconfig.esm.tsbuildinfo +0 -1
  89. package/dist/tsconfig.tsbuildinfo +0 -1
package/CHANGELOG.md CHANGED
@@ -1,4 +1,16 @@
1
- # @haneullabs/utils
1
+ # @mysten/utils
2
+
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 99d1e00: Add default export condition
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 339d1e0: Add mitt
2
14
 
3
15
  ## 0.2.0
4
16
 
package/dist/b58.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/b58.d.ts
2
+ declare const toBase58: (buffer: Uint8Array) => string;
3
+ declare const fromBase58: (str: string) => Uint8Array<ArrayBuffer>;
4
+ //#endregion
5
+ export { fromBase58, toBase58 };
6
+ //# sourceMappingURL=b58.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b58.d.mts","names":[],"sources":["../src/b58.ts"],"mappings":";cAKa,QAAA,GAAY,MAAA,EAAQ,UAAA;AAAA,cACpB,UAAA,GAAc,GAAA,aAAsC,UAAA,CAAW,WAAA"}
@@ -1,8 +1,9 @@
1
1
  import { base58 } from "@scure/base";
2
+
3
+ //#region src/b58.ts
2
4
  const toBase58 = (buffer) => base58.encode(buffer);
3
5
  const fromBase58 = (str) => base58.decode(str);
4
- export {
5
- fromBase58,
6
- toBase58
7
- };
8
- //# sourceMappingURL=b58.js.map
6
+
7
+ //#endregion
8
+ export { fromBase58, toBase58 };
9
+ //# sourceMappingURL=b58.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b58.mjs","names":[],"sources":["../src/b58.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { base58 } from '@scure/base';\n\nexport const toBase58 = (buffer: Uint8Array) => base58.encode(buffer);\nexport const fromBase58 = (str: string) => base58.decode(str) as Uint8Array<ArrayBuffer>;\n"],"mappings":";;;AAKA,MAAa,YAAY,WAAuB,OAAO,OAAO,OAAO;AACrE,MAAa,cAAc,QAAgB,OAAO,OAAO,IAAI"}
package/dist/b64.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/b64.d.ts
2
+ declare function fromBase64(base64String: string): Uint8Array<ArrayBuffer>;
3
+ declare function toBase64(bytes: Uint8Array): string;
4
+ //#endregion
5
+ export { fromBase64, toBase64 };
6
+ //# sourceMappingURL=b64.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b64.d.mts","names":[],"sources":["../src/b64.ts"],"mappings":";iBAGgB,UAAA,CAAW,YAAA,WAAuB,UAAA,CAAW,WAAA;AAAA,iBAK7C,QAAA,CAAS,KAAA,EAAO,UAAA"}
package/dist/b64.mjs ADDED
@@ -0,0 +1,18 @@
1
+ //#region src/b64.ts
2
+ function fromBase64(base64String) {
3
+ return Uint8Array.from(atob(base64String), (char) => char.charCodeAt(0));
4
+ }
5
+ const CHUNK_SIZE = 8192;
6
+ function toBase64(bytes) {
7
+ if (bytes.length < CHUNK_SIZE) return btoa(String.fromCharCode(...bytes));
8
+ let output = "";
9
+ for (var i = 0; i < bytes.length; i += CHUNK_SIZE) {
10
+ const chunk = bytes.slice(i, i + CHUNK_SIZE);
11
+ output += String.fromCharCode(...chunk);
12
+ }
13
+ return btoa(output);
14
+ }
15
+
16
+ //#endregion
17
+ export { fromBase64, toBase64 };
18
+ //# sourceMappingURL=b64.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"b64.mjs","names":[],"sources":["../src/b64.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function fromBase64(base64String: string): Uint8Array<ArrayBuffer> {\n\treturn Uint8Array.from(atob(base64String), (char) => char.charCodeAt(0));\n}\n\nconst CHUNK_SIZE = 8192;\nexport function toBase64(bytes: Uint8Array): string {\n\t// Special-case the simple case for speed's sake.\n\tif (bytes.length < CHUNK_SIZE) {\n\t\treturn btoa(String.fromCharCode(...bytes));\n\t}\n\n\tlet output = '';\n\tfor (var i = 0; i < bytes.length; i += CHUNK_SIZE) {\n\t\tconst chunk = bytes.slice(i, i + CHUNK_SIZE);\n\t\toutput += String.fromCharCode(...chunk);\n\t}\n\n\treturn btoa(output);\n}\n"],"mappings":";AAGA,SAAgB,WAAW,cAA+C;AACzE,QAAO,WAAW,KAAK,KAAK,aAAa,GAAG,SAAS,KAAK,WAAW,EAAE,CAAC;;AAGzE,MAAM,aAAa;AACnB,SAAgB,SAAS,OAA2B;AAEnD,KAAI,MAAM,SAAS,WAClB,QAAO,KAAK,OAAO,aAAa,GAAG,MAAM,CAAC;CAG3C,IAAI,SAAS;AACb,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,YAAY;EAClD,MAAM,QAAQ,MAAM,MAAM,GAAG,IAAI,WAAW;AAC5C,YAAU,OAAO,aAAa,GAAG,MAAM;;AAGxC,QAAO,KAAK,OAAO"}
@@ -0,0 +1,5 @@
1
+ //#region src/chunk.d.ts
2
+ declare function chunk<T>(array: readonly T[], size: number): T[][];
3
+ //#endregion
4
+ export { chunk };
5
+ //# sourceMappingURL=chunk.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.d.mts","names":[],"sources":["../src/chunk.ts"],"mappings":";iBAGgB,KAAA,GAAA,CAAS,KAAA,WAAgB,CAAA,IAAK,IAAA,WAAe,CAAA"}
package/dist/chunk.mjs ADDED
@@ -0,0 +1,10 @@
1
+ //#region src/chunk.ts
2
+ function chunk(array, size) {
3
+ return Array.from({ length: Math.ceil(array.length / size) }, (_, i) => {
4
+ return array.slice(i * size, (i + 1) * size);
5
+ });
6
+ }
7
+
8
+ //#endregion
9
+ export { chunk };
10
+ //# sourceMappingURL=chunk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk.mjs","names":[],"sources":["../src/chunk.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function chunk<T>(array: readonly T[], size: number): T[][] {\n\treturn Array.from({ length: Math.ceil(array.length / size) }, (_, i) => {\n\t\treturn array.slice(i * size, (i + 1) * size);\n\t});\n}\n"],"mappings":";AAGA,SAAgB,MAAS,OAAqB,MAAqB;AAClE,QAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,KAAK,MAAM,SAAS,KAAK,EAAE,GAAG,GAAG,MAAM;AACvE,SAAO,MAAM,MAAM,IAAI,OAAO,IAAI,KAAK,KAAK;GAC3C"}
@@ -0,0 +1,139 @@
1
+ //#region src/dataloader.d.ts
2
+ /**
3
+ * DataLoader - A generic utility for batching and caching data fetches.
4
+ *
5
+ * Vendored from: https://github.com/graphql/dataloader
6
+ * Commit: a10773043d41a56bde4219c155fcf5633e6c9bcb
7
+ * License: MIT
8
+ * Copyright (c) GraphQL Contributors
9
+ */
10
+ /**
11
+ * A `DataLoader` creates a public API for loading data from a particular
12
+ * data back-end with unique keys such as the `id` column of a SQL table or
13
+ * document name in a MongoDB database, given a batch loading function.
14
+ *
15
+ * Each `DataLoader` instance contains a unique memoized cache. Use caution when
16
+ * used in long-lived applications or those which serve many users with
17
+ * different access permissions and consider creating a new instance per
18
+ * web request.
19
+ */
20
+ declare class DataLoader<K, V, C = K> {
21
+ constructor(batchLoadFn: DataLoader.BatchLoadFn<K, V>, options?: DataLoader.Options<K, V, C>);
22
+ _batchLoadFn: DataLoader.BatchLoadFn<K, V>;
23
+ _maxBatchSize: number;
24
+ _batchScheduleFn: (cb: () => void) => void;
25
+ _cacheKeyFn: (key: K) => C;
26
+ _cacheMap: DataLoader.CacheMap<C, Promise<V>> | null;
27
+ _batch: Batch<K, V> | null;
28
+ /**
29
+ * Loads a key, returning a `Promise` for the value represented by that key.
30
+ */
31
+ load(key: K): Promise<V>;
32
+ /**
33
+ * Loads multiple keys, promising an array of values:
34
+ *
35
+ * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]);
36
+ *
37
+ * This is similar to the more verbose:
38
+ *
39
+ * var [ a, b ] = await Promise.all([
40
+ * myLoader.load('a'),
41
+ * myLoader.load('b')
42
+ * ]);
43
+ *
44
+ * However it is different in the case where any load fails. Where
45
+ * Promise.all() would reject, loadMany() always resolves, however each result
46
+ * is either a value or an Error instance.
47
+ *
48
+ * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]);
49
+ * // c instanceof Error
50
+ *
51
+ */
52
+ loadMany(keys: ReadonlyArray<K>): Promise<Array<V | Error>>;
53
+ /**
54
+ * Clears the value at `key` from the cache, if it exists. Returns itself for
55
+ * method chaining.
56
+ */
57
+ clear(key: K): this;
58
+ /**
59
+ * Clears the entire cache. To be used when some event results in unknown
60
+ * invalidations across this particular `DataLoader`. Returns itself for
61
+ * method chaining.
62
+ */
63
+ clearAll(): this;
64
+ /**
65
+ * Adds the provided key and value to the cache. If the key already
66
+ * exists, no change is made. Returns itself for method chaining.
67
+ *
68
+ * To prime the cache with an error at a key, provide an Error instance.
69
+ */
70
+ prime(key: K, value: V | Promise<V> | Error): this;
71
+ /**
72
+ * The name given to this `DataLoader` instance. Useful for APM tools.
73
+ *
74
+ * Is `null` if not set in the constructor.
75
+ */
76
+ name: string | null;
77
+ }
78
+ type Batch<K, V> = {
79
+ hasDispatched: boolean;
80
+ keys: Array<K>;
81
+ callbacks: Array<{
82
+ resolve: (value: V) => void;
83
+ reject: (error: Error) => void;
84
+ }>;
85
+ cacheHits?: Array<() => void>;
86
+ };
87
+ declare namespace DataLoader {
88
+ type CacheMap<K, V> = {
89
+ get(key: K): V | void;
90
+ set(key: K, value: V): any;
91
+ delete(key: K): any;
92
+ clear(): any;
93
+ };
94
+ type BatchLoadFn<K, V> = (keys: ReadonlyArray<K>) => PromiseLike<ArrayLike<V | Error>>;
95
+ type Options<K, V, C = K> = {
96
+ /**
97
+ * Default `true`. Set to `false` to disable batching, invoking
98
+ * `batchLoadFn` with a single load key. This is equivalent to setting
99
+ * `maxBatchSize` to `1`.
100
+ */
101
+ batch?: boolean;
102
+ /**
103
+ * Default `Infinity`. Limits the number of items that get passed in to the
104
+ * `batchLoadFn`. May be set to `1` to disable batching.
105
+ */
106
+ maxBatchSize?: number;
107
+ /**
108
+ * Default see https://github.com/graphql/dataloader#batch-scheduling.
109
+ * A function to schedule the later execution of a batch. The function is
110
+ * expected to call the provided callback in the immediate future.
111
+ */
112
+ batchScheduleFn?: (callback: () => void) => void;
113
+ /**
114
+ * Default `true`. Set to `false` to disable memoization caching, creating a
115
+ * new Promise and new key in the `batchLoadFn` for every load of the same
116
+ * key. This is equivalent to setting `cacheMap` to `null`.
117
+ */
118
+ cache?: boolean;
119
+ /**
120
+ * Default `key => key`. Produces cache key for a given load key. Useful
121
+ * when keys are objects and two objects should be considered equivalent.
122
+ */
123
+ cacheKeyFn?: (key: K) => C;
124
+ /**
125
+ * Default `new Map()`. Instance of `Map` (or an object with a similar API)
126
+ * to be used as cache. May be set to `null` to disable caching.
127
+ */
128
+ cacheMap?: CacheMap<C, Promise<V>> | null;
129
+ /**
130
+ * The name given to this `DataLoader` instance. Useful for APM tools.
131
+ *
132
+ * Is `null` if not set in the constructor.
133
+ */
134
+ name?: string | null;
135
+ };
136
+ }
137
+ //#endregion
138
+ export { DataLoader };
139
+ //# sourceMappingURL=dataloader.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataloader.d.mts","names":[],"sources":["../src/dataloader.ts"],"mappings":";;AAsBA;;;;;;;;;;;;;;;;;cAAa,UAAA,WAAqB,CAAA;cACrB,WAAA,EAAa,UAAA,CAAW,WAAA,CAAY,CAAA,EAAG,CAAA,GAAI,OAAA,GAAU,UAAA,CAAW,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAA;EAiB1F,YAAA,EAAc,UAAA,CAAW,WAAA,CAAY,CAAA,EAAG,CAAA;EACxC,aAAA;EACA,gBAAA,GAAmB,EAAA;EACnB,WAAA,GAAc,GAAA,EAAK,CAAA,KAAM,CA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AA,IAAc,GAAA,EAAK,CAAA,KAAM,CAAA;IA3QpB;;;;IAiRL,QAAA,GAAW,QAAA,CAAS,CAAA,EAAG,OAAA,CAAQ,CAAA;IA/Qd;;;;;IAsRjB,IAAA;EAAA;AAAA"}
@@ -0,0 +1,236 @@
1
+ //#region src/dataloader.ts
2
+ /**
3
+ * DataLoader - A generic utility for batching and caching data fetches.
4
+ *
5
+ * Vendored from: https://github.com/graphql/dataloader
6
+ * Commit: a10773043d41a56bde4219c155fcf5633e6c9bcb
7
+ * License: MIT
8
+ * Copyright (c) GraphQL Contributors
9
+ */
10
+ /**
11
+ * A `DataLoader` creates a public API for loading data from a particular
12
+ * data back-end with unique keys such as the `id` column of a SQL table or
13
+ * document name in a MongoDB database, given a batch loading function.
14
+ *
15
+ * Each `DataLoader` instance contains a unique memoized cache. Use caution when
16
+ * used in long-lived applications or those which serve many users with
17
+ * different access permissions and consider creating a new instance per
18
+ * web request.
19
+ */
20
+ var DataLoader = class {
21
+ constructor(batchLoadFn, options) {
22
+ if (typeof batchLoadFn !== "function") throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${batchLoadFn}.`);
23
+ this._batchLoadFn = batchLoadFn;
24
+ this._maxBatchSize = getValidMaxBatchSize(options);
25
+ this._batchScheduleFn = getValidBatchScheduleFn(options);
26
+ this._cacheKeyFn = getValidCacheKeyFn(options);
27
+ this._cacheMap = getValidCacheMap(options);
28
+ this._batch = null;
29
+ this.name = getValidName(options);
30
+ }
31
+ /**
32
+ * Loads a key, returning a `Promise` for the value represented by that key.
33
+ */
34
+ load(key) {
35
+ if (key === null || key === void 0) throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(key)}.`);
36
+ const batch = getCurrentBatch(this);
37
+ const cacheMap = this._cacheMap;
38
+ let cacheKey;
39
+ if (cacheMap) {
40
+ cacheKey = this._cacheKeyFn(key);
41
+ const cachedPromise = cacheMap.get(cacheKey);
42
+ if (cachedPromise) {
43
+ const cacheHits = batch.cacheHits || (batch.cacheHits = []);
44
+ return new Promise((resolve) => {
45
+ cacheHits.push(() => {
46
+ resolve(cachedPromise);
47
+ });
48
+ });
49
+ }
50
+ }
51
+ batch.keys.push(key);
52
+ const promise = new Promise((resolve, reject) => {
53
+ batch.callbacks.push({
54
+ resolve,
55
+ reject
56
+ });
57
+ });
58
+ if (cacheMap) cacheMap.set(cacheKey, promise);
59
+ return promise;
60
+ }
61
+ /**
62
+ * Loads multiple keys, promising an array of values:
63
+ *
64
+ * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]);
65
+ *
66
+ * This is similar to the more verbose:
67
+ *
68
+ * var [ a, b ] = await Promise.all([
69
+ * myLoader.load('a'),
70
+ * myLoader.load('b')
71
+ * ]);
72
+ *
73
+ * However it is different in the case where any load fails. Where
74
+ * Promise.all() would reject, loadMany() always resolves, however each result
75
+ * is either a value or an Error instance.
76
+ *
77
+ * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]);
78
+ * // c instanceof Error
79
+ *
80
+ */
81
+ loadMany(keys) {
82
+ if (!isArrayLike(keys)) throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${keys}.`);
83
+ const loadPromises = [];
84
+ for (let i = 0; i < keys.length; i++) loadPromises.push(this.load(keys[i]).catch((error) => error));
85
+ return Promise.all(loadPromises);
86
+ }
87
+ /**
88
+ * Clears the value at `key` from the cache, if it exists. Returns itself for
89
+ * method chaining.
90
+ */
91
+ clear(key) {
92
+ const cacheMap = this._cacheMap;
93
+ if (cacheMap) {
94
+ const cacheKey = this._cacheKeyFn(key);
95
+ cacheMap.delete(cacheKey);
96
+ }
97
+ return this;
98
+ }
99
+ /**
100
+ * Clears the entire cache. To be used when some event results in unknown
101
+ * invalidations across this particular `DataLoader`. Returns itself for
102
+ * method chaining.
103
+ */
104
+ clearAll() {
105
+ const cacheMap = this._cacheMap;
106
+ if (cacheMap) cacheMap.clear();
107
+ return this;
108
+ }
109
+ /**
110
+ * Adds the provided key and value to the cache. If the key already
111
+ * exists, no change is made. Returns itself for method chaining.
112
+ *
113
+ * To prime the cache with an error at a key, provide an Error instance.
114
+ */
115
+ prime(key, value) {
116
+ const cacheMap = this._cacheMap;
117
+ if (cacheMap) {
118
+ const cacheKey = this._cacheKeyFn(key);
119
+ if (cacheMap.get(cacheKey) === void 0) {
120
+ let promise;
121
+ if (value instanceof Error) {
122
+ promise = Promise.reject(value);
123
+ promise.catch(() => {});
124
+ } else promise = Promise.resolve(value);
125
+ cacheMap.set(cacheKey, promise);
126
+ }
127
+ }
128
+ return this;
129
+ }
130
+ };
131
+ const enqueuePostPromiseJob = typeof process === "object" && typeof process.nextTick === "function" ? function(fn) {
132
+ if (!resolvedPromise) resolvedPromise = Promise.resolve();
133
+ resolvedPromise.then(() => {
134
+ process.nextTick(fn);
135
+ });
136
+ } : typeof setImmediate === "function" ? function(fn) {
137
+ setImmediate(fn);
138
+ } : function(fn) {
139
+ setTimeout(fn);
140
+ };
141
+ let resolvedPromise;
142
+ function getCurrentBatch(loader) {
143
+ const existingBatch = loader._batch;
144
+ if (existingBatch !== null && !existingBatch.hasDispatched && existingBatch.keys.length < loader._maxBatchSize) return existingBatch;
145
+ const newBatch = {
146
+ hasDispatched: false,
147
+ keys: [],
148
+ callbacks: []
149
+ };
150
+ loader._batch = newBatch;
151
+ loader._batchScheduleFn(() => {
152
+ dispatchBatch(loader, newBatch);
153
+ });
154
+ return newBatch;
155
+ }
156
+ function dispatchBatch(loader, batch) {
157
+ batch.hasDispatched = true;
158
+ if (batch.keys.length === 0) {
159
+ resolveCacheHits(batch);
160
+ return;
161
+ }
162
+ let batchPromise;
163
+ try {
164
+ batchPromise = loader._batchLoadFn(batch.keys);
165
+ } catch (e) {
166
+ return failedDispatch(loader, batch, /* @__PURE__ */ new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(e)}.`));
167
+ }
168
+ if (!batchPromise || typeof batchPromise.then !== "function") return failedDispatch(loader, batch, /* @__PURE__ */ new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(batchPromise)}.`));
169
+ Promise.resolve(batchPromise).then((values) => {
170
+ if (!isArrayLike(values)) throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(values)}.`);
171
+ if (values.length !== batch.keys.length) throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n${String(batch.keys)}\n\nValues:\n${String(values)}`);
172
+ resolveCacheHits(batch);
173
+ for (let i = 0; i < batch.callbacks.length; i++) {
174
+ const value = values[i];
175
+ if (value instanceof Error) batch.callbacks[i].reject(value);
176
+ else batch.callbacks[i].resolve(value);
177
+ }
178
+ }).catch((error) => {
179
+ failedDispatch(loader, batch, error);
180
+ });
181
+ }
182
+ function failedDispatch(loader, batch, error) {
183
+ resolveCacheHits(batch);
184
+ for (let i = 0; i < batch.keys.length; i++) {
185
+ loader.clear(batch.keys[i]);
186
+ batch.callbacks[i].reject(error);
187
+ }
188
+ }
189
+ function resolveCacheHits(batch) {
190
+ if (batch.cacheHits) for (let i = 0; i < batch.cacheHits.length; i++) batch.cacheHits[i]();
191
+ }
192
+ function getValidMaxBatchSize(options) {
193
+ if (!(!options || options.batch !== false)) return 1;
194
+ const maxBatchSize = options && options.maxBatchSize;
195
+ if (maxBatchSize === void 0) return Infinity;
196
+ if (typeof maxBatchSize !== "number" || maxBatchSize < 1) throw new TypeError(`maxBatchSize must be a positive number: ${maxBatchSize}`);
197
+ return maxBatchSize;
198
+ }
199
+ function getValidBatchScheduleFn(options) {
200
+ const batchScheduleFn = options && options.batchScheduleFn;
201
+ if (batchScheduleFn === void 0) return enqueuePostPromiseJob;
202
+ if (typeof batchScheduleFn !== "function") throw new TypeError(`batchScheduleFn must be a function: ${batchScheduleFn}`);
203
+ return batchScheduleFn;
204
+ }
205
+ function getValidCacheKeyFn(options) {
206
+ const cacheKeyFn = options && options.cacheKeyFn;
207
+ if (cacheKeyFn === void 0) return (key) => key;
208
+ if (typeof cacheKeyFn !== "function") throw new TypeError(`cacheKeyFn must be a function: ${cacheKeyFn}`);
209
+ return cacheKeyFn;
210
+ }
211
+ function getValidCacheMap(options) {
212
+ if (!(!options || options.cache !== false)) return null;
213
+ const cacheMap = options && options.cacheMap;
214
+ if (cacheMap === void 0) return /* @__PURE__ */ new Map();
215
+ if (cacheMap !== null) {
216
+ const missingFunctions = [
217
+ "get",
218
+ "set",
219
+ "delete",
220
+ "clear"
221
+ ].filter((fnName) => cacheMap && typeof cacheMap[fnName] !== "function");
222
+ if (missingFunctions.length !== 0) throw new TypeError("Custom cacheMap missing methods: " + missingFunctions.join(", "));
223
+ }
224
+ return cacheMap;
225
+ }
226
+ function getValidName(options) {
227
+ if (options && options.name) return options.name;
228
+ return null;
229
+ }
230
+ function isArrayLike(x) {
231
+ return typeof x === "object" && x !== null && "length" in x && typeof x.length === "number" && (x.length === 0 || x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1));
232
+ }
233
+
234
+ //#endregion
235
+ export { DataLoader };
236
+ //# sourceMappingURL=dataloader.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataloader.mjs","names":[],"sources":["../src/dataloader.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * DataLoader - A generic utility for batching and caching data fetches.\n *\n * Vendored from: https://github.com/graphql/dataloader\n * Commit: a10773043d41a56bde4219c155fcf5633e6c9bcb\n * License: MIT\n * Copyright (c) GraphQL Contributors\n */\n\n/**\n * A `DataLoader` creates a public API for loading data from a particular\n * data back-end with unique keys such as the `id` column of a SQL table or\n * document name in a MongoDB database, given a batch loading function.\n *\n * Each `DataLoader` instance contains a unique memoized cache. Use caution when\n * used in long-lived applications or those which serve many users with\n * different access permissions and consider creating a new instance per\n * web request.\n */\nexport class DataLoader<K, V, C = K> {\n\tconstructor(batchLoadFn: DataLoader.BatchLoadFn<K, V>, options?: DataLoader.Options<K, V, C>) {\n\t\tif (typeof batchLoadFn !== 'function') {\n\t\t\tthrow new TypeError(\n\t\t\t\t'DataLoader must be constructed with a function which accepts ' +\n\t\t\t\t\t`Array<key> and returns Promise<Array<value>>, but got: ${batchLoadFn}.`,\n\t\t\t);\n\t\t}\n\t\tthis._batchLoadFn = batchLoadFn;\n\t\tthis._maxBatchSize = getValidMaxBatchSize(options);\n\t\tthis._batchScheduleFn = getValidBatchScheduleFn(options);\n\t\tthis._cacheKeyFn = getValidCacheKeyFn(options);\n\t\tthis._cacheMap = getValidCacheMap(options);\n\t\tthis._batch = null;\n\t\tthis.name = getValidName(options);\n\t}\n\n\t// Private\n\t_batchLoadFn: DataLoader.BatchLoadFn<K, V>;\n\t_maxBatchSize: number;\n\t_batchScheduleFn: (cb: () => void) => void;\n\t_cacheKeyFn: (key: K) => C;\n\t_cacheMap: DataLoader.CacheMap<C, Promise<V>> | null;\n\t_batch: Batch<K, V> | null;\n\n\t/**\n\t * Loads a key, returning a `Promise` for the value represented by that key.\n\t */\n\tload(key: K): Promise<V> {\n\t\tif (key === null || key === undefined) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`The loader.load() function must be called with a value, but got: ${String(key)}.`,\n\t\t\t);\n\t\t}\n\n\t\tconst batch = getCurrentBatch(this);\n\t\tconst cacheMap = this._cacheMap;\n\t\tlet cacheKey: C;\n\n\t\t// If caching and there is a cache-hit, return cached Promise.\n\t\tif (cacheMap) {\n\t\t\tcacheKey = this._cacheKeyFn(key);\n\t\t\tconst cachedPromise = cacheMap.get(cacheKey);\n\t\t\tif (cachedPromise) {\n\t\t\t\tconst cacheHits = batch.cacheHits || (batch.cacheHits = []);\n\t\t\t\treturn new Promise((resolve) => {\n\t\t\t\t\tcacheHits.push(() => {\n\t\t\t\t\t\tresolve(cachedPromise);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// Otherwise, produce a new Promise for this key, and enqueue it to be\n\t\t// dispatched along with the current batch.\n\t\tbatch.keys.push(key);\n\t\tconst promise = new Promise<V>((resolve, reject) => {\n\t\t\tbatch.callbacks.push({ resolve, reject });\n\t\t});\n\n\t\t// If caching, cache this promise.\n\t\tif (cacheMap) {\n\t\t\tcacheMap.set(cacheKey!, promise);\n\t\t}\n\n\t\treturn promise;\n\t}\n\n\t/**\n\t * Loads multiple keys, promising an array of values:\n\t *\n\t * var [ a, b ] = await myLoader.loadMany([ 'a', 'b' ]);\n\t *\n\t * This is similar to the more verbose:\n\t *\n\t * var [ a, b ] = await Promise.all([\n\t * myLoader.load('a'),\n\t * myLoader.load('b')\n\t * ]);\n\t *\n\t * However it is different in the case where any load fails. Where\n\t * Promise.all() would reject, loadMany() always resolves, however each result\n\t * is either a value or an Error instance.\n\t *\n\t * var [ a, b, c ] = await myLoader.loadMany([ 'a', 'b', 'badkey' ]);\n\t * // c instanceof Error\n\t *\n\t */\n\tloadMany(keys: ReadonlyArray<K>): Promise<Array<V | Error>> {\n\t\tif (!isArrayLike(keys)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`The loader.loadMany() function must be called with Array<key>, but got: ${keys}.`,\n\t\t\t);\n\t\t}\n\t\t// Support ArrayLike by using only minimal property access\n\t\tconst loadPromises = [];\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tloadPromises.push(this.load(keys[i]).catch((error) => error));\n\t\t}\n\t\treturn Promise.all(loadPromises);\n\t}\n\n\t/**\n\t * Clears the value at `key` from the cache, if it exists. Returns itself for\n\t * method chaining.\n\t */\n\tclear(key: K): this {\n\t\tconst cacheMap = this._cacheMap;\n\t\tif (cacheMap) {\n\t\t\tconst cacheKey = this._cacheKeyFn(key);\n\t\t\tcacheMap.delete(cacheKey);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Clears the entire cache. To be used when some event results in unknown\n\t * invalidations across this particular `DataLoader`. Returns itself for\n\t * method chaining.\n\t */\n\tclearAll(): this {\n\t\tconst cacheMap = this._cacheMap;\n\t\tif (cacheMap) {\n\t\t\tcacheMap.clear();\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the provided key and value to the cache. If the key already\n\t * exists, no change is made. Returns itself for method chaining.\n\t *\n\t * To prime the cache with an error at a key, provide an Error instance.\n\t */\n\tprime(key: K, value: V | Promise<V> | Error): this {\n\t\tconst cacheMap = this._cacheMap;\n\t\tif (cacheMap) {\n\t\t\tconst cacheKey = this._cacheKeyFn(key);\n\n\t\t\t// Only add the key if it does not already exist.\n\t\t\tif (cacheMap.get(cacheKey) === undefined) {\n\t\t\t\t// Cache a rejected promise if the value is an Error, in order to match\n\t\t\t\t// the behavior of load(key).\n\t\t\t\tlet promise;\n\t\t\t\tif (value instanceof Error) {\n\t\t\t\t\tpromise = Promise.reject(value);\n\t\t\t\t\t// Since this is a case where an Error is intentionally being primed\n\t\t\t\t\t// for a given key, we want to disable unhandled promise rejection.\n\t\t\t\t\tpromise.catch(() => {});\n\t\t\t\t} else {\n\t\t\t\t\tpromise = Promise.resolve(value);\n\t\t\t\t}\n\t\t\t\tcacheMap.set(cacheKey, promise);\n\t\t\t}\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * The name given to this `DataLoader` instance. Useful for APM tools.\n\t *\n\t * Is `null` if not set in the constructor.\n\t */\n\tname: string | null;\n}\n\n// Private: Enqueue a Job to be executed after all \"PromiseJobs\" Jobs.\n//\n// ES6 JavaScript uses the concepts Job and JobQueue to schedule work to occur\n// after the current execution context has completed:\n// http://www.ecma-international.org/ecma-262/6.0/#sec-jobs-and-job-queues\n//\n// Node.js uses the `process.nextTick` mechanism to implement the concept of a\n// Job, maintaining a global FIFO JobQueue for all Jobs, which is flushed after\n// the current call stack ends.\n//\n// When calling `then` on a Promise, it enqueues a Job on a specific\n// \"PromiseJobs\" JobQueue which is flushed in Node as a single Job on the\n// global JobQueue.\n//\n// DataLoader batches all loads which occur in a single frame of execution, but\n// should include in the batch all loads which occur during the flushing of the\n// \"PromiseJobs\" JobQueue after that same execution frame.\n//\n// In order to avoid the DataLoader dispatch Job occuring before \"PromiseJobs\",\n// A Promise Job is created with the sole purpose of enqueuing a global Job,\n// ensuring that it always occurs after \"PromiseJobs\" ends.\n//\n// Node.js's job queue is unique. Browsers do not have an equivalent mechanism\n// for enqueuing a job to be performed after promise microtasks and before the\n// next macrotask. For browser environments, a macrotask is used (via\n// setImmediate or setTimeout) at a potential performance penalty.\nconst enqueuePostPromiseJob: (fn: () => void) => void =\n\t// @ts-ignore\n\ttypeof process === 'object' && typeof process.nextTick === 'function'\n\t\t? function (fn) {\n\t\t\t\tif (!resolvedPromise) {\n\t\t\t\t\tresolvedPromise = Promise.resolve();\n\t\t\t\t}\n\t\t\t\tresolvedPromise.then(() => {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tprocess.nextTick(fn);\n\t\t\t\t});\n\t\t\t}\n\t\t: // @ts-ignore\n\t\t\ttypeof setImmediate === 'function'\n\t\t\t? function (fn) {\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tsetImmediate(fn);\n\t\t\t\t}\n\t\t\t: function (fn) {\n\t\t\t\t\tsetTimeout(fn);\n\t\t\t\t};\n\n// Private: cached resolved Promise instance\nlet resolvedPromise: Promise<void> | undefined;\n\n// Private: Describes a batch of requests\ntype Batch<K, V> = {\n\thasDispatched: boolean;\n\tkeys: Array<K>;\n\tcallbacks: Array<{\n\t\tresolve: (value: V) => void;\n\t\treject: (error: Error) => void;\n\t}>;\n\tcacheHits?: Array<() => void>;\n};\n\n// Private: Either returns the current batch, or creates and schedules a\n// dispatch of a new batch for the given loader.\nfunction getCurrentBatch<K, V>(loader: DataLoader<K, V, any>): Batch<K, V> {\n\t// If there is an existing batch which has not yet dispatched and is within\n\t// the limit of the batch size, then return it.\n\tconst existingBatch = loader._batch;\n\tif (\n\t\texistingBatch !== null &&\n\t\t!existingBatch.hasDispatched &&\n\t\texistingBatch.keys.length < loader._maxBatchSize\n\t) {\n\t\treturn existingBatch;\n\t}\n\n\t// Otherwise, create a new batch for this loader.\n\tconst newBatch = { hasDispatched: false, keys: [], callbacks: [] };\n\n\t// Store it on the loader so it may be reused.\n\tloader._batch = newBatch;\n\n\t// Then schedule a task to dispatch this batch of requests.\n\tloader._batchScheduleFn(() => {\n\t\tdispatchBatch(loader, newBatch);\n\t});\n\n\treturn newBatch;\n}\n\nfunction dispatchBatch<K, V>(loader: DataLoader<K, V, any>, batch: Batch<K, V>) {\n\t// Mark this batch as having been dispatched.\n\tbatch.hasDispatched = true;\n\n\t// If there's nothing to load, resolve any cache hits and return early.\n\tif (batch.keys.length === 0) {\n\t\tresolveCacheHits(batch);\n\t\treturn;\n\t}\n\n\t// Call the provided batchLoadFn for this loader with the batch's keys and\n\t// with the loader as the `this` context.\n\tlet batchPromise;\n\ttry {\n\t\tbatchPromise = loader._batchLoadFn(batch.keys);\n\t} catch (e) {\n\t\treturn failedDispatch(\n\t\t\tloader,\n\t\t\tbatch,\n\t\t\tnew TypeError(\n\t\t\t\t'DataLoader must be constructed with a function which accepts ' +\n\t\t\t\t\t'Array<key> and returns Promise<Array<value>>, but the function ' +\n\t\t\t\t\t`errored synchronously: ${String(e)}.`,\n\t\t\t),\n\t\t);\n\t}\n\n\t// Assert the expected response from batchLoadFn\n\tif (!batchPromise || typeof batchPromise.then !== 'function') {\n\t\treturn failedDispatch(\n\t\t\tloader,\n\t\t\tbatch,\n\t\t\tnew TypeError(\n\t\t\t\t'DataLoader must be constructed with a function which accepts ' +\n\t\t\t\t\t'Array<key> and returns Promise<Array<value>>, but the function did ' +\n\t\t\t\t\t`not return a Promise: ${String(batchPromise)}.`,\n\t\t\t),\n\t\t);\n\t}\n\n\t// Await the resolution of the call to batchLoadFn.\n\tPromise.resolve(batchPromise)\n\t\t.then((values) => {\n\t\t\t// Assert the expected resolution from batchLoadFn.\n\t\t\tif (!isArrayLike(values)) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t'DataLoader must be constructed with a function which accepts ' +\n\t\t\t\t\t\t'Array<key> and returns Promise<Array<value>>, but the function did ' +\n\t\t\t\t\t\t`not return a Promise of an Array: ${String(values)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (values.length !== batch.keys.length) {\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t'DataLoader must be constructed with a function which accepts ' +\n\t\t\t\t\t\t'Array<key> and returns Promise<Array<value>>, but the function did ' +\n\t\t\t\t\t\t'not return a Promise of an Array of the same length as the Array ' +\n\t\t\t\t\t\t'of keys.' +\n\t\t\t\t\t\t`\\n\\nKeys:\\n${String(batch.keys)}` +\n\t\t\t\t\t\t`\\n\\nValues:\\n${String(values)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// Resolve all cache hits in the same micro-task as freshly loaded values.\n\t\t\tresolveCacheHits(batch);\n\n\t\t\t// Step through values, resolving or rejecting each Promise in the batch.\n\t\t\tfor (let i = 0; i < batch.callbacks.length; i++) {\n\t\t\t\tconst value = values[i];\n\t\t\t\tif (value instanceof Error) {\n\t\t\t\t\tbatch.callbacks[i].reject(value);\n\t\t\t\t} else {\n\t\t\t\t\tbatch.callbacks[i].resolve(value);\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\t.catch((error: unknown) => {\n\t\t\tfailedDispatch(loader, batch, error as Error);\n\t\t});\n}\n\n// Private: do not cache individual loads if the entire batch dispatch fails,\n// but still reject each request so they do not hang.\nfunction failedDispatch<K, V>(loader: DataLoader<K, V, any>, batch: Batch<K, V>, error: Error) {\n\t// Cache hits are resolved, even though the batch failed.\n\tresolveCacheHits(batch);\n\tfor (let i = 0; i < batch.keys.length; i++) {\n\t\tloader.clear(batch.keys[i]);\n\t\tbatch.callbacks[i].reject(error);\n\t}\n}\n\n// Private: Resolves the Promises for any cache hits in this batch.\nfunction resolveCacheHits(batch: Batch<any, any>) {\n\tif (batch.cacheHits) {\n\t\tfor (let i = 0; i < batch.cacheHits.length; i++) {\n\t\t\tbatch.cacheHits[i]();\n\t\t}\n\t}\n}\n\n// Private: given the DataLoader's options, produce a valid max batch size.\nfunction getValidMaxBatchSize<K, V, C>(options?: DataLoader.Options<K, V, C>): number {\n\tconst shouldBatch = !options || options.batch !== false;\n\tif (!shouldBatch) {\n\t\treturn 1;\n\t}\n\tconst maxBatchSize = options && options.maxBatchSize;\n\tif (maxBatchSize === undefined) {\n\t\treturn Infinity;\n\t}\n\tif (typeof maxBatchSize !== 'number' || maxBatchSize < 1) {\n\t\tthrow new TypeError(`maxBatchSize must be a positive number: ${maxBatchSize}`);\n\t}\n\treturn maxBatchSize;\n}\n\n// Private\nfunction getValidBatchScheduleFn<K, V, C>(\n\toptions?: DataLoader.Options<K, V, C>,\n): (cb: () => void) => void {\n\tconst batchScheduleFn = options && options.batchScheduleFn;\n\tif (batchScheduleFn === undefined) {\n\t\treturn enqueuePostPromiseJob;\n\t}\n\tif (typeof batchScheduleFn !== 'function') {\n\t\tthrow new TypeError(`batchScheduleFn must be a function: ${batchScheduleFn}`);\n\t}\n\treturn batchScheduleFn;\n}\n\n// Private: given the DataLoader's options, produce a cache key function.\nfunction getValidCacheKeyFn<K, V, C>(options?: DataLoader.Options<K, V, C>): (key: K) => C {\n\tconst cacheKeyFn = options && options.cacheKeyFn;\n\tif (cacheKeyFn === undefined) {\n\t\treturn (key: K) => key as unknown as C;\n\t}\n\tif (typeof cacheKeyFn !== 'function') {\n\t\tthrow new TypeError(`cacheKeyFn must be a function: ${cacheKeyFn}`);\n\t}\n\treturn cacheKeyFn;\n}\n\n// Private: given the DataLoader's options, produce a CacheMap to be used.\nfunction getValidCacheMap<K, V, C>(\n\toptions?: DataLoader.Options<K, V, C>,\n): DataLoader.CacheMap<C, Promise<V>> | null {\n\tconst shouldCache = !options || options.cache !== false;\n\tif (!shouldCache) {\n\t\treturn null;\n\t}\n\tconst cacheMap = options && options.cacheMap;\n\tif (cacheMap === undefined) {\n\t\treturn new Map();\n\t}\n\tif (cacheMap !== null) {\n\t\tconst cacheFunctions = ['get', 'set', 'delete', 'clear'] as const;\n\t\tconst missingFunctions = cacheFunctions.filter(\n\t\t\t(fnName) => cacheMap && typeof cacheMap[fnName] !== 'function',\n\t\t);\n\t\tif (missingFunctions.length !== 0) {\n\t\t\tthrow new TypeError('Custom cacheMap missing methods: ' + missingFunctions.join(', '));\n\t\t}\n\t}\n\treturn cacheMap;\n}\n\nfunction getValidName<K, V, C>(options?: DataLoader.Options<K, V, C>): string | null {\n\tif (options && options.name) {\n\t\treturn options.name;\n\t}\n\n\treturn null;\n}\n\nfunction isArrayLike(x: unknown): x is ArrayLike<unknown> {\n\treturn (\n\t\ttypeof x === 'object' &&\n\t\tx !== null &&\n\t\t'length' in x &&\n\t\ttypeof x.length === 'number' &&\n\t\t(x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1)))\n\t);\n}\n\nexport declare namespace DataLoader {\n\t// If a custom cache is provided, it must be of this type (a subset of ES6 Map).\n\texport type CacheMap<K, V> = {\n\t\tget(key: K): V | void;\n\t\tset(key: K, value: V): any;\n\t\tdelete(key: K): any;\n\t\tclear(): any;\n\t};\n\n\t// A Function, which when given an Array of keys, returns a Promise of an Array\n\t// of values or Errors.\n\texport type BatchLoadFn<K, V> = (keys: ReadonlyArray<K>) => PromiseLike<ArrayLike<V | Error>>;\n\n\t// Optionally turn off batching or caching or provide a cache key function or a\n\t// custom cache instance.\n\texport type Options<K, V, C = K> = {\n\t\t/**\n\t\t * Default `true`. Set to `false` to disable batching, invoking\n\t\t * `batchLoadFn` with a single load key. This is equivalent to setting\n\t\t * `maxBatchSize` to `1`.\n\t\t */\n\t\tbatch?: boolean;\n\n\t\t/**\n\t\t * Default `Infinity`. Limits the number of items that get passed in to the\n\t\t * `batchLoadFn`. May be set to `1` to disable batching.\n\t\t */\n\t\tmaxBatchSize?: number;\n\n\t\t/**\n\t\t * Default see https://github.com/graphql/dataloader#batch-scheduling.\n\t\t * A function to schedule the later execution of a batch. The function is\n\t\t * expected to call the provided callback in the immediate future.\n\t\t */\n\t\tbatchScheduleFn?: (callback: () => void) => void;\n\n\t\t/**\n\t\t * Default `true`. Set to `false` to disable memoization caching, creating a\n\t\t * new Promise and new key in the `batchLoadFn` for every load of the same\n\t\t * key. This is equivalent to setting `cacheMap` to `null`.\n\t\t */\n\t\tcache?: boolean;\n\n\t\t/**\n\t\t * Default `key => key`. Produces cache key for a given load key. Useful\n\t\t * when keys are objects and two objects should be considered equivalent.\n\t\t */\n\t\tcacheKeyFn?: (key: K) => C;\n\n\t\t/**\n\t\t * Default `new Map()`. Instance of `Map` (or an object with a similar API)\n\t\t * to be used as cache. May be set to `null` to disable caching.\n\t\t */\n\t\tcacheMap?: CacheMap<C, Promise<V>> | null;\n\n\t\t/**\n\t\t * The name given to this `DataLoader` instance. Useful for APM tools.\n\t\t *\n\t\t * Is `null` if not set in the constructor.\n\t\t */\n\t\tname?: string | null;\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsBA,IAAa,aAAb,MAAqC;CACpC,YAAY,aAA2C,SAAuC;AAC7F,MAAI,OAAO,gBAAgB,WAC1B,OAAM,IAAI,UACT,uHAC2D,YAAY,GACvE;AAEF,OAAK,eAAe;AACpB,OAAK,gBAAgB,qBAAqB,QAAQ;AAClD,OAAK,mBAAmB,wBAAwB,QAAQ;AACxD,OAAK,cAAc,mBAAmB,QAAQ;AAC9C,OAAK,YAAY,iBAAiB,QAAQ;AAC1C,OAAK,SAAS;AACd,OAAK,OAAO,aAAa,QAAQ;;;;;CAclC,KAAK,KAAoB;AACxB,MAAI,QAAQ,QAAQ,QAAQ,OAC3B,OAAM,IAAI,UACT,oEAAoE,OAAO,IAAI,CAAC,GAChF;EAGF,MAAM,QAAQ,gBAAgB,KAAK;EACnC,MAAM,WAAW,KAAK;EACtB,IAAI;AAGJ,MAAI,UAAU;AACb,cAAW,KAAK,YAAY,IAAI;GAChC,MAAM,gBAAgB,SAAS,IAAI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,MAAM,WAAW,WAAW,QAAQ;AACpC,KAAI,aAAa,OAChB,wBAAO,IAAI,KAAK;AAEjB,KAAI,aAAa,MAAM;EAEtB,MAAM,mBADiB;GAAC;GAAO;GAAO;GAAU;GAAQ,CAChB,QACtC,WAAW,YAAY,OAAO,SAAS,YAAY,WACpD;AACD,MAAI,iBAAiB,WAAW,EAC/B,OAAM,IAAI,UAAU,sCAAsC,iBAAiB,KAAK,KAAK,CAAC;;AAGxF,QAAO;;AAGR,SAAS,aAAsB,SAAsD;AACpF,KAAI,WAAW,QAAQ,KACtB,QAAO,QAAQ;AAGhB,QAAO;;AAGR,SAAS,YAAY,GAAqC;AACzD,QACC,OAAO,MAAM,YACb,MAAM,QACN,YAAY,KACZ,OAAO,EAAE,WAAW,aACnB,EAAE,WAAW,KAAM,EAAE,SAAS,KAAK,OAAO,UAAU,eAAe,KAAK,GAAG,EAAE,SAAS,EAAE"}
package/dist/hex.d.mts ADDED
@@ -0,0 +1,6 @@
1
+ //#region src/hex.d.ts
2
+ declare function fromHex(hexStr: string): Uint8Array<ArrayBuffer>;
3
+ declare function toHex(bytes: Uint8Array): string;
4
+ //#endregion
5
+ export { fromHex, toHex };
6
+ //# sourceMappingURL=hex.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.d.mts","names":[],"sources":["../src/hex.ts"],"mappings":";iBAGgB,OAAA,CAAQ,MAAA,WAAiB,UAAA,CAAW,WAAA;AAAA,iBAYpC,KAAA,CAAM,KAAA,EAAO,UAAA"}
package/dist/hex.mjs ADDED
@@ -0,0 +1,15 @@
1
+ //#region src/hex.ts
2
+ function fromHex(hexStr) {
3
+ const normalized = hexStr.startsWith("0x") ? hexStr.slice(2) : hexStr;
4
+ const padded = normalized.length % 2 === 0 ? normalized : `0${normalized}`;
5
+ const intArr = padded.match(/[0-9a-fA-F]{2}/g)?.map((byte) => parseInt(byte, 16)) ?? [];
6
+ if (intArr.length !== padded.length / 2) throw new Error(`Invalid hex string ${hexStr}`);
7
+ return Uint8Array.from(intArr);
8
+ }
9
+ function toHex(bytes) {
10
+ return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
11
+ }
12
+
13
+ //#endregion
14
+ export { fromHex, toHex };
15
+ //# sourceMappingURL=hex.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.mjs","names":[],"sources":["../src/hex.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function fromHex(hexStr: string): Uint8Array<ArrayBuffer> {\n\tconst normalized = hexStr.startsWith('0x') ? hexStr.slice(2) : hexStr;\n\tconst padded = normalized.length % 2 === 0 ? normalized : `0${normalized}`;\n\tconst intArr = padded.match(/[0-9a-fA-F]{2}/g)?.map((byte) => parseInt(byte, 16)) ?? [];\n\n\tif (intArr.length !== padded.length / 2) {\n\t\tthrow new Error(`Invalid hex string ${hexStr}`);\n\t}\n\n\treturn Uint8Array.from(intArr);\n}\n\nexport function toHex(bytes: Uint8Array): string {\n\treturn bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, '0'), '');\n}\n"],"mappings":";AAGA,SAAgB,QAAQ,QAAyC;CAChE,MAAM,aAAa,OAAO,WAAW,KAAK,GAAG,OAAO,MAAM,EAAE,GAAG;CAC/D,MAAM,SAAS,WAAW,SAAS,MAAM,IAAI,aAAa,IAAI;CAC9D,MAAM,SAAS,OAAO,MAAM,kBAAkB,EAAE,KAAK,SAAS,SAAS,MAAM,GAAG,CAAC,IAAI,EAAE;AAEvF,KAAI,OAAO,WAAW,OAAO,SAAS,EACrC,OAAM,IAAI,MAAM,sBAAsB,SAAS;AAGhD,QAAO,WAAW,KAAK,OAAO;;AAG/B,SAAgB,MAAM,OAA2B;AAChD,QAAO,MAAM,QAAQ,KAAK,SAAS,MAAM,KAAK,SAAS,GAAG,CAAC,SAAS,GAAG,IAAI,EAAE,GAAG"}
@@ -0,0 +1,9 @@
1
+ import { fromBase58, toBase58 } from "./b58.mjs";
2
+ import { fromBase64, toBase64 } from "./b64.mjs";
3
+ import { fromHex, toHex } from "./hex.mjs";
4
+ import { Simplify, UnionToIntersection } from "./types.mjs";
5
+ import { chunk } from "./chunk.mjs";
6
+ import { PromiseWithResolvers, promiseWithResolvers } from "./with-resolver.mjs";
7
+ import { DataLoader } from "./dataloader.mjs";
8
+ import { Emitter, EventHandlerMap, Handler, WildcardHandler, mitt } from "./mitt.mjs";
9
+ export { DataLoader, type Emitter, type EventHandlerMap, type Handler, type PromiseWithResolvers, type Simplify, type UnionToIntersection, type WildcardHandler, chunk, fromBase58, fromBase64, fromHex, mitt, promiseWithResolvers, toBase58, toBase64, toHex };
package/dist/index.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import { fromBase58, toBase58 } from "./b58.mjs";
2
+ import { fromBase64, toBase64 } from "./b64.mjs";
3
+ import { fromHex, toHex } from "./hex.mjs";
4
+ import { chunk } from "./chunk.mjs";
5
+ import { promiseWithResolvers } from "./with-resolver.mjs";
6
+ import { DataLoader } from "./dataloader.mjs";
7
+ import mitt from "./mitt.mjs";
8
+
9
+ export { DataLoader, chunk, fromBase58, fromBase64, fromHex, mitt, promiseWithResolvers, toBase58, toBase64, toHex };
@@ -0,0 +1,32 @@
1
+ //#region src/mitt.d.ts
2
+ /**
3
+ * Mitt - Tiny (~200b) functional event emitter / pubsub.
4
+ *
5
+ * Vendored from: https://github.com/developit/mitt
6
+ * License: MIT
7
+ * Copyright (c) 2021 Jason Miller
8
+ */
9
+ type EventType = string | symbol;
10
+ type Handler<T = unknown> = (event: T) => void;
11
+ type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void;
12
+ type EventHandlerList<T = unknown> = Array<Handler<T>>;
13
+ type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;
14
+ type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<keyof Events | '*', EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
15
+ interface Emitter<Events extends Record<EventType, unknown>> {
16
+ all: EventHandlerMap<Events>;
17
+ on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
18
+ on(type: '*', handler: WildcardHandler<Events>): void;
19
+ off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
20
+ off(type: '*', handler: WildcardHandler<Events>): void;
21
+ emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
22
+ emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
23
+ }
24
+ /**
25
+ * Mitt: Tiny (~200b) functional event emitter / pubsub.
26
+ * @name mitt
27
+ * @returns {Mitt}
28
+ */
29
+ declare function mitt<Events extends Record<EventType, unknown>>(all?: EventHandlerMap<Events>): Emitter<Events>;
30
+ //#endregion
31
+ export { Emitter, EventHandlerMap, Handler, WildcardHandler, mitt };
32
+ //# sourceMappingURL=mitt.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mitt.d.mts","names":[],"sources":["../src/mitt.ts"],"mappings":";;AAWA;;;;;AAIA;KAJY,SAAA;AAAA,KAIA,OAAA,iBAAwB,KAAA,EAAO,CAAA;AAAA,KAC/B,eAAA,KAAoB,MAAA,sBAC/B,IAAA,QAAY,CAAA,EACZ,KAAA,EAAO,CAAA,OAAQ,CAAA;AAAA,KAIJ,gBAAA,gBAAgC,KAAA,CAAM,OAAA,CAAQ,CAAA;AAAA,KAC9C,wBAAA,KAA6B,MAAA,qBAA2B,KAAA,CAAM,eAAA,CAAgB,CAAA;AAAA,KAG9E,eAAA,gBAA+B,MAAA,CAAO,SAAA,cAAuB,GAAA,OAClE,MAAA,QACN,gBAAA,CAAiB,MAAA,OAAa,MAAA,KAAW,wBAAA,CAAyB,MAAA;AAAA,UAGlD,OAAA,gBAAuB,MAAA,CAAO,SAAA;EAC9C,GAAA,EAAK,eAAA,CAAgB,MAAA;EAErB,EAAA,mBAAqB,MAAA,EAAQ,IAAA,EAAM,GAAA,EAAK,OAAA,EAAS,OAAA,CAAQ,MAAA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