@mtkruto/browser 0.141.0 → 0.143.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/esm/0_deps.d.ts +4 -4
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +4 -4
- package/esm/3_types.d.ts +1 -0
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +1 -0
- package/esm/client/0_params.d.ts +10 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +50 -3
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/2_managed_bot_manager.d.ts +28 -0
- package/esm/client/2_managed_bot_manager.d.ts.map +1 -0
- package/esm/client/2_managed_bot_manager.js +37 -0
- package/esm/client/3_account_manager.d.ts +2 -1
- package/esm/client/3_account_manager.d.ts.map +1 -1
- package/esm/client/3_account_manager.js +17 -2
- package/esm/client/3_filters.d.ts +6 -1
- package/esm/client/3_filters.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +8 -5
- package/esm/client/3_message_manager.d.ts.map +1 -1
- package/esm/client/3_message_manager.js +40 -11
- package/esm/client/4_context.d.ts +8 -0
- package/esm/client/4_context.d.ts.map +1 -1
- package/esm/client/4_context.js +21 -1
- package/esm/client/6_client.d.ts +50 -3
- package/esm/client/6_client.d.ts.map +1 -1
- package/esm/client/6_client.js +71 -2
- package/esm/client/6_client_dispatcher.d.ts +50 -3
- package/esm/client/6_client_dispatcher.d.ts.map +1 -1
- package/esm/client/6_client_dispatcher.js +67 -2
- package/esm/deps/jsr.io/@std/assert/1.0.19/equals.js +4 -4
- package/esm/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/delay.d.ts.map +1 -1
- package/{script/deps/jsr.io/@std/async/1.2.0 → esm/deps/jsr.io/@std/async/1.3.0}/pool.d.ts +2 -0
- package/esm/deps/jsr.io/@std/async/1.3.0/pool.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/pool.js +5 -1
- package/esm/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/_serialize_arg_list.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/_serialize_arg_list.js +27 -16
- package/{script/deps/jsr.io/@std/cache/0.2.2 → esm/deps/jsr.io/@std/cache/0.2.3}/lru_cache.d.ts +109 -25
- package/esm/deps/jsr.io/@std/cache/0.2.3/lru_cache.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/0.2.3/lru_cache.js +299 -0
- package/{script/deps/jsr.io/@std/cache/0.2.2 → esm/deps/jsr.io/@std/cache/0.2.3}/memoize.d.ts +18 -10
- package/esm/deps/jsr.io/@std/cache/0.2.3/memoize.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/memoize.js +11 -7
- package/esm/deps/jsr.io/@std/internal/1.0.13/_os.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/_os.js +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.js +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff.js +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff_str.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff_str.js +3 -3
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/format.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/format.js +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/os.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/os.js +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.js +3 -3
- package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/internal/1.0.13/types.js +3 -0
- package/esm/deps/jsr.io/@std/path/1.1.4/basename.js +1 -1
- package/esm/deps/jsr.io/@std/path/1.1.4/extname.js +1 -1
- package/esm/deps/jsr.io/@std/path/1.1.4/is_absolute.js +1 -1
- package/esm/deps/jsr.io/@std/path/1.1.4/join.js +1 -1
- package/esm/deps/jsr.io/@std/path/1.1.4/to_file_url.js +1 -1
- package/esm/deps/jsr.io/@std/streams/1.1.0/to_array_buffer.d.ts.map +1 -0
- package/esm/tl/1_telegram_api.d.ts +251 -5
- package/esm/tl/1_telegram_api.d.ts.map +1 -1
- package/esm/tl/1_telegram_api.js +271 -11
- package/esm/types/1_chat_p.d.ts +2 -0
- package/esm/types/1_chat_p.d.ts.map +1 -1
- package/esm/types/1_chat_p.js +1 -0
- package/esm/types/2_user.d.ts +2 -0
- package/esm/types/2_user.d.ts.map +1 -1
- package/esm/types/2_user.js +1 -0
- package/esm/types/4_poll.d.ts +2 -0
- package/esm/types/4_poll.d.ts.map +1 -1
- package/esm/types/4_poll.js +1 -0
- package/esm/types/7_guest_query.d.ts +28 -0
- package/esm/types/7_guest_query.d.ts.map +1 -0
- package/esm/types/7_guest_query.js +20 -0
- package/esm/types/8_update.d.ts +19 -1
- package/esm/types/8_update.d.ts.map +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +4 -4
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +4 -4
- package/script/3_types.d.ts +1 -0
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +1 -0
- package/script/client/0_params.d.ts +10 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +50 -3
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/2_managed_bot_manager.d.ts +28 -0
- package/script/client/2_managed_bot_manager.d.ts.map +1 -0
- package/script/client/2_managed_bot_manager.js +41 -0
- package/script/client/3_account_manager.d.ts +2 -1
- package/script/client/3_account_manager.d.ts.map +1 -1
- package/script/client/3_account_manager.js +17 -2
- package/script/client/3_filters.d.ts +6 -1
- package/script/client/3_filters.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +8 -5
- package/script/client/3_message_manager.d.ts.map +1 -1
- package/script/client/3_message_manager.js +38 -9
- package/script/client/4_context.d.ts +8 -0
- package/script/client/4_context.d.ts.map +1 -1
- package/script/client/4_context.js +21 -1
- package/script/client/6_client.d.ts +50 -3
- package/script/client/6_client.d.ts.map +1 -1
- package/script/client/6_client.js +71 -2
- package/script/client/6_client_dispatcher.d.ts +50 -3
- package/script/client/6_client_dispatcher.d.ts.map +1 -1
- package/script/client/6_client_dispatcher.js +67 -2
- package/script/deps/jsr.io/@std/assert/1.0.19/equals.js +4 -4
- package/script/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/delay.d.ts.map +1 -1
- package/{esm/deps/jsr.io/@std/async/1.2.0 → script/deps/jsr.io/@std/async/1.3.0}/pool.d.ts +2 -0
- package/script/deps/jsr.io/@std/async/1.3.0/pool.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/pool.js +5 -1
- package/script/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/_serialize_arg_list.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/_serialize_arg_list.js +27 -16
- package/{esm/deps/jsr.io/@std/cache/0.2.2 → script/deps/jsr.io/@std/cache/0.2.3}/lru_cache.d.ts +109 -25
- package/script/deps/jsr.io/@std/cache/0.2.3/lru_cache.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/lru_cache.js +149 -38
- package/{esm/deps/jsr.io/@std/cache/0.2.2 → script/deps/jsr.io/@std/cache/0.2.3}/memoize.d.ts +18 -10
- package/script/deps/jsr.io/@std/cache/0.2.3/memoize.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/memoize.js +11 -7
- package/script/deps/jsr.io/@std/internal/1.0.13/_os.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/_os.js +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.js +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff.js +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff_str.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff_str.js +3 -3
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/format.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/format.js +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/os.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/os.js +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.js +3 -3
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.d.ts.map +1 -1
- package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.js +1 -1
- package/script/deps/jsr.io/@std/path/1.1.4/basename.js +1 -1
- package/script/deps/jsr.io/@std/path/1.1.4/extname.js +1 -1
- package/script/deps/jsr.io/@std/path/1.1.4/is_absolute.js +1 -1
- package/script/deps/jsr.io/@std/path/1.1.4/join.js +1 -1
- package/script/deps/jsr.io/@std/path/1.1.4/to_file_url.js +1 -1
- package/script/deps/jsr.io/@std/streams/1.1.0/to_array_buffer.d.ts.map +1 -0
- package/script/tl/1_telegram_api.d.ts +251 -5
- package/script/tl/1_telegram_api.d.ts.map +1 -1
- package/script/tl/1_telegram_api.js +271 -11
- package/script/types/1_chat_p.d.ts +2 -0
- package/script/types/1_chat_p.d.ts.map +1 -1
- package/script/types/1_chat_p.js +1 -0
- package/script/types/2_user.d.ts +2 -0
- package/script/types/2_user.d.ts.map +1 -1
- package/script/types/2_user.js +1 -0
- package/script/types/4_poll.d.ts +2 -0
- package/script/types/4_poll.d.ts.map +1 -1
- package/script/types/4_poll.js +1 -0
- package/script/types/7_guest_query.d.ts +28 -0
- package/script/types/7_guest_query.d.ts.map +1 -0
- package/script/types/7_guest_query.js +21 -0
- package/script/types/8_update.d.ts +19 -1
- package/script/types/8_update.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/async/1.2.0/pool.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +0 -188
- package/esm/deps/jsr.io/@std/cache/0.2.2/memoize.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.12/types.js +0 -3
- package/esm/deps/jsr.io/@std/streams/1.0.17/to_array_buffer.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/async/1.2.0/pool.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/cache/0.2.2/memoize.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.12/_os.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/streams/1.0.17/to_array_buffer.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/delay.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/delay.js +0 -0
- /package/esm/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/_serialize_arg_list.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/_os.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff_str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/format.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/os.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/streams/{1.0.17 → 1.1.0}/to_array_buffer.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/streams/{1.0.17 → 1.1.0}/to_array_buffer.js +0 -0
- /package/script/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/delay.d.ts +0 -0
- /package/script/deps/jsr.io/@std/async/{1.2.0 → 1.3.0}/delay.js +0 -0
- /package/script/deps/jsr.io/@std/cache/{0.2.2 → 0.2.3}/_serialize_arg_list.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/_os.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/build_message.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/diff_str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/format.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/os.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/styles.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.12 → 1.0.13}/types.d.ts +0 -0
- /package/script/deps/jsr.io/@std/streams/{1.0.17 → 1.1.0}/to_array_buffer.d.ts +0 -0
- /package/script/deps/jsr.io/@std/streams/{1.0.17 → 1.1.0}/to_array_buffer.js +0 -0
package/{esm/deps/jsr.io/@std/cache/0.2.2 → script/deps/jsr.io/@std/cache/0.2.3}/lru_cache.d.ts
RENAMED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
import type { MemoizationCache } from "./memoize.js";
|
|
2
2
|
export type { MemoizationCache };
|
|
3
|
+
/**
|
|
4
|
+
* The reason an entry was removed from the cache.
|
|
5
|
+
*
|
|
6
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
7
|
+
*
|
|
8
|
+
* - `"evicted"` — removed automatically because the cache exceeded
|
|
9
|
+
* {@linkcode LruCache.prototype.maxSize | maxSize}.
|
|
10
|
+
* - `"deleted"` — removed by an explicit
|
|
11
|
+
* {@linkcode LruCache.prototype.delete | delete()} call.
|
|
12
|
+
* - `"cleared"` — removed by
|
|
13
|
+
* {@linkcode LruCache.prototype.clear | clear()}.
|
|
14
|
+
*/
|
|
15
|
+
export type LruCacheEjectionReason = "evicted" | "deleted" | "cleared";
|
|
16
|
+
/**
|
|
17
|
+
* Options for the {@linkcode LruCache} constructor.
|
|
18
|
+
*
|
|
19
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
20
|
+
*/
|
|
21
|
+
export interface LruCacheOptions<K, V> {
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when an entry is removed, whether by eviction,
|
|
24
|
+
* manual deletion, or clearing the cache. The entry is already removed
|
|
25
|
+
* from the cache when this callback fires. Overwriting an existing key
|
|
26
|
+
* via {@linkcode LruCache.prototype.set | set()} does **not** trigger
|
|
27
|
+
* this callback. The cache is not re-entrant during this callback:
|
|
28
|
+
* calling `set`, `delete`, or `clear` will throw.
|
|
29
|
+
*
|
|
30
|
+
* @param ejectedKey The key of the removed entry.
|
|
31
|
+
* @param ejectedValue The value of the removed entry.
|
|
32
|
+
* @param reason Why the entry was removed.
|
|
33
|
+
*/
|
|
34
|
+
onEject?: (ejectedKey: K, ejectedValue: V, reason: LruCacheEjectionReason) => void;
|
|
35
|
+
}
|
|
3
36
|
/**
|
|
4
37
|
* Least-recently-used cache.
|
|
5
38
|
*
|
|
@@ -8,7 +41,7 @@ export type { MemoizationCache };
|
|
|
8
41
|
* @see {@link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU | Least-recently-used cache}
|
|
9
42
|
*
|
|
10
43
|
* Automatically removes entries above the max size based on when they were
|
|
11
|
-
* last accessed with `get
|
|
44
|
+
* last accessed with `get` or `set`.
|
|
12
45
|
*
|
|
13
46
|
* @typeParam K The type of the cache keys.
|
|
14
47
|
* @typeParam V The type of the cache values.
|
|
@@ -35,32 +68,42 @@ export type { MemoizationCache };
|
|
|
35
68
|
* assert(!cache.has("a"));
|
|
36
69
|
* ```
|
|
37
70
|
*
|
|
38
|
-
* @example Adding
|
|
71
|
+
* @example Adding an onEject callback
|
|
39
72
|
* ```ts
|
|
40
73
|
* import { LruCache } from "@std/cache";
|
|
41
74
|
* import { assertEquals } from "@std/assert";
|
|
42
75
|
*
|
|
43
|
-
* const
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* }
|
|
76
|
+
* const ejected: [string, number, string][] = [];
|
|
77
|
+
* const cache = new LruCache<string, number>(2, {
|
|
78
|
+
* onEject: (key, value, reason) => ejected.push([key, value, reason]),
|
|
79
|
+
* });
|
|
47
80
|
*
|
|
48
|
-
* cache.set(
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* );
|
|
81
|
+
* cache.set("a", 1);
|
|
82
|
+
* cache.set("b", 2);
|
|
83
|
+
* cache.set("c", 3);
|
|
52
84
|
*
|
|
53
|
-
*
|
|
54
|
-
* assertEquals(cache.get("fast-url"), undefined)
|
|
85
|
+
* assertEquals(ejected, [["a", 1, "evicted"]]);
|
|
55
86
|
* ```
|
|
56
87
|
*/
|
|
57
88
|
export declare class LruCache<K, V> extends Map<K, V> implements MemoizationCache<K, V> {
|
|
58
89
|
#private;
|
|
90
|
+
/**
|
|
91
|
+
* Constructs a new `LruCache`.
|
|
92
|
+
*
|
|
93
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
94
|
+
*
|
|
95
|
+
* @param maxSize The maximum number of entries to store in the cache. Must
|
|
96
|
+
* be a positive integer.
|
|
97
|
+
* @param options Additional options.
|
|
98
|
+
*/
|
|
99
|
+
constructor(maxSize: number, options?: LruCacheOptions<K, V>);
|
|
59
100
|
/**
|
|
60
101
|
* The maximum number of entries to store in the cache.
|
|
61
102
|
*
|
|
103
|
+
* @returns The maximum number of entries in the cache.
|
|
104
|
+
*
|
|
62
105
|
* @example Max size
|
|
63
|
-
* ```ts
|
|
106
|
+
* ```ts
|
|
64
107
|
* import { LruCache } from "@std/cache";
|
|
65
108
|
* import { assertEquals } from "@std/assert";
|
|
66
109
|
*
|
|
@@ -68,18 +111,10 @@ export declare class LruCache<K, V> extends Map<K, V> implements MemoizationCach
|
|
|
68
111
|
* assertEquals(cache.maxSize, 100);
|
|
69
112
|
* ```
|
|
70
113
|
*/
|
|
71
|
-
maxSize: number;
|
|
114
|
+
get maxSize(): number;
|
|
72
115
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @param maxSize The maximum number of entries to store in the cache.
|
|
76
|
-
* @param options Additional options.
|
|
77
|
-
*/
|
|
78
|
-
constructor(maxSize: number, options?: {
|
|
79
|
-
onEject: (ejectedKey: K, ejectedValue: V) => void;
|
|
80
|
-
});
|
|
81
|
-
/**
|
|
82
|
-
* Checks whether an element with the specified key exists or not.
|
|
116
|
+
* Checks whether an element with the specified key exists or not. Does
|
|
117
|
+
* **not** update the entry's position in the eviction order.
|
|
83
118
|
*
|
|
84
119
|
* @param key The key to check.
|
|
85
120
|
* @returns `true` if the cache contains the specified key, otherwise `false`.
|
|
@@ -100,7 +135,8 @@ export declare class LruCache<K, V> extends Map<K, V> implements MemoizationCach
|
|
|
100
135
|
* Gets the element with the specified key.
|
|
101
136
|
*
|
|
102
137
|
* @param key The key to get the value for.
|
|
103
|
-
* @returns The value associated with the specified key, or `undefined` if
|
|
138
|
+
* @returns The value associated with the specified key, or `undefined` if
|
|
139
|
+
* the key is not present in the cache.
|
|
104
140
|
*
|
|
105
141
|
* @example Getting a value from the cache
|
|
106
142
|
* ```ts
|
|
@@ -114,6 +150,35 @@ export declare class LruCache<K, V> extends Map<K, V> implements MemoizationCach
|
|
|
114
150
|
* ```
|
|
115
151
|
*/
|
|
116
152
|
get(key: K): V | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* Returns the value associated with the given key, or `undefined` if the
|
|
155
|
+
* key is not present, **without** updating its position in the eviction
|
|
156
|
+
* order.
|
|
157
|
+
*
|
|
158
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
159
|
+
*
|
|
160
|
+
* @param key The key to look up.
|
|
161
|
+
* @returns The value, or `undefined` if not present.
|
|
162
|
+
*
|
|
163
|
+
* @example Peeking at a value without promoting it
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { LruCache } from "@std/cache";
|
|
166
|
+
* import { assertEquals } from "@std/assert";
|
|
167
|
+
*
|
|
168
|
+
* const cache = new LruCache<string, number>(3);
|
|
169
|
+
* cache.set("a", 1);
|
|
170
|
+
* cache.set("b", 2);
|
|
171
|
+
* cache.set("c", 3);
|
|
172
|
+
*
|
|
173
|
+
* // peek does not promote "a"
|
|
174
|
+
* assertEquals(cache.peek("a"), 1);
|
|
175
|
+
*
|
|
176
|
+
* // "a" is still the least recently used and gets evicted
|
|
177
|
+
* cache.set("d", 4);
|
|
178
|
+
* assertEquals(cache.peek("a"), undefined);
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
peek(key: K): V | undefined;
|
|
117
182
|
/**
|
|
118
183
|
* Sets the specified key to the specified value.
|
|
119
184
|
*
|
|
@@ -151,5 +216,24 @@ export declare class LruCache<K, V> extends Map<K, V> implements MemoizationCach
|
|
|
151
216
|
* ```
|
|
152
217
|
*/
|
|
153
218
|
delete(key: K): boolean;
|
|
219
|
+
/**
|
|
220
|
+
* Clears the cache.
|
|
221
|
+
*
|
|
222
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
223
|
+
*
|
|
224
|
+
* @example Usage
|
|
225
|
+
* ```ts
|
|
226
|
+
* import { LruCache } from "@std/cache";
|
|
227
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
228
|
+
*
|
|
229
|
+
* const cache = new LruCache<string, number>(100);
|
|
230
|
+
*
|
|
231
|
+
* cache.set("a", 1);
|
|
232
|
+
* cache.set("b", 2);
|
|
233
|
+
* cache.clear();
|
|
234
|
+
* assertEquals(cache.size, 0);
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
clear(): void;
|
|
154
238
|
}
|
|
155
239
|
//# sourceMappingURL=lru_cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru_cache.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/cache/0.2.3/lru_cache.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC;IACnC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,CACR,UAAU,EAAE,CAAC,EACb,YAAY,EAAE,CAAC,EACf,MAAM,EAAE,sBAAsB,KAC3B,IAAI,CAAC;CACX;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBAAa,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAC1C,YAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC;;IAOjC;;;;;;;;OAQG;gBAED,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAYjC;;;;;;;;;;;;;OAaG;IACH,IAAI,OAAO,IAAI,MAAM,CAEpB;IAsBD;;;;;;;;;;;;;;;;;OAiBG;IACM,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAI7B;;;;;;;;;;;;;;;;;OAiBG;IACM,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAUnC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAI3B;;;;;;;;;;;;;;OAcG;IACM,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAYpC;;;;;;;;;;;;;;;;;;;OAmBG;IACM,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAqBhC;;;;;;;;;;;;;;;;;OAiBG;IACM,KAAK,IAAI,IAAI;CA2BvB"}
|
|
@@ -11,7 +11,7 @@ exports.LruCache = void 0;
|
|
|
11
11
|
* @see {@link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU | Least-recently-used cache}
|
|
12
12
|
*
|
|
13
13
|
* Automatically removes entries above the max size based on when they were
|
|
14
|
-
* last accessed with `get
|
|
14
|
+
* last accessed with `get` or `set`.
|
|
15
15
|
*
|
|
16
16
|
* @typeParam K The type of the cache keys.
|
|
17
17
|
* @typeParam V The type of the cache values.
|
|
@@ -38,31 +38,51 @@ exports.LruCache = void 0;
|
|
|
38
38
|
* assert(!cache.has("a"));
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
41
|
-
* @example Adding
|
|
41
|
+
* @example Adding an onEject callback
|
|
42
42
|
* ```ts
|
|
43
43
|
* import { LruCache } from "@std/cache";
|
|
44
44
|
* import { assertEquals } from "@std/assert";
|
|
45
45
|
*
|
|
46
|
-
* const
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* }
|
|
46
|
+
* const ejected: [string, number, string][] = [];
|
|
47
|
+
* const cache = new LruCache<string, number>(2, {
|
|
48
|
+
* onEject: (key, value, reason) => ejected.push([key, value, reason]),
|
|
49
|
+
* });
|
|
50
50
|
*
|
|
51
|
-
* cache.set(
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* );
|
|
51
|
+
* cache.set("a", 1);
|
|
52
|
+
* cache.set("b", 2);
|
|
53
|
+
* cache.set("c", 3);
|
|
55
54
|
*
|
|
56
|
-
*
|
|
57
|
-
* assertEquals(cache.get("fast-url"), undefined)
|
|
55
|
+
* assertEquals(ejected, [["a", 1, "evicted"]]);
|
|
58
56
|
* ```
|
|
59
57
|
*/
|
|
60
58
|
class LruCache extends Map {
|
|
59
|
+
#maxSize;
|
|
60
|
+
#ejecting = false;
|
|
61
|
+
#eject;
|
|
62
|
+
/**
|
|
63
|
+
* Constructs a new `LruCache`.
|
|
64
|
+
*
|
|
65
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
66
|
+
*
|
|
67
|
+
* @param maxSize The maximum number of entries to store in the cache. Must
|
|
68
|
+
* be a positive integer.
|
|
69
|
+
* @param options Additional options.
|
|
70
|
+
*/
|
|
71
|
+
constructor(maxSize, options) {
|
|
72
|
+
super();
|
|
73
|
+
if (!Number.isInteger(maxSize) || maxSize < 1) {
|
|
74
|
+
throw new RangeError(`Cannot create LruCache: maxSize must be a positive integer: received ${maxSize}`);
|
|
75
|
+
}
|
|
76
|
+
this.#maxSize = maxSize;
|
|
77
|
+
this.#eject = options?.onEject;
|
|
78
|
+
}
|
|
61
79
|
/**
|
|
62
80
|
* The maximum number of entries to store in the cache.
|
|
63
81
|
*
|
|
82
|
+
* @returns The maximum number of entries in the cache.
|
|
83
|
+
*
|
|
64
84
|
* @example Max size
|
|
65
|
-
* ```ts
|
|
85
|
+
* ```ts
|
|
66
86
|
* import { LruCache } from "@std/cache";
|
|
67
87
|
* import { assertEquals } from "@std/assert";
|
|
68
88
|
*
|
|
@@ -70,31 +90,32 @@ class LruCache extends Map {
|
|
|
70
90
|
* assertEquals(cache.maxSize, 100);
|
|
71
91
|
* ```
|
|
72
92
|
*/
|
|
73
|
-
maxSize
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Constructs a new `LruCache`.
|
|
77
|
-
*
|
|
78
|
-
* @param maxSize The maximum number of entries to store in the cache.
|
|
79
|
-
* @param options Additional options.
|
|
80
|
-
*/
|
|
81
|
-
constructor(maxSize, options) {
|
|
82
|
-
super();
|
|
83
|
-
this.maxSize = maxSize;
|
|
84
|
-
this.#eject = options?.onEject ?? (() => { });
|
|
93
|
+
get maxSize() {
|
|
94
|
+
return this.#maxSize;
|
|
85
95
|
}
|
|
86
96
|
#setMostRecentlyUsed(key, value) {
|
|
87
|
-
// delete then re-add to ensure most recently accessed elements are last
|
|
88
97
|
super.delete(key);
|
|
89
98
|
super.set(key, value);
|
|
90
99
|
}
|
|
91
100
|
#pruneToMaxSize() {
|
|
92
|
-
if (this.size
|
|
93
|
-
|
|
101
|
+
if (this.size <= this.#maxSize)
|
|
102
|
+
return;
|
|
103
|
+
const key = this.keys().next().value;
|
|
104
|
+
const value = super.get(key);
|
|
105
|
+
super.delete(key);
|
|
106
|
+
if (this.#eject) {
|
|
107
|
+
this.#ejecting = true;
|
|
108
|
+
try {
|
|
109
|
+
this.#eject(key, value, "evicted");
|
|
110
|
+
}
|
|
111
|
+
finally {
|
|
112
|
+
this.#ejecting = false;
|
|
113
|
+
}
|
|
94
114
|
}
|
|
95
115
|
}
|
|
96
116
|
/**
|
|
97
|
-
* Checks whether an element with the specified key exists or not.
|
|
117
|
+
* Checks whether an element with the specified key exists or not. Does
|
|
118
|
+
* **not** update the entry's position in the eviction order.
|
|
98
119
|
*
|
|
99
120
|
* @param key The key to check.
|
|
100
121
|
* @returns `true` if the cache contains the specified key, otherwise `false`.
|
|
@@ -111,17 +132,14 @@ class LruCache extends Map {
|
|
|
111
132
|
* ```
|
|
112
133
|
*/
|
|
113
134
|
has(key) {
|
|
114
|
-
|
|
115
|
-
if (exists) {
|
|
116
|
-
this.#setMostRecentlyUsed(key, super.get(key));
|
|
117
|
-
}
|
|
118
|
-
return exists;
|
|
135
|
+
return super.has(key);
|
|
119
136
|
}
|
|
120
137
|
/**
|
|
121
138
|
* Gets the element with the specified key.
|
|
122
139
|
*
|
|
123
140
|
* @param key The key to get the value for.
|
|
124
|
-
* @returns The value associated with the specified key, or `undefined` if
|
|
141
|
+
* @returns The value associated with the specified key, or `undefined` if
|
|
142
|
+
* the key is not present in the cache.
|
|
125
143
|
*
|
|
126
144
|
* @example Getting a value from the cache
|
|
127
145
|
* ```ts
|
|
@@ -142,6 +160,37 @@ class LruCache extends Map {
|
|
|
142
160
|
}
|
|
143
161
|
return undefined;
|
|
144
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Returns the value associated with the given key, or `undefined` if the
|
|
165
|
+
* key is not present, **without** updating its position in the eviction
|
|
166
|
+
* order.
|
|
167
|
+
*
|
|
168
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
169
|
+
*
|
|
170
|
+
* @param key The key to look up.
|
|
171
|
+
* @returns The value, or `undefined` if not present.
|
|
172
|
+
*
|
|
173
|
+
* @example Peeking at a value without promoting it
|
|
174
|
+
* ```ts
|
|
175
|
+
* import { LruCache } from "@std/cache";
|
|
176
|
+
* import { assertEquals } from "@std/assert";
|
|
177
|
+
*
|
|
178
|
+
* const cache = new LruCache<string, number>(3);
|
|
179
|
+
* cache.set("a", 1);
|
|
180
|
+
* cache.set("b", 2);
|
|
181
|
+
* cache.set("c", 3);
|
|
182
|
+
*
|
|
183
|
+
* // peek does not promote "a"
|
|
184
|
+
* assertEquals(cache.peek("a"), 1);
|
|
185
|
+
*
|
|
186
|
+
* // "a" is still the least recently used and gets evicted
|
|
187
|
+
* cache.set("d", 4);
|
|
188
|
+
* assertEquals(cache.peek("a"), undefined);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
peek(key) {
|
|
192
|
+
return super.get(key);
|
|
193
|
+
}
|
|
145
194
|
/**
|
|
146
195
|
* Sets the specified key to the specified value.
|
|
147
196
|
*
|
|
@@ -158,6 +207,9 @@ class LruCache extends Map {
|
|
|
158
207
|
* ```
|
|
159
208
|
*/
|
|
160
209
|
set(key, value) {
|
|
210
|
+
if (this.#ejecting) {
|
|
211
|
+
throw new TypeError("Cannot set entry in LruCache: cache is not re-entrant during onEject callbacks");
|
|
212
|
+
}
|
|
161
213
|
this.#setMostRecentlyUsed(key, value);
|
|
162
214
|
this.#pruneToMaxSize();
|
|
163
215
|
return this;
|
|
@@ -183,10 +235,69 @@ class LruCache extends Map {
|
|
|
183
235
|
* ```
|
|
184
236
|
*/
|
|
185
237
|
delete(key) {
|
|
186
|
-
if (
|
|
187
|
-
|
|
238
|
+
if (this.#ejecting) {
|
|
239
|
+
throw new TypeError("Cannot delete entry in LruCache: cache is not re-entrant during onEject callbacks");
|
|
240
|
+
}
|
|
241
|
+
const value = super.get(key);
|
|
242
|
+
const existed = super.delete(key);
|
|
243
|
+
if (!existed)
|
|
244
|
+
return false;
|
|
245
|
+
if (this.#eject) {
|
|
246
|
+
this.#ejecting = true;
|
|
247
|
+
try {
|
|
248
|
+
this.#eject(key, value, "deleted");
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
this.#ejecting = false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Clears the cache.
|
|
258
|
+
*
|
|
259
|
+
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
260
|
+
*
|
|
261
|
+
* @example Usage
|
|
262
|
+
* ```ts
|
|
263
|
+
* import { LruCache } from "@std/cache";
|
|
264
|
+
* import { assertEquals } from "@std/assert/equals";
|
|
265
|
+
*
|
|
266
|
+
* const cache = new LruCache<string, number>(100);
|
|
267
|
+
*
|
|
268
|
+
* cache.set("a", 1);
|
|
269
|
+
* cache.set("b", 2);
|
|
270
|
+
* cache.clear();
|
|
271
|
+
* assertEquals(cache.size, 0);
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
clear() {
|
|
275
|
+
if (this.#ejecting) {
|
|
276
|
+
throw new TypeError("Cannot clear LruCache: cache is not re-entrant during onEject callbacks");
|
|
277
|
+
}
|
|
278
|
+
if (!this.#eject) {
|
|
279
|
+
super.clear();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const entries = [...super.entries()];
|
|
283
|
+
super.clear();
|
|
284
|
+
this.#ejecting = true;
|
|
285
|
+
let error;
|
|
286
|
+
try {
|
|
287
|
+
for (const [key, value] of entries) {
|
|
288
|
+
try {
|
|
289
|
+
this.#eject(key, value, "cleared");
|
|
290
|
+
}
|
|
291
|
+
catch (e) {
|
|
292
|
+
error ??= e;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
finally {
|
|
297
|
+
this.#ejecting = false;
|
|
188
298
|
}
|
|
189
|
-
|
|
299
|
+
if (error !== undefined)
|
|
300
|
+
throw error;
|
|
190
301
|
}
|
|
191
302
|
}
|
|
192
303
|
exports.LruCache = LruCache;
|
package/{esm/deps/jsr.io/@std/cache/0.2.2 → script/deps/jsr.io/@std/cache/0.2.3}/memoize.d.ts
RENAMED
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export interface MemoizationCache<K, V> {
|
|
7
|
+
/** Checks whether a value for the given key exists in the cache. */
|
|
8
|
+
has(key: K): boolean;
|
|
9
|
+
/** Returns the cached value associated with the given key, if present. */
|
|
10
|
+
get(key: K): V | undefined;
|
|
11
|
+
/** Stores a value in the cache under the given key. */
|
|
12
|
+
set(key: K, val: V): unknown;
|
|
13
|
+
/** Removes the value associated with the given key from the cache. */
|
|
14
|
+
delete(key: K): unknown;
|
|
15
|
+
}
|
|
12
16
|
/**
|
|
13
17
|
* The result of a memoized function, as stored in its cache.
|
|
14
18
|
*
|
|
@@ -39,8 +43,9 @@ export type MemoizeOptions<Fn extends (...args: never[]) => unknown, Key, Cache
|
|
|
39
43
|
* {@linkcode Map} object is instantiated upon memoization and used as a cache, with no
|
|
40
44
|
* limit on the number of results to be cached.
|
|
41
45
|
*
|
|
42
|
-
* Alternatively, you can supply
|
|
43
|
-
*
|
|
46
|
+
* Alternatively, you can supply an
|
|
47
|
+
* {@link https://jsr.io/@std/cache/doc/lru-cache/~/LruCache | LruCache}
|
|
48
|
+
* with a specified max size to limit memory usage.
|
|
44
49
|
*/
|
|
45
50
|
cache?: Cache;
|
|
46
51
|
/**
|
|
@@ -84,7 +89,8 @@ export type MemoizeOptions<Fn extends (...args: never[]) => unknown, Key, Cache
|
|
|
84
89
|
* @param fn The function to memoize
|
|
85
90
|
* @param options Options for memoization
|
|
86
91
|
*
|
|
87
|
-
* @returns The memoized function
|
|
92
|
+
* @returns The memoized function, with a `cache` property exposing the
|
|
93
|
+
* underlying cache for inspection or manual invalidation.
|
|
88
94
|
*
|
|
89
95
|
* @example Basic usage
|
|
90
96
|
* ```ts
|
|
@@ -107,5 +113,7 @@ export type MemoizeOptions<Fn extends (...args: never[]) => unknown, Key, Cache
|
|
|
107
113
|
* > avoid this, you can pass a custom `getKey` option or use the memoized
|
|
108
114
|
* > function inside an anonymous callback like `arr.map((x) => func(x))`.
|
|
109
115
|
*/
|
|
110
|
-
export declare function memoize<Fn extends (...args: never[]) => unknown, Key = string, Cache extends MemoizationCache<Key, MemoizationCacheResult<ReturnType<Fn>>> = Map<Key, MemoizationCacheResult<ReturnType<Fn>>>>(fn: Fn, options?: MemoizeOptions<Fn, Key, Cache>): Fn
|
|
116
|
+
export declare function memoize<Fn extends (...args: never[]) => unknown, Key = string, Cache extends MemoizationCache<Key, MemoizationCacheResult<ReturnType<Fn>>> = Map<Key, MemoizationCacheResult<ReturnType<Fn>>>>(fn: Fn, options?: MemoizeOptions<Fn, Key, Cache>): Fn & {
|
|
117
|
+
cache: Cache;
|
|
118
|
+
};
|
|
111
119
|
//# sourceMappingURL=memoize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/cache/0.2.3/memoize.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IACpC,oEAAoE;IACpE,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IACrB,0EAA0E;IAC1E,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3B,uDAAuD;IACvD,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;IAC7B,sEAAsE;IACtE,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAChC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACjC,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG,KAAK,CAAC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CACxB,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxC,GAAG,EACH,KAAK,SAAS,gBAAgB,CAAC,GAAG,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,IACzE;IACF;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,GAAG,CAAC;IACvE;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CACrB,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxC,GAAG,GAAG,MAAM,EACZ,KAAK,SAAS,gBAAgB,CAAC,GAAG,EAAE,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,GACzE,GAAG,CACD,GAAG,EACH,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CACvC,EAEH,EAAE,EAAE,EAAE,EACN,OAAO,CAAC,EAAE,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,GACvC,EAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAkEvB"}
|
|
@@ -15,7 +15,8 @@ const _serialize_arg_list_js_1 = require("./_serialize_arg_list.js");
|
|
|
15
15
|
* @param fn The function to memoize
|
|
16
16
|
* @param options Options for memoization
|
|
17
17
|
*
|
|
18
|
-
* @returns The memoized function
|
|
18
|
+
* @returns The memoized function, with a `cache` property exposing the
|
|
19
|
+
* underlying cache for inspection or manual invalidation.
|
|
19
20
|
*
|
|
20
21
|
* @example Basic usage
|
|
21
22
|
* ```ts
|
|
@@ -39,20 +40,22 @@ const _serialize_arg_list_js_1 = require("./_serialize_arg_list.js");
|
|
|
39
40
|
* > function inside an anonymous callback like `arr.map((x) => func(x))`.
|
|
40
41
|
*/
|
|
41
42
|
function memoize(fn, options) {
|
|
42
|
-
const cache = options?.cache ?? new Map();
|
|
43
|
+
const cache = (options?.cache ?? new Map());
|
|
43
44
|
const getKey = options?.getKey ??
|
|
44
45
|
(0, _serialize_arg_list_js_1._serializeArgList)(cache);
|
|
45
46
|
const errorIsCacheable = options?.errorIsCacheable ?? (() => false);
|
|
46
47
|
const memoized = function (...args) {
|
|
47
48
|
const key = getKey.apply(this, args);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const cached = cache.get(key);
|
|
50
|
+
// `MemoizationCacheResult` is always a truthy object, so `undefined`
|
|
51
|
+
// reliably indicates a cache miss here.
|
|
52
|
+
if (cached !== undefined) {
|
|
53
|
+
switch (cached.kind) {
|
|
51
54
|
case "ok":
|
|
52
55
|
case "promise":
|
|
53
|
-
return
|
|
56
|
+
return cached.value;
|
|
54
57
|
case "error":
|
|
55
|
-
throw
|
|
58
|
+
throw cached.error;
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
try {
|
|
@@ -81,5 +84,6 @@ function memoize(fn, options) {
|
|
|
81
84
|
return Object.defineProperties(memoized, {
|
|
82
85
|
length: { value: fn.length },
|
|
83
86
|
name: { value: fn.name },
|
|
87
|
+
cache: { value: cache },
|
|
84
88
|
});
|
|
85
89
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_os.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/_os.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,IAAI,OAAO,CAUtC"}
|
|
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.checkWindows = checkWindows;
|
|
37
|
-
// Copyright 2018-
|
|
37
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
38
38
|
const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
|
|
39
39
|
function checkWindows() {
|
|
40
40
|
// deno-lint-ignore no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"build_message.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/build_message.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,QAAQ;AAClB;;;GAGG;AACH,UAAU,UAAQ,GACjB,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAWvB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CASrD;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,OAAO,GAAE,mBAAwB,EACjC,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,UAAU,EAAE,OAAO,EACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,KAC1B,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GACrC,MAAM,EAAE,CA8BV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/diff.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEvD,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;CACZ;AAMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAanD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAWvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EACzB,CAAC,EAAE,CAAC,EAAE,EACN,CAAC,EAAE,CAAC,EAAE,EACN,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,WAAW,EACnB,kBAAkB,EAAE,MAAM,GACzB,KAAK,CAAC;IACP,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,CAAC,CAAC;CACV,CAAC,CAgCD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,EAAE,WAAW,EACnB,kBAAkB,EAAE,MAAM,EAC1B,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,aAAa,EACrB,IAAI,CAAC,EAAE,aAAa,GACnB,aAAa,CAsBf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAwEvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff_str.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"diff_str.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/diff_str.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAqB,UAAU,EAAE,MAAM,YAAY,CAAC;AAGhE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAY/C;AAKD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,UAAQ,GAAG,MAAM,EAAE,CAiBnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,EACxB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,GAC3B,UAAU,CAAC,MAAM,CAAC,EAAE,CAetB;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAkDlE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
3
3
|
// This module is browser compatible.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.unescape = unescape;
|
|
@@ -34,7 +34,7 @@ function unescape(string) {
|
|
|
34
34
|
// This does not remove line breaks
|
|
35
35
|
.replaceAll(/\r\n|\r|\n/g, (str) => str === "\r" ? "\\r" : str === "\n" ? "\\n\n" : "\\r\\n\r\n");
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const WHITESPACE_SYMBOLS_REGEXP = /((?:\\[bftv]|[^\S\r\n])+|\\[rn\\]|[()[\]{}'"\r\n]|\b)/;
|
|
38
38
|
/**
|
|
39
39
|
* Tokenizes a string into an array of tokens.
|
|
40
40
|
*
|
|
@@ -54,7 +54,7 @@ const WHITESPACE_SYMBOLS = /((?:\\[bftv]|[^\S\r\n])+|\\[rn\\]|[()[\]{}'"\r\n]|\b
|
|
|
54
54
|
function tokenize(string, wordDiff = false) {
|
|
55
55
|
if (wordDiff) {
|
|
56
56
|
return string
|
|
57
|
-
.split(
|
|
57
|
+
.split(WHITESPACE_SYMBOLS_REGEXP)
|
|
58
58
|
.filter((token) => token);
|
|
59
59
|
}
|
|
60
60
|
const tokens = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/format.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,GAAG,CACtB,CAAC,EAAE,OAAO,EACV,OAAO,EAAE;IACP,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,KACE,MAAM,CAAC;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAmBzC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright 2018-
|
|
2
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
3
3
|
// This module is browser compatible.
|
|
4
4
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
5
|
if (k2 === undefined) k2 = k;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"os.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.
|
|
1
|
+
{"version":3,"file":"os.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/internal/1.0.13/os.ts"],"names":[],"mappings":"AAKA,8CAA8C;AAC9C,eAAO,MAAM,SAAS,EAAE,OAAwB,CAAC"}
|