lib0 0.2.41 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -72
- package/bin/gendocs.js +1 -1
- package/cache.d.ts +50 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +178 -0
- package/cache.test.d.ts +3 -0
- package/cache.test.d.ts.map +1 -0
- package/component.d.ts +4 -1
- package/component.d.ts.map +1 -1
- package/component.js +4 -1
- package/diff.d.ts +5 -0
- package/diff.d.ts.map +1 -1
- package/diff.js +47 -10
- package/diff.test.d.ts +1 -0
- package/diff.test.d.ts.map +1 -1
- package/dist/{broadcastchannel-8a61b21a.cjs → broadcastchannel-7da37795.cjs} +2 -2
- package/dist/{broadcastchannel-8a61b21a.cjs.map → broadcastchannel-7da37795.cjs.map} +1 -1
- package/dist/broadcastchannel.cjs +5 -5
- package/dist/{buffer-ac2cdedf.cjs → buffer-b0dea3b0.cjs} +4 -4
- package/dist/{buffer-ac2cdedf.cjs.map → buffer-b0dea3b0.cjs.map} +1 -1
- package/dist/buffer.cjs +4 -4
- package/dist/cache.cjs +185 -0
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.ts +50 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.test.d.ts +3 -0
- package/dist/cache.test.d.ts.map +1 -0
- package/dist/component.cjs +7 -4
- package/dist/component.cjs.map +1 -1
- package/dist/component.d.ts +4 -1
- package/dist/component.d.ts.map +1 -1
- package/dist/decoding.cjs +4 -4
- package/dist/{diff-75787d87.cjs → diff-233747fa.cjs} +51 -12
- package/dist/diff-233747fa.cjs.map +1 -0
- package/dist/diff.cjs +2 -1
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.d.ts +5 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.test.d.ts +1 -0
- package/dist/diff.test.d.ts.map +1 -1
- package/dist/dom.d.ts.map +1 -1
- package/dist/encoding.cjs +4 -4
- package/dist/{environment-7e2ffaea.cjs → environment-60b83194.cjs} +2 -2
- package/dist/{environment-7e2ffaea.cjs.map → environment-60b83194.cjs.map} +1 -1
- package/dist/environment.cjs +2 -2
- package/dist/{error-55a9a8c8.cjs → error-873c9cbf.cjs} +4 -4
- package/dist/error-873c9cbf.cjs.map +1 -0
- package/dist/error.cjs +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/index.cjs +13 -13
- package/dist/{indexeddb-44227700.cjs → indexeddb-5b4b0e13.cjs} +27 -25
- package/dist/indexeddb-5b4b0e13.cjs.map +1 -0
- package/dist/indexeddb.cjs +3 -3
- package/dist/indexeddb.d.ts +2 -2
- package/dist/indexeddb.d.ts.map +1 -1
- package/dist/isomorphic.cjs +2 -6
- package/dist/isomorphic.cjs.map +1 -1
- package/dist/list.cjs +172 -0
- package/dist/list.cjs.map +1 -0
- package/dist/list.d.ts +33 -0
- package/dist/list.d.ts.map +1 -0
- package/dist/list.test.d.ts +4 -0
- package/dist/list.test.d.ts.map +1 -0
- package/dist/{logging-7cc36806.cjs → logging-f6d41f58.cjs} +2 -2
- package/dist/{logging-7cc36806.cjs.map → logging-f6d41f58.cjs.map} +1 -1
- package/dist/logging.cjs +3 -3
- package/dist/{number-24f1eabe.cjs → number-e62129bc.cjs} +5 -2
- package/dist/number-e62129bc.cjs.map +1 -0
- package/dist/number.cjs +2 -1
- package/dist/number.cjs.map +1 -1
- package/dist/number.d.ts +1 -0
- package/dist/number.d.ts.map +1 -1
- package/dist/observable.cjs +1 -1
- package/dist/{prng-695120cc.cjs → prng-25602bac.cjs} +3 -3
- package/dist/{prng-695120cc.cjs.map → prng-25602bac.cjs.map} +1 -1
- package/dist/prng.cjs +5 -5
- package/dist/{promise-f0a086b2.cjs → promise-1a9fe712.cjs} +10 -1
- package/dist/{promise-f0a086b2.cjs.map → promise-1a9fe712.cjs.map} +1 -1
- package/dist/promise.cjs +2 -1
- package/dist/promise.cjs.map +1 -1
- package/dist/promise.d.ts +1 -0
- package/dist/promise.d.ts.map +1 -1
- package/dist/queue.cjs +3 -0
- package/dist/queue.cjs.map +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.test.d.ts.map +1 -1
- package/dist/set-b596ef38.cjs +49 -0
- package/dist/set-b596ef38.cjs.map +1 -0
- package/dist/set.cjs +3 -1
- package/dist/set.cjs.map +1 -1
- package/dist/set.d.ts +2 -0
- package/dist/set.d.ts.map +1 -1
- package/dist/set.test.d.ts +2 -0
- package/dist/set.test.d.ts.map +1 -1
- package/dist/{string-f3c3d805.cjs → string-ad04f734.cjs} +12 -2
- package/dist/{string-f3c3d805.cjs.map → string-ad04f734.cjs.map} +1 -1
- package/dist/string.cjs +3 -4
- package/dist/string.cjs.map +1 -1
- package/dist/string.d.ts +1 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/string.test.d.ts +1 -0
- package/dist/string.test.d.ts.map +1 -1
- package/dist/test.cjs +750 -125
- package/dist/test.cjs.map +1 -1
- package/dist/test.js +751 -126
- package/dist/test.js.map +1 -1
- package/dist/testing.cjs +12 -9
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/{websocket-bfe7f545.cjs → websocket-08bd4c7b.cjs} +1 -1
- package/dist/{websocket-bfe7f545.cjs.map → websocket-08bd4c7b.cjs.map} +1 -1
- package/dist/websocket.cjs +2 -2
- package/dist/websocket.d.ts +1 -1
- package/dist/websocket.d.ts.map +1 -1
- package/dom.d.ts.map +1 -1
- package/error.d.ts.map +1 -1
- package/error.js +3 -3
- package/indexeddb.d.ts +2 -2
- package/indexeddb.d.ts.map +1 -1
- package/indexeddb.js +25 -23
- package/list.d.ts +33 -0
- package/list.d.ts.map +1 -0
- package/list.js +155 -0
- package/list.test.d.ts +4 -0
- package/list.test.d.ts.map +1 -0
- package/number.d.ts +1 -0
- package/number.d.ts.map +1 -1
- package/number.js +1 -0
- package/package.json +16 -4
- package/promise.d.ts +1 -0
- package/promise.d.ts.map +1 -1
- package/promise.js +7 -0
- package/queue.d.ts.map +1 -1
- package/queue.js +3 -0
- package/queue.test.d.ts.map +1 -1
- package/set.d.ts +2 -0
- package/set.d.ts.map +1 -1
- package/set.js +18 -0
- package/set.test.d.ts +2 -0
- package/set.test.d.ts.map +1 -1
- package/string.d.ts +1 -0
- package/string.d.ts.map +1 -1
- package/string.js +8 -0
- package/string.test.d.ts +1 -0
- package/string.test.d.ts.map +1 -1
- package/test.js +7 -1
- package/testing.d.ts.map +1 -1
- package/testing.js +5 -2
- package/websocket.d.ts +1 -1
- package/websocket.d.ts.map +1 -1
- package/dist/diff-75787d87.cjs.map +0 -1
- package/dist/error-55a9a8c8.cjs.map +0 -1
- package/dist/indexeddb-44227700.cjs.map +0 -1
- package/dist/number-24f1eabe.cjs.map +0 -1
- package/dist/set-7ae96d21.cjs +0 -27
- package/dist/set-7ae96d21.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ import module from 'lib0/[module].js'
|
|
|
75
75
|
## Modules
|
|
76
76
|
|
|
77
77
|
<details><summary><b>[lib0/array]</b> Utility module to work with Arrays.</summary>
|
|
78
|
-
<pre>import * as array from 'lib0/array
|
|
78
|
+
<pre>import * as array from 'lib0/array'</pre>
|
|
79
79
|
<dl>
|
|
80
80
|
<b><code>array.last(arr: Array<L>): L</code></b><br>
|
|
81
81
|
<dd><p>Return the last element of an array. The element must exist</p></dd>
|
|
@@ -94,7 +94,7 @@ import module from 'lib0/[module].js'
|
|
|
94
94
|
</dl>
|
|
95
95
|
</details>
|
|
96
96
|
<details><summary><b>[lib0/binary]</b> Binary data constants.</summary>
|
|
97
|
-
<pre>import * as binary from 'lib0/binary
|
|
97
|
+
<pre>import * as binary from 'lib0/binary'</pre>
|
|
98
98
|
<dl>
|
|
99
99
|
<b><code>binary.BIT1: number</code></b><br>
|
|
100
100
|
<dd><p>n-th bit activated.</p></dd>
|
|
@@ -166,7 +166,7 @@ import module from 'lib0/[module].js'
|
|
|
166
166
|
</dl>
|
|
167
167
|
</details>
|
|
168
168
|
<details><summary><b>[lib0/broadcastchannel]</b> Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.</summary>
|
|
169
|
-
<pre>import * as broadcastchannel from 'lib0/broadcastchannel
|
|
169
|
+
<pre>import * as broadcastchannel from 'lib0/broadcastchannel'</pre>
|
|
170
170
|
|
|
171
171
|
<pre class="prettyprint source lang-js"><code>// In browser window A:
|
|
172
172
|
broadcastchannel.subscribe('my events', data => console.log(data))
|
|
@@ -185,7 +185,7 @@ broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from t
|
|
|
185
185
|
</dl>
|
|
186
186
|
</details>
|
|
187
187
|
<details><summary><b>[lib0/buffer]</b> Utility functions to work with buffers (Uint8Array).</summary>
|
|
188
|
-
<pre>import * as buffer from 'lib0/buffer
|
|
188
|
+
<pre>import * as buffer from 'lib0/buffer'</pre>
|
|
189
189
|
<dl>
|
|
190
190
|
<b><code>buffer.createUint8ArrayFromLen(len: number)</code></b><br>
|
|
191
191
|
<b><code>buffer.createUint8ArrayViewFromArrayBuffer(buffer: ArrayBuffer, byteOffset: number, length: number)</code></b><br>
|
|
@@ -203,12 +203,26 @@ See encoding.writeAny for more information.</p></dd>
|
|
|
203
203
|
<dd><p>Decode an any-encoded value.</p></dd>
|
|
204
204
|
</dl>
|
|
205
205
|
</details>
|
|
206
|
+
<details><summary><b>[lib0/cached-map]</b> An implementation of a map which has keys that expire.</summary>
|
|
207
|
+
<pre>import * as cached-map from 'lib0/cache'</pre>
|
|
208
|
+
<dl>
|
|
209
|
+
<b><code>new cached-map.Cache(timeout: number)</code></b><br>
|
|
210
|
+
<b><code>cached-map.removeStale(cache: module:cache.Cache<K, V>): number</code></b><br>
|
|
211
|
+
<b><code>cached-map.set(cache: module:cache.Cache<K, V>, key: K, value: V)</code></b><br>
|
|
212
|
+
<b><code>cached-map.get(cache: module:cache.Cache<K, V>, key: K): V | undefined</code></b><br>
|
|
213
|
+
<b><code>cached-map.getAsync(cache: module:cache.Cache<K, V>, key: K): V | Promise<V> | undefined</code></b><br>
|
|
214
|
+
<dd><p>Works well in conjunktion with setIfUndefined which has an async init function.
|
|
215
|
+
Using getAsync & setIfUndefined ensures that the init function is only called once.</p></dd>
|
|
216
|
+
<b><code>cached-map.setIfUndefined(cache: module:cache.Cache<K, V>, key: K, init: function():Promise<V>): Promise<V> | V</code></b><br>
|
|
217
|
+
<b><code>cached-map.create(timeout: number)</code></b><br>
|
|
218
|
+
</dl>
|
|
219
|
+
</details>
|
|
206
220
|
<details><summary><b>[lib0/component]</b> Web components.</summary>
|
|
207
|
-
<pre>import * as component from 'lib0/component
|
|
221
|
+
<pre>import * as component from 'lib0/component'</pre>
|
|
208
222
|
<dl>
|
|
209
|
-
<b><code>component.registry</code></b><br>
|
|
223
|
+
<b><code>component.registry: CustomElementRegistry</code></b><br>
|
|
210
224
|
<b><code>component.define(name: string, constr: any, opts: ElementDefinitionOptions)</code></b><br>
|
|
211
|
-
<b><code>component.whenDefined(name: string): Promise<
|
|
225
|
+
<b><code>component.whenDefined(name: string): Promise<CustomElementConstructor></code></b><br>
|
|
212
226
|
<b><code>new component.Lib0Component(state: S)</code></b><br>
|
|
213
227
|
<b><code>component.Lib0Component#state: S|null</code></b><br>
|
|
214
228
|
<b><code>component.Lib0Component#setState(state: S, forceStateUpdate: boolean)</code></b><br>
|
|
@@ -220,13 +234,13 @@ See encoding.writeAny for more information.</p></dd>
|
|
|
220
234
|
</dl>
|
|
221
235
|
</details>
|
|
222
236
|
<details><summary><b>[lib0/conditions]</b> Often used conditions.</summary>
|
|
223
|
-
<pre>import * as conditions from 'lib0/conditions
|
|
237
|
+
<pre>import * as conditions from 'lib0/conditions'</pre>
|
|
224
238
|
<dl>
|
|
225
239
|
<b><code>conditions.undefinedToNull</code></b><br>
|
|
226
240
|
</dl>
|
|
227
241
|
</details>
|
|
228
242
|
<details><summary><b>[lib0/decoding]</b> Efficient schema-less binary decoding with support for variable length encoding.</summary>
|
|
229
|
-
<pre>import * as decoding from 'lib0/decoding
|
|
243
|
+
<pre>import * as decoding from 'lib0/decoding'</pre>
|
|
230
244
|
|
|
231
245
|
<p>Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.</p>
|
|
232
246
|
<p>Encodes numbers in little-endian order (least to most significant byte order)
|
|
@@ -376,7 +390,7 @@ For effiency reasons we apply a maximum of 10000 characters at once.</p></dd>
|
|
|
376
390
|
</dl>
|
|
377
391
|
</details>
|
|
378
392
|
<details><summary><b>[lib0/diff]</b> Efficient diffs.</summary>
|
|
379
|
-
<pre>import * as diff from 'lib0/diff
|
|
393
|
+
<pre>import * as diff from 'lib0/diff'</pre>
|
|
380
394
|
<dl>
|
|
381
395
|
<b><code>diff.simpleDiffString(a: string, b: string): module:diff~SimpleDiff<string></code></b><br>
|
|
382
396
|
<dd><p>Create a diff between two strings. This diff implementation is highly
|
|
@@ -387,10 +401,12 @@ efficient, but not very sophisticated.</p></dd>
|
|
|
387
401
|
efficient, but not very sophisticated.</p>
|
|
388
402
|
<p>Note: This is basically the same function as above. Another function was created so that the runtime
|
|
389
403
|
can better optimize these function calls.</p></dd>
|
|
404
|
+
<b><code>diff.simpleDiffStringWithCursor(a: string, b: string, cursor: number)</code></b><br>
|
|
405
|
+
<dd><p>Diff text and try to diff at the current cursor position.</p></dd>
|
|
390
406
|
</dl>
|
|
391
407
|
</details>
|
|
392
408
|
<details><summary><b>[lib0/dom]</b> Utility module to work with the DOM.</summary>
|
|
393
|
-
<pre>import * as dom from 'lib0/dom
|
|
409
|
+
<pre>import * as dom from 'lib0/dom'</pre>
|
|
394
410
|
<dl>
|
|
395
411
|
<b><code>dom.doc: Document</code></b><br>
|
|
396
412
|
<b><code>dom.createElement</code></b><br>
|
|
@@ -434,7 +450,7 @@ can better optimize these function calls.</p></dd>
|
|
|
434
450
|
</dl>
|
|
435
451
|
</details>
|
|
436
452
|
<details><summary><b>[lib0/encoding]</b> Efficient schema-less binary encoding with support for variable length encoding.</summary>
|
|
437
|
-
<pre>import * as encoding from 'lib0/encoding
|
|
453
|
+
<pre>import * as encoding from 'lib0/encoding'</pre>
|
|
438
454
|
|
|
439
455
|
<p>Use [lib0/encoding] with [lib0/decoding]. Every encoding function has a corresponding decoding function.</p>
|
|
440
456
|
<p>Encodes numbers in little-endian order (least to most significant byte order)
|
|
@@ -677,7 +693,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
677
693
|
</dl>
|
|
678
694
|
</details>
|
|
679
695
|
<details><summary><b>[lib0/map]</b> Isomorphic module to work access the environment (query params, env variables).</summary>
|
|
680
|
-
<pre>import * as map from 'lib0/environment
|
|
696
|
+
<pre>import * as map from 'lib0/environment'</pre>
|
|
681
697
|
<dl>
|
|
682
698
|
<b><code>map.isNode</code></b><br>
|
|
683
699
|
<b><code>map.isBrowser</code></b><br>
|
|
@@ -691,15 +707,15 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
691
707
|
</dl>
|
|
692
708
|
</details>
|
|
693
709
|
<details><summary><b>[lib0/error]</b> Error helpers.</summary>
|
|
694
|
-
<pre>import * as error from 'lib0/error
|
|
710
|
+
<pre>import * as error from 'lib0/error'</pre>
|
|
695
711
|
<dl>
|
|
696
|
-
<b><code>error.create</code></b><br>
|
|
697
|
-
<b><code>error.methodUnimplemented</code></b><br>
|
|
698
|
-
<b><code>error.unexpectedCase</code></b><br>
|
|
712
|
+
<b><code>error.create(s: string): Error</code></b><br>
|
|
713
|
+
<b><code>error.methodUnimplemented(): never</code></b><br>
|
|
714
|
+
<b><code>error.unexpectedCase(): never</code></b><br>
|
|
699
715
|
</dl>
|
|
700
716
|
</details>
|
|
701
717
|
<details><summary><b>[lib0/eventloop]</b> Utility module to work with EcmaScript's event loop.</summary>
|
|
702
|
-
<pre>import * as eventloop from 'lib0/eventloop
|
|
718
|
+
<pre>import * as eventloop from 'lib0/eventloop'</pre>
|
|
703
719
|
<dl>
|
|
704
720
|
<b><code>eventloop.enqueue(f: function():void)</code></b><br>
|
|
705
721
|
<b><code>eventloop#destroy()</code></b><br>
|
|
@@ -713,7 +729,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
713
729
|
</dl>
|
|
714
730
|
</details>
|
|
715
731
|
<details><summary><b>[lib0/function]</b> Common functions and function call helpers.</summary>
|
|
716
|
-
<pre>import * as function from 'lib0/function
|
|
732
|
+
<pre>import * as function from 'lib0/function'</pre>
|
|
717
733
|
<dl>
|
|
718
734
|
<b><code>function.callAll(fs: Array<function>, args: Array<any>)</code></b><br>
|
|
719
735
|
<dd><p>Calls all functions in <code>fs</code> with args. Only throws after all functions were called.</p></dd>
|
|
@@ -726,47 +742,51 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
726
742
|
</dl>
|
|
727
743
|
</details>
|
|
728
744
|
<details><summary><b>[lib0/lib0]</b> Experimental method to import lib0.</summary>
|
|
729
|
-
<pre>import * as lib0 from 'lib0/index
|
|
745
|
+
<pre>import * as lib0 from 'lib0/index'</pre>
|
|
730
746
|
|
|
731
747
|
<p>Not recommended if the module bundler doesn't support dead code elimination.</p>
|
|
732
748
|
<dl>
|
|
733
749
|
</dl>
|
|
734
750
|
</details>
|
|
735
|
-
<details><summary><b>[lib0/
|
|
736
|
-
<pre>import * as
|
|
751
|
+
<details><summary><b>[lib0/indexeddb]</b> Helpers to work with IndexedDB.</summary>
|
|
752
|
+
<pre>import * as indexeddb from 'lib0/indexeddb'</pre>
|
|
737
753
|
<dl>
|
|
738
|
-
<b><code>
|
|
739
|
-
<
|
|
740
|
-
<b><code>
|
|
741
|
-
<b><code>
|
|
742
|
-
<b><code>
|
|
743
|
-
<b><code>
|
|
744
|
-
<b><code>
|
|
745
|
-
<b><code>
|
|
746
|
-
<b><code>
|
|
747
|
-
<b><code>
|
|
748
|
-
<b><code>
|
|
749
|
-
<b><code>
|
|
750
|
-
<b><code>
|
|
751
|
-
<b><code>
|
|
752
|
-
<b><code>
|
|
753
|
-
<b><code>
|
|
754
|
-
<b><code>
|
|
755
|
-
<b><code>
|
|
756
|
-
<b><code>
|
|
757
|
-
<
|
|
758
|
-
<b><code>
|
|
759
|
-
<
|
|
760
|
-
<b><code>
|
|
754
|
+
<b><code>indexeddb.rtop(request: IDBRequest): Promise<any></code></b><br>
|
|
755
|
+
<dd><p>IDB Request to Promise transformer</p></dd>
|
|
756
|
+
<b><code>indexeddb.openDB(name: string, initDB: function(IDBDatabase):any): Promise<IDBDatabase></code></b><br>
|
|
757
|
+
<b><code>indexeddb.deleteDB(name: string)</code></b><br>
|
|
758
|
+
<b><code>indexeddb.createStores(db: IDBDatabase, definitions: Array<Array<string>|Array<string|IDBObjectStoreParameters|undefined>>)</code></b><br>
|
|
759
|
+
<b><code>indexeddb.transact(db: IDBDatabase, stores: Array<string>, access: "readwrite"|"readonly"): Array<IDBObjectStore></code></b><br>
|
|
760
|
+
<b><code>indexeddb.count(store: IDBObjectStore, range: IDBKeyRange): Promise<number></code></b><br>
|
|
761
|
+
<b><code>indexeddb.get(store: IDBObjectStore, key: String | number | ArrayBuffer | Date | Array<any> ): Promise<String | number | ArrayBuffer | Date | Array<any>></code></b><br>
|
|
762
|
+
<b><code>indexeddb.del(store: IDBObjectStore, key: String | number | ArrayBuffer | Date | IDBKeyRange | Array<any> )</code></b><br>
|
|
763
|
+
<b><code>indexeddb.put(store: IDBObjectStore, item: String | number | ArrayBuffer | Date | boolean, key: String | number | ArrayBuffer | Date | Array<any>)</code></b><br>
|
|
764
|
+
<b><code>indexeddb.add(store: IDBObjectStore, item: String|number|ArrayBuffer|Date|boolean, key: String|number|ArrayBuffer|Date|Array.<any>): Promise<any></code></b><br>
|
|
765
|
+
<b><code>indexeddb.addAutoKey(store: IDBObjectStore, item: String|number|ArrayBuffer|Date): Promise<number></code></b><br>
|
|
766
|
+
<b><code>indexeddb.getAll(store: IDBObjectStore, range: IDBKeyRange): Promise<Array<any>></code></b><br>
|
|
767
|
+
<b><code>indexeddb.getAllKeys(store: IDBObjectStore, range: IDBKeyRange): Promise<Array<any>></code></b><br>
|
|
768
|
+
<b><code>indexeddb.queryFirst(store: IDBObjectStore, query: IDBKeyRange|null, direction: 'next'|'prev'|'nextunique'|'prevunique'): Promise<any></code></b><br>
|
|
769
|
+
<b><code>indexeddb.getLastKey(store: IDBObjectStore, range: IDBKeyRange?): Promise<any></code></b><br>
|
|
770
|
+
<b><code>indexeddb.getFirstKey(store: IDBObjectStore, range: IDBKeyRange?): Promise<any></code></b><br>
|
|
771
|
+
<b><code>indexeddb.getAllKeysValues(store: IDBObjectStore, range: IDBKeyRange): Promise<Array<KeyValuePair>></code></b><br>
|
|
772
|
+
<b><code>indexeddb.iterate(store: IDBObjectStore, keyrange: IDBKeyRange|null, f: function(any,any):void|boolean, direction: 'next'|'prev'|'nextunique'|'prevunique')</code></b><br>
|
|
773
|
+
<dd><p>Iterate on keys and values</p></dd>
|
|
774
|
+
<b><code>indexeddb.iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange|null, f: function(any):void|boolean, direction: 'next'|'prev'|'nextunique'|'prevunique')</code></b><br>
|
|
775
|
+
<dd><p>Iterate on the keys (no values)</p></dd>
|
|
776
|
+
<b><code>indexeddb.getStore(t: IDBTransaction, store: String)IDBObjectStore</code></b><br>
|
|
777
|
+
<dd><p>Open store from transaction</p></dd>
|
|
778
|
+
<b><code>indexeddb.createIDBKeyRangeBound(lower: any, upper: any, lowerOpen: boolean, upperOpen: boolean)</code></b><br>
|
|
779
|
+
<b><code>indexeddb.createIDBKeyRangeUpperBound(upper: any, upperOpen: boolean)</code></b><br>
|
|
780
|
+
<b><code>indexeddb.createIDBKeyRangeLowerBound(lower: any, lowerOpen: boolean)</code></b><br>
|
|
761
781
|
</dl>
|
|
762
782
|
</details>
|
|
763
783
|
<details><summary><b>[lib0/isomorphic]</b> Isomorphic library exports from isomorphic.js.</summary>
|
|
764
|
-
<pre>import * as isomorphic from 'lib0/isomorphic
|
|
784
|
+
<pre>import * as isomorphic from 'lib0/isomorphic'</pre>
|
|
765
785
|
<dl>
|
|
766
786
|
</dl>
|
|
767
787
|
</details>
|
|
768
788
|
<details><summary><b>[lib0/iterator]</b> Utility module to create and manipulate Iterators.</summary>
|
|
769
|
-
<pre>import * as iterator from 'lib0/iterator
|
|
789
|
+
<pre>import * as iterator from 'lib0/iterator'</pre>
|
|
770
790
|
<dl>
|
|
771
791
|
<b><code>iterator.mapIterator(iterator: Iterator<T>, f: function(T):R): IterableIterator<R></code></b><br>
|
|
772
792
|
<b><code>iterator.createIterator(next: function():IteratorResult<T>): IterableIterator<T></code></b><br>
|
|
@@ -775,7 +795,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
775
795
|
</dl>
|
|
776
796
|
</details>
|
|
777
797
|
<details><summary><b>[lib0/json]</b> JSON utility functions.</summary>
|
|
778
|
-
<pre>import * as json from 'lib0/json
|
|
798
|
+
<pre>import * as json from 'lib0/json'</pre>
|
|
779
799
|
<dl>
|
|
780
800
|
<b><code>json.stringify(object: any): string</code></b><br>
|
|
781
801
|
<dd><p>Transform JavaScript object to JSON.</p></dd>
|
|
@@ -783,8 +803,38 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
783
803
|
<dd><p>Parse JSON object.</p></dd>
|
|
784
804
|
</dl>
|
|
785
805
|
</details>
|
|
806
|
+
<details><summary><b>[lib0/list]</b> </summary>
|
|
807
|
+
<pre>import * as list from 'lib0/list'</pre>
|
|
808
|
+
<dl>
|
|
809
|
+
<b><code>new e#ListNode()</code></b><br>
|
|
810
|
+
<b><code>e#next: this|null</code></b><br>
|
|
811
|
+
<b><code>e#prev: this|null</code></b><br>
|
|
812
|
+
<b><code>new st()</code></b><br>
|
|
813
|
+
<b><code>art: N | null</code></b><br>
|
|
814
|
+
<b><code>d: N | null</code></b><br>
|
|
815
|
+
<b><code>(): module:list.List<N></code></b><br>
|
|
816
|
+
<b><code>()</code></b><br>
|
|
817
|
+
<b><code>(queue: module:list.List<N>)</code></b><br>
|
|
818
|
+
<b><code>()</code></b><br>
|
|
819
|
+
<b><code>ode(queue: module:list.List<N>, node: N)</code></b><br>
|
|
820
|
+
<dd><p>Remove a single node from the queue. Only works with Queues that operate on Doubly-linked lists of nodes.</p></dd>
|
|
821
|
+
<b><code>ode()</code></b><br>
|
|
822
|
+
<b><code>etween(queue: module:list.List<N>, left: N| null, right: N| null, node: N)</code></b><br>
|
|
823
|
+
<b><code>etween()</code></b><br>
|
|
824
|
+
<b><code>(queue: module:list.List<N>, n: N)</code></b><br>
|
|
825
|
+
<b><code>()</code></b><br>
|
|
826
|
+
<b><code>nt(queue: module:list.List<N>, n: N)</code></b><br>
|
|
827
|
+
<b><code>nt()</code></b><br>
|
|
828
|
+
<b><code>t(list: module:list.List<N>): N| null</code></b><br>
|
|
829
|
+
<b><code>t()</code></b><br>
|
|
830
|
+
<b><code>(list: module:list.List<N>): N| null</code></b><br>
|
|
831
|
+
<b><code>()</code></b><br>
|
|
832
|
+
<b><code>(list: module:list.List<N>, f: function(N):M): Array<M></code></b><br>
|
|
833
|
+
<b><code>()</code></b><br>
|
|
834
|
+
</dl>
|
|
835
|
+
</details>
|
|
786
836
|
<details><summary><b>[lib0/logging]</b> Isomorphic logging module with support for colors!</summary>
|
|
787
|
-
<pre>import * as logging from 'lib0/logging
|
|
837
|
+
<pre>import * as logging from 'lib0/logging'</pre>
|
|
788
838
|
<dl>
|
|
789
839
|
<b><code>logging.BOLD</code></b><br>
|
|
790
840
|
<b><code>logging.UNBOLD</code></b><br>
|
|
@@ -821,7 +871,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
821
871
|
</dl>
|
|
822
872
|
</details>
|
|
823
873
|
<details><summary><b>[lib0/map]</b> Utility module to work with key-value stores.</summary>
|
|
824
|
-
<pre>import * as map from 'lib0/map
|
|
874
|
+
<pre>import * as map from 'lib0/map'</pre>
|
|
825
875
|
<dl>
|
|
826
876
|
<b><code>map.create(): Map<any, any></code></b><br>
|
|
827
877
|
<dd><p>Creates a new Map instance.</p></dd>
|
|
@@ -841,7 +891,7 @@ listeners.add(listener)
|
|
|
841
891
|
</dl>
|
|
842
892
|
</details>
|
|
843
893
|
<details><summary><b>[lib0/math]</b> Common Math expressions.</summary>
|
|
844
|
-
<pre>import * as math from 'lib0/math
|
|
894
|
+
<pre>import * as math from 'lib0/math'</pre>
|
|
845
895
|
<dl>
|
|
846
896
|
<b><code>math.floor</code></b><br>
|
|
847
897
|
<b><code>math.ceil</code></b><br>
|
|
@@ -864,7 +914,7 @@ listeners.add(listener)
|
|
|
864
914
|
</dl>
|
|
865
915
|
</details>
|
|
866
916
|
<details><summary><b>[lib0/metric]</b> Utility module to convert metric values.</summary>
|
|
867
|
-
<pre>import * as metric from 'lib0/metric
|
|
917
|
+
<pre>import * as metric from 'lib0/metric'</pre>
|
|
868
918
|
<dl>
|
|
869
919
|
<b><code>metric.yotta</code></b><br>
|
|
870
920
|
<b><code>metric.zetta</code></b><br>
|
|
@@ -891,7 +941,7 @@ listeners.add(listener)
|
|
|
891
941
|
</dl>
|
|
892
942
|
</details>
|
|
893
943
|
<details><summary><b>[lib0/mutex]</b> Mutual exclude for JavaScript.</summary>
|
|
894
|
-
<pre>import * as mutex from 'lib0/mutex
|
|
944
|
+
<pre>import * as mutex from 'lib0/mutex'</pre>
|
|
895
945
|
<dl>
|
|
896
946
|
<b><code>mutex.createMutex(): mutex</code></b><br>
|
|
897
947
|
<dd><p>Creates a mutual exclude function with the following property:</p>
|
|
@@ -906,7 +956,7 @@ mutex(() => {
|
|
|
906
956
|
</dl>
|
|
907
957
|
</details>
|
|
908
958
|
<details><summary><b>[lib0/number]</b> </summary>
|
|
909
|
-
<pre>import * as number from 'lib0/number
|
|
959
|
+
<pre>import * as number from 'lib0/number'</pre>
|
|
910
960
|
<dl>
|
|
911
961
|
<b><code>number.MAX_SAFE_INTEGER</code></b><br>
|
|
912
962
|
<b><code>number.MIN_SAFE_INTEGER</code></b><br>
|
|
@@ -914,10 +964,11 @@ mutex(() => {
|
|
|
914
964
|
<b><code>number.HIGHEST_INT32: number</code></b><br>
|
|
915
965
|
<b><code>number.isInteger</code></b><br>
|
|
916
966
|
<b><code>number.isNaN</code></b><br>
|
|
967
|
+
<b><code>number.parseInt</code></b><br>
|
|
917
968
|
</dl>
|
|
918
969
|
</details>
|
|
919
970
|
<details><summary><b>[lib0/object]</b> Utility functions for working with EcmaScript objects.</summary>
|
|
920
|
-
<pre>import * as object from 'lib0/object
|
|
971
|
+
<pre>import * as object from 'lib0/object'</pre>
|
|
921
972
|
<dl>
|
|
922
973
|
<b><code>object.create(): Object<string,any></code></b><br>
|
|
923
974
|
<b><code>object.assign</code></b><br>
|
|
@@ -934,7 +985,7 @@ mutex(() => {
|
|
|
934
985
|
</dl>
|
|
935
986
|
</details>
|
|
936
987
|
<details><summary><b>[lib0/observable]</b> Observable class prototype.</summary>
|
|
937
|
-
<pre>import * as observable from 'lib0/observable
|
|
988
|
+
<pre>import * as observable from 'lib0/observable'</pre>
|
|
938
989
|
<dl>
|
|
939
990
|
<b><code>new observable.Observable()</code></b><br>
|
|
940
991
|
<dd><p>Handles named events.</p></dd>
|
|
@@ -954,7 +1005,7 @@ specified name will receive the event.</p></dd>
|
|
|
954
1005
|
</dl>
|
|
955
1006
|
</details>
|
|
956
1007
|
<details><summary><b>[lib0/pair]</b> Working with value pairs.</summary>
|
|
957
|
-
<pre>import * as pair from 'lib0/pair
|
|
1008
|
+
<pre>import * as pair from 'lib0/pair'</pre>
|
|
958
1009
|
<dl>
|
|
959
1010
|
<b><code>new pair.Pair(left: L, right: R)</code></b><br>
|
|
960
1011
|
<b><code>pair.create(left: L, right: R): module:pair.Pair<L,R></code></b><br>
|
|
@@ -964,7 +1015,7 @@ specified name will receive the event.</p></dd>
|
|
|
964
1015
|
</dl>
|
|
965
1016
|
</details>
|
|
966
1017
|
<details><summary><b>[lib0/prng]</b> Fast Pseudo Random Number Generators.</summary>
|
|
967
|
-
<pre>import * as prng from 'lib0/prng
|
|
1018
|
+
<pre>import * as prng from 'lib0/prng'</pre>
|
|
968
1019
|
|
|
969
1020
|
<p>Given a seed a PRNG generates a sequence of numbers that cannot be reasonably predicted.
|
|
970
1021
|
Two PRNGs must generate the same random sequence of numbers if given the same seed.</p>
|
|
@@ -1002,7 +1053,7 @@ But there are more PRNGs available in ./PRNG/.</p></dd>
|
|
|
1002
1053
|
</dl>
|
|
1003
1054
|
</details>
|
|
1004
1055
|
<details><summary><b>[lib0/promise]</b> Utility helpers to work with promises.</summary>
|
|
1005
|
-
<pre>import * as promise from 'lib0/promise
|
|
1056
|
+
<pre>import * as promise from 'lib0/promise'</pre>
|
|
1006
1057
|
<dl>
|
|
1007
1058
|
<b><code>promise.create(f: function(PromiseResolve<T>,function(Error):void):any): Promise<T></code></b><br>
|
|
1008
1059
|
<b><code>promise.createEmpty(f: function(function():void,function(Error):void):void): Promise<void></code></b><br>
|
|
@@ -1010,6 +1061,7 @@ But there are more PRNGs available in ./PRNG/.</p></dd>
|
|
|
1010
1061
|
<dd><p><code>Promise.all</code> wait for all promises in the array to resolve and return the result</p></dd>
|
|
1011
1062
|
<b><code>promise.reject(reason: Error): Promise<never></code></b><br>
|
|
1012
1063
|
<b><code>promise.resolve(res: T|void): Promise<T|void></code></b><br>
|
|
1064
|
+
<b><code>promise.resolveWith(res: T): Promise<T></code></b><br>
|
|
1013
1065
|
<b><code>promise.until(timeout: number, check: function():boolean, intervalResolution: number): Promise<void></code></b><br>
|
|
1014
1066
|
<b><code>promise.wait(timeout: number): Promise<undefined></code></b><br>
|
|
1015
1067
|
<b><code>promise.isPromise(p: any): boolean</code></b><br>
|
|
@@ -1019,7 +1071,7 @@ library has some insane environment where global Promise objects are overwritten
|
|
|
1019
1071
|
</dl>
|
|
1020
1072
|
</details>
|
|
1021
1073
|
<details><summary><b>[lib0/queue]</b> </summary>
|
|
1022
|
-
<pre>import * as queue from 'lib0/queue
|
|
1074
|
+
<pre>import * as queue from 'lib0/queue'</pre>
|
|
1023
1075
|
<dl>
|
|
1024
1076
|
<b><code>new de#QueueNode()</code></b><br>
|
|
1025
1077
|
<b><code>de#next: module:queue.QueueNode|null</code></b><br>
|
|
@@ -1037,7 +1089,7 @@ library has some insane environment where global Promise objects are overwritten
|
|
|
1037
1089
|
</dl>
|
|
1038
1090
|
</details>
|
|
1039
1091
|
<details><summary><b>[lib0/random]</b> Isomorphic module for true random numbers / buffers / uuids.</summary>
|
|
1040
|
-
<pre>import * as random from 'lib0/random
|
|
1092
|
+
<pre>import * as random from 'lib0/random'</pre>
|
|
1041
1093
|
|
|
1042
1094
|
<p>Attention: falls back to Math.random if the browser does not support crypto.</p>
|
|
1043
1095
|
<dl>
|
|
@@ -1048,14 +1100,16 @@ library has some insane environment where global Promise objects are overwritten
|
|
|
1048
1100
|
</dl>
|
|
1049
1101
|
</details>
|
|
1050
1102
|
<details><summary><b>[lib0/set]</b> Utility module to work with sets.</summary>
|
|
1051
|
-
<pre>import * as set from 'lib0/set
|
|
1103
|
+
<pre>import * as set from 'lib0/set'</pre>
|
|
1052
1104
|
<dl>
|
|
1053
1105
|
<b><code>set.create</code></b><br>
|
|
1054
1106
|
<b><code>set.toArray(set: Set<T>): Array<T></code></b><br>
|
|
1107
|
+
<b><code>set.first(set: Set<T>): T</code></b><br>
|
|
1108
|
+
<b><code>set.from(entries: Iterable<T>): Set<T></code></b><br>
|
|
1055
1109
|
</dl>
|
|
1056
1110
|
</details>
|
|
1057
1111
|
<details><summary><b>[lib0/sort]</b> Efficient sort implementations.</summary>
|
|
1058
|
-
<pre>import * as sort from 'lib0/sort
|
|
1112
|
+
<pre>import * as sort from 'lib0/sort'</pre>
|
|
1059
1113
|
|
|
1060
1114
|
<p>Note: These sort implementations were created to compare different sorting algorithms in JavaScript.
|
|
1061
1115
|
Don't use them if you don't know what you are doing. Native Array.sort is almost always a better choice.</p>
|
|
@@ -1069,14 +1123,14 @@ integrate this algorithm.</p>
|
|
|
1069
1123
|
</dl>
|
|
1070
1124
|
</details>
|
|
1071
1125
|
<details><summary><b>[lib0/statistics]</b> Utility helpers for generating statistics.</summary>
|
|
1072
|
-
<pre>import * as statistics from 'lib0/statistics
|
|
1126
|
+
<pre>import * as statistics from 'lib0/statistics'</pre>
|
|
1073
1127
|
<dl>
|
|
1074
1128
|
<b><code>statistics.median(arr: Array<number>): number</code></b><br>
|
|
1075
1129
|
<b><code>statistics.average(arr: Array<number>): number</code></b><br>
|
|
1076
1130
|
</dl>
|
|
1077
1131
|
</details>
|
|
1078
1132
|
<details><summary><b>[lib0/storage]</b> Isomorphic variable storage.</summary>
|
|
1079
|
-
<pre>import * as storage from 'lib0/storage
|
|
1133
|
+
<pre>import * as storage from 'lib0/storage'</pre>
|
|
1080
1134
|
|
|
1081
1135
|
<p>Uses LocalStorage in the browser and falls back to in-memory storage.</p>
|
|
1082
1136
|
<dl>
|
|
@@ -1087,7 +1141,7 @@ integrate this algorithm.</p>
|
|
|
1087
1141
|
</dl>
|
|
1088
1142
|
</details>
|
|
1089
1143
|
<details><summary><b>[lib0/string]</b> Utility module to work with strings.</summary>
|
|
1090
|
-
<pre>import * as string from 'lib0/string
|
|
1144
|
+
<pre>import * as string from 'lib0/string'</pre>
|
|
1091
1145
|
<dl>
|
|
1092
1146
|
<b><code>string.fromCharCode</code></b><br>
|
|
1093
1147
|
<b><code>string.fromCodePoint</code></b><br>
|
|
@@ -1098,10 +1152,11 @@ integrate this algorithm.</p>
|
|
|
1098
1152
|
<b><code>string.utf8TextEncoder</code></b><br>
|
|
1099
1153
|
<b><code>string.encodeUtf8</code></b><br>
|
|
1100
1154
|
<b><code>string.decodeUtf8</code></b><br>
|
|
1155
|
+
<b><code>string.splice(str: string, index: number, remove: number, insert: string)</code></b><br>
|
|
1101
1156
|
</dl>
|
|
1102
1157
|
</details>
|
|
1103
1158
|
<details><summary><b>[lib0/symbol]</b> Utility module to work with EcmaScript Symbols.</summary>
|
|
1104
|
-
<pre>import * as symbol from 'lib0/symbol
|
|
1159
|
+
<pre>import * as symbol from 'lib0/symbol'</pre>
|
|
1105
1160
|
<dl>
|
|
1106
1161
|
<b><code>symbol.create(): Symbol</code></b><br>
|
|
1107
1162
|
<dd><p>Return fresh symbol.</p></dd>
|
|
@@ -1109,7 +1164,7 @@ integrate this algorithm.</p>
|
|
|
1109
1164
|
</dl>
|
|
1110
1165
|
</details>
|
|
1111
1166
|
<details><summary><b>[lib0/testing]</b> Testing framework with support for generating tests.</summary>
|
|
1112
|
-
<pre>import * as testing from 'lib0/testing
|
|
1167
|
+
<pre>import * as testing from 'lib0/testing'</pre>
|
|
1113
1168
|
|
|
1114
1169
|
<pre class="prettyprint source lang-js"><code>// test.js template for creating a test executable
|
|
1115
1170
|
import { runTests } from 'lib0/testing.js'
|
|
@@ -1227,7 +1282,7 @@ export const testMyFirstTest = tc => {
|
|
|
1227
1282
|
</dl>
|
|
1228
1283
|
</details>
|
|
1229
1284
|
<details><summary><b>[lib0/time]</b> Utility module to work with time.</summary>
|
|
1230
|
-
<pre>import * as time from 'lib0/time
|
|
1285
|
+
<pre>import * as time from 'lib0/time'</pre>
|
|
1231
1286
|
<dl>
|
|
1232
1287
|
<b><code>time.getDate(): Date</code></b><br>
|
|
1233
1288
|
<dd><p>Return current time.</p></dd>
|
|
@@ -1238,7 +1293,7 @@ export const testMyFirstTest = tc => {
|
|
|
1238
1293
|
</dl>
|
|
1239
1294
|
</details>
|
|
1240
1295
|
<details><summary><b>[lib0/tree]</b> Red-black-tree implementation.</summary>
|
|
1241
|
-
<pre>import * as tree from 'lib0/tree
|
|
1296
|
+
<pre>import * as tree from 'lib0/tree'</pre>
|
|
1242
1297
|
<dl>
|
|
1243
1298
|
<b><code>new tree.Tree()</code></b><br>
|
|
1244
1299
|
<dd><p>This is a Red Black Tree implementation</p></dd>
|
|
@@ -1257,7 +1312,7 @@ export const testMyFirstTest = tc => {
|
|
|
1257
1312
|
</dl>
|
|
1258
1313
|
</details>
|
|
1259
1314
|
<details><summary><b>[lib0/url]</b> Utility module to work with urls.</summary>
|
|
1260
|
-
<pre>import * as url from 'lib0/url
|
|
1315
|
+
<pre>import * as url from 'lib0/url'</pre>
|
|
1261
1316
|
<dl>
|
|
1262
1317
|
<b><code>url.decodeQueryParams(url: string): Object<string,string></code></b><br>
|
|
1263
1318
|
<dd><p>Parse query parameters from an url.</p></dd>
|
|
@@ -1265,7 +1320,7 @@ export const testMyFirstTest = tc => {
|
|
|
1265
1320
|
</dl>
|
|
1266
1321
|
</details>
|
|
1267
1322
|
<details><summary><b>[lib0/websocket]</b> Tiny websocket connection handler.</summary>
|
|
1268
|
-
<pre>import * as websocket from 'lib0/websocket
|
|
1323
|
+
<pre>import * as websocket from 'lib0/websocket'</pre>
|
|
1269
1324
|
|
|
1270
1325
|
<p>Implements exponential backoff reconnects, ping/pong, and a nice event system using [lib0/observable].</p>
|
|
1271
1326
|
<dl>
|
package/bin/gendocs.js
CHANGED
|
@@ -39,7 +39,7 @@ jsdoc.explain({
|
|
|
39
39
|
const descHead = desc ? desc[1] : ''
|
|
40
40
|
const descRest = desc ? desc[2] : ''
|
|
41
41
|
strBuilder.push(`<details><summary><b>[lib0/${mod.name}]</b> ${descHead}</summary>`)
|
|
42
|
-
strBuilder.push(`<pre>import * as ${mod.name} from 'lib0/${fileName}'</pre>`)
|
|
42
|
+
strBuilder.push(`<pre>import * as ${mod.name} from 'lib0/${fileName.slice(0, -3)}'</pre>`)
|
|
43
43
|
if (descRest.length > 0) {
|
|
44
44
|
strBuilder.push(descRest)
|
|
45
45
|
}
|
package/cache.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template K, V
|
|
3
|
+
*/
|
|
4
|
+
export class Cache<K, V> {
|
|
5
|
+
/**
|
|
6
|
+
* @param {number} timeout
|
|
7
|
+
*/
|
|
8
|
+
constructor(timeout: number);
|
|
9
|
+
timeout: number;
|
|
10
|
+
/**
|
|
11
|
+
* @type list.List<Entry<K, V>>
|
|
12
|
+
*/
|
|
13
|
+
_q: list.List<Entry<K, V>>;
|
|
14
|
+
/**
|
|
15
|
+
* @type {Map<K, Entry<K, V>>}
|
|
16
|
+
*/
|
|
17
|
+
_map: Map<K, Entry<K, V>>;
|
|
18
|
+
}
|
|
19
|
+
export function removeStale<K, V>(cache: Cache<K, V>): number;
|
|
20
|
+
export function set<K, V>(cache: Cache<K, V>, key: K, value: V): void;
|
|
21
|
+
export function get<K, V>(cache: Cache<K, V>, key: K): V | undefined;
|
|
22
|
+
export function getAsync<K, V>(cache: Cache<K, V>, key: K): V | Promise<V> | undefined;
|
|
23
|
+
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>): V | Promise<V>;
|
|
24
|
+
export function create(timeout: number): Cache<any, any>;
|
|
25
|
+
import * as list from "./list.js";
|
|
26
|
+
/**
|
|
27
|
+
* @template K, V
|
|
28
|
+
*
|
|
29
|
+
* @implements {list.ListNode}
|
|
30
|
+
*/
|
|
31
|
+
declare class Entry<K, V> implements list.ListNode {
|
|
32
|
+
/**
|
|
33
|
+
* @param {K} key
|
|
34
|
+
* @param {V | Promise<V>} val
|
|
35
|
+
*/
|
|
36
|
+
constructor(key: K, val: V | Promise<V>);
|
|
37
|
+
/**
|
|
38
|
+
* @type {this | null}
|
|
39
|
+
*/
|
|
40
|
+
prev: Entry<K, V> | null;
|
|
41
|
+
/**
|
|
42
|
+
* @type {this | null}
|
|
43
|
+
*/
|
|
44
|
+
next: Entry<K, V> | null;
|
|
45
|
+
created: number;
|
|
46
|
+
val: V | Promise<V>;
|
|
47
|
+
key: K;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=cache.d.ts.map
|
package/cache.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["cache.js"],"names":[],"mappings":"AAsCA;;GAEG;AACH;IACE;;OAEG;IACH,qBAFW,MAAM,EAYhB;IATC,gBAAsB;IACtB;;OAEG;IACH,IAFS,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAER;IACvB;;OAEG;IACH,MAFU,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAEL;CAE3B;AAQM,uDAFK,MAAM,CAUjB;AASM,sEAcN;AA4BM,qEAGN;AAYM,uFAGN;AAUM,yGAqBN;AAKM,gCAFI,MAAM,mBAEkC;;AApKnD;;;;GAIG;AACH,qCAFgB,IAAI,CAAC,QAAQ;IAG3B;;;OAGG;IACH,iBAHW,CAAC,OACD,CAAC,GAAG,QAAQ,CAAC,CAAC,EAcxB;IAXC;;OAEG;IACH,yBAAgB;IAChB;;OAEG;IACH,yBAAgB;IAChB,gBAAiC;IACjC,oBAAc;IACd,OAAc;CAEjB"}
|