lib0 0.2.42 → 0.2.45
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 +128 -72
- package/bin/gendocs.js +1 -1
- package/cache.d.ts +51 -0
- package/cache.d.ts.map +1 -0
- package/cache.js +197 -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 +205 -0
- package/dist/cache.cjs.map +1 -0
- package/dist/cache.d.ts +51 -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 +779 -125
- package/dist/test.cjs.map +1 -1
- package/dist/test.js +780 -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 +15 -3
- 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,27 @@ 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/cache]</b> An implementation of a map which has keys that expire.</summary>
|
|
207
|
+
<pre>import * as cache from 'lib0/cache'</pre>
|
|
208
|
+
<dl>
|
|
209
|
+
<b><code>new cache.Cache(timeout: number)</code></b><br>
|
|
210
|
+
<b><code>cache.removeStale(cache: module:cache.Cache<K, V>): number</code></b><br>
|
|
211
|
+
<b><code>cache.set(cache: module:cache.Cache<K, V>, key: K, value: V)</code></b><br>
|
|
212
|
+
<b><code>cache.get(cache: module:cache.Cache<K, V>, key: K): V | undefined</code></b><br>
|
|
213
|
+
<b><code>cache.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>cache.remove(cache: module:cache.Cache<K, V>, key: K)</code></b><br>
|
|
217
|
+
<b><code>cache.setIfUndefined(cache: module:cache.Cache<K, V>, key: K, init: function():Promise<V>, removeNull: boolean): Promise<V> | V</code></b><br>
|
|
218
|
+
<b><code>cache.create(timeout: number)</code></b><br>
|
|
219
|
+
</dl>
|
|
220
|
+
</details>
|
|
206
221
|
<details><summary><b>[lib0/component]</b> Web components.</summary>
|
|
207
|
-
<pre>import * as component from 'lib0/component
|
|
222
|
+
<pre>import * as component from 'lib0/component'</pre>
|
|
208
223
|
<dl>
|
|
209
|
-
<b><code>component.registry</code></b><br>
|
|
224
|
+
<b><code>component.registry: CustomElementRegistry</code></b><br>
|
|
210
225
|
<b><code>component.define(name: string, constr: any, opts: ElementDefinitionOptions)</code></b><br>
|
|
211
|
-
<b><code>component.whenDefined(name: string): Promise<
|
|
226
|
+
<b><code>component.whenDefined(name: string): Promise<CustomElementConstructor></code></b><br>
|
|
212
227
|
<b><code>new component.Lib0Component(state: S)</code></b><br>
|
|
213
228
|
<b><code>component.Lib0Component#state: S|null</code></b><br>
|
|
214
229
|
<b><code>component.Lib0Component#setState(state: S, forceStateUpdate: boolean)</code></b><br>
|
|
@@ -220,13 +235,13 @@ See encoding.writeAny for more information.</p></dd>
|
|
|
220
235
|
</dl>
|
|
221
236
|
</details>
|
|
222
237
|
<details><summary><b>[lib0/conditions]</b> Often used conditions.</summary>
|
|
223
|
-
<pre>import * as conditions from 'lib0/conditions
|
|
238
|
+
<pre>import * as conditions from 'lib0/conditions'</pre>
|
|
224
239
|
<dl>
|
|
225
240
|
<b><code>conditions.undefinedToNull</code></b><br>
|
|
226
241
|
</dl>
|
|
227
242
|
</details>
|
|
228
243
|
<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
|
|
244
|
+
<pre>import * as decoding from 'lib0/decoding'</pre>
|
|
230
245
|
|
|
231
246
|
<p>Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.</p>
|
|
232
247
|
<p>Encodes numbers in little-endian order (least to most significant byte order)
|
|
@@ -376,7 +391,7 @@ For effiency reasons we apply a maximum of 10000 characters at once.</p></dd>
|
|
|
376
391
|
</dl>
|
|
377
392
|
</details>
|
|
378
393
|
<details><summary><b>[lib0/diff]</b> Efficient diffs.</summary>
|
|
379
|
-
<pre>import * as diff from 'lib0/diff
|
|
394
|
+
<pre>import * as diff from 'lib0/diff'</pre>
|
|
380
395
|
<dl>
|
|
381
396
|
<b><code>diff.simpleDiffString(a: string, b: string): module:diff~SimpleDiff<string></code></b><br>
|
|
382
397
|
<dd><p>Create a diff between two strings. This diff implementation is highly
|
|
@@ -387,10 +402,12 @@ efficient, but not very sophisticated.</p></dd>
|
|
|
387
402
|
efficient, but not very sophisticated.</p>
|
|
388
403
|
<p>Note: This is basically the same function as above. Another function was created so that the runtime
|
|
389
404
|
can better optimize these function calls.</p></dd>
|
|
405
|
+
<b><code>diff.simpleDiffStringWithCursor(a: string, b: string, cursor: number)</code></b><br>
|
|
406
|
+
<dd><p>Diff text and try to diff at the current cursor position.</p></dd>
|
|
390
407
|
</dl>
|
|
391
408
|
</details>
|
|
392
409
|
<details><summary><b>[lib0/dom]</b> Utility module to work with the DOM.</summary>
|
|
393
|
-
<pre>import * as dom from 'lib0/dom
|
|
410
|
+
<pre>import * as dom from 'lib0/dom'</pre>
|
|
394
411
|
<dl>
|
|
395
412
|
<b><code>dom.doc: Document</code></b><br>
|
|
396
413
|
<b><code>dom.createElement</code></b><br>
|
|
@@ -434,7 +451,7 @@ can better optimize these function calls.</p></dd>
|
|
|
434
451
|
</dl>
|
|
435
452
|
</details>
|
|
436
453
|
<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
|
|
454
|
+
<pre>import * as encoding from 'lib0/encoding'</pre>
|
|
438
455
|
|
|
439
456
|
<p>Use [lib0/encoding] with [lib0/decoding]. Every encoding function has a corresponding decoding function.</p>
|
|
440
457
|
<p>Encodes numbers in little-endian order (least to most significant byte order)
|
|
@@ -677,7 +694,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
677
694
|
</dl>
|
|
678
695
|
</details>
|
|
679
696
|
<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
|
|
697
|
+
<pre>import * as map from 'lib0/environment'</pre>
|
|
681
698
|
<dl>
|
|
682
699
|
<b><code>map.isNode</code></b><br>
|
|
683
700
|
<b><code>map.isBrowser</code></b><br>
|
|
@@ -691,15 +708,15 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
691
708
|
</dl>
|
|
692
709
|
</details>
|
|
693
710
|
<details><summary><b>[lib0/error]</b> Error helpers.</summary>
|
|
694
|
-
<pre>import * as error from 'lib0/error
|
|
711
|
+
<pre>import * as error from 'lib0/error'</pre>
|
|
695
712
|
<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>
|
|
713
|
+
<b><code>error.create(s: string): Error</code></b><br>
|
|
714
|
+
<b><code>error.methodUnimplemented(): never</code></b><br>
|
|
715
|
+
<b><code>error.unexpectedCase(): never</code></b><br>
|
|
699
716
|
</dl>
|
|
700
717
|
</details>
|
|
701
718
|
<details><summary><b>[lib0/eventloop]</b> Utility module to work with EcmaScript's event loop.</summary>
|
|
702
|
-
<pre>import * as eventloop from 'lib0/eventloop
|
|
719
|
+
<pre>import * as eventloop from 'lib0/eventloop'</pre>
|
|
703
720
|
<dl>
|
|
704
721
|
<b><code>eventloop.enqueue(f: function():void)</code></b><br>
|
|
705
722
|
<b><code>eventloop#destroy()</code></b><br>
|
|
@@ -713,7 +730,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
713
730
|
</dl>
|
|
714
731
|
</details>
|
|
715
732
|
<details><summary><b>[lib0/function]</b> Common functions and function call helpers.</summary>
|
|
716
|
-
<pre>import * as function from 'lib0/function
|
|
733
|
+
<pre>import * as function from 'lib0/function'</pre>
|
|
717
734
|
<dl>
|
|
718
735
|
<b><code>function.callAll(fs: Array<function>, args: Array<any>)</code></b><br>
|
|
719
736
|
<dd><p>Calls all functions in <code>fs</code> with args. Only throws after all functions were called.</p></dd>
|
|
@@ -726,47 +743,51 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
726
743
|
</dl>
|
|
727
744
|
</details>
|
|
728
745
|
<details><summary><b>[lib0/lib0]</b> Experimental method to import lib0.</summary>
|
|
729
|
-
<pre>import * as lib0 from 'lib0/index
|
|
746
|
+
<pre>import * as lib0 from 'lib0/index'</pre>
|
|
730
747
|
|
|
731
748
|
<p>Not recommended if the module bundler doesn't support dead code elimination.</p>
|
|
732
749
|
<dl>
|
|
733
750
|
</dl>
|
|
734
751
|
</details>
|
|
735
|
-
<details><summary><b>[lib0/
|
|
736
|
-
<pre>import * as
|
|
752
|
+
<details><summary><b>[lib0/indexeddb]</b> Helpers to work with IndexedDB.</summary>
|
|
753
|
+
<pre>import * as indexeddb from 'lib0/indexeddb'</pre>
|
|
737
754
|
<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>
|
|
755
|
+
<b><code>indexeddb.rtop(request: IDBRequest): Promise<any></code></b><br>
|
|
756
|
+
<dd><p>IDB Request to Promise transformer</p></dd>
|
|
757
|
+
<b><code>indexeddb.openDB(name: string, initDB: function(IDBDatabase):any): Promise<IDBDatabase></code></b><br>
|
|
758
|
+
<b><code>indexeddb.deleteDB(name: string)</code></b><br>
|
|
759
|
+
<b><code>indexeddb.createStores(db: IDBDatabase, definitions: Array<Array<string>|Array<string|IDBObjectStoreParameters|undefined>>)</code></b><br>
|
|
760
|
+
<b><code>indexeddb.transact(db: IDBDatabase, stores: Array<string>, access: "readwrite"|"readonly"): Array<IDBObjectStore></code></b><br>
|
|
761
|
+
<b><code>indexeddb.count(store: IDBObjectStore, range: IDBKeyRange): Promise<number></code></b><br>
|
|
762
|
+
<b><code>indexeddb.get(store: IDBObjectStore, key: String | number | ArrayBuffer | Date | Array<any> ): Promise<String | number | ArrayBuffer | Date | Array<any>></code></b><br>
|
|
763
|
+
<b><code>indexeddb.del(store: IDBObjectStore, key: String | number | ArrayBuffer | Date | IDBKeyRange | Array<any> )</code></b><br>
|
|
764
|
+
<b><code>indexeddb.put(store: IDBObjectStore, item: String | number | ArrayBuffer | Date | boolean, key: String | number | ArrayBuffer | Date | Array<any>)</code></b><br>
|
|
765
|
+
<b><code>indexeddb.add(store: IDBObjectStore, item: String|number|ArrayBuffer|Date|boolean, key: String|number|ArrayBuffer|Date|Array.<any>): Promise<any></code></b><br>
|
|
766
|
+
<b><code>indexeddb.addAutoKey(store: IDBObjectStore, item: String|number|ArrayBuffer|Date): Promise<number></code></b><br>
|
|
767
|
+
<b><code>indexeddb.getAll(store: IDBObjectStore, range: IDBKeyRange): Promise<Array<any>></code></b><br>
|
|
768
|
+
<b><code>indexeddb.getAllKeys(store: IDBObjectStore, range: IDBKeyRange): Promise<Array<any>></code></b><br>
|
|
769
|
+
<b><code>indexeddb.queryFirst(store: IDBObjectStore, query: IDBKeyRange|null, direction: 'next'|'prev'|'nextunique'|'prevunique'): Promise<any></code></b><br>
|
|
770
|
+
<b><code>indexeddb.getLastKey(store: IDBObjectStore, range: IDBKeyRange?): Promise<any></code></b><br>
|
|
771
|
+
<b><code>indexeddb.getFirstKey(store: IDBObjectStore, range: IDBKeyRange?): Promise<any></code></b><br>
|
|
772
|
+
<b><code>indexeddb.getAllKeysValues(store: IDBObjectStore, range: IDBKeyRange): Promise<Array<KeyValuePair>></code></b><br>
|
|
773
|
+
<b><code>indexeddb.iterate(store: IDBObjectStore, keyrange: IDBKeyRange|null, f: function(any,any):void|boolean, direction: 'next'|'prev'|'nextunique'|'prevunique')</code></b><br>
|
|
774
|
+
<dd><p>Iterate on keys and values</p></dd>
|
|
775
|
+
<b><code>indexeddb.iterateKeys(store: IDBObjectStore, keyrange: IDBKeyRange|null, f: function(any):void|boolean, direction: 'next'|'prev'|'nextunique'|'prevunique')</code></b><br>
|
|
776
|
+
<dd><p>Iterate on the keys (no values)</p></dd>
|
|
777
|
+
<b><code>indexeddb.getStore(t: IDBTransaction, store: String)IDBObjectStore</code></b><br>
|
|
778
|
+
<dd><p>Open store from transaction</p></dd>
|
|
779
|
+
<b><code>indexeddb.createIDBKeyRangeBound(lower: any, upper: any, lowerOpen: boolean, upperOpen: boolean)</code></b><br>
|
|
780
|
+
<b><code>indexeddb.createIDBKeyRangeUpperBound(upper: any, upperOpen: boolean)</code></b><br>
|
|
781
|
+
<b><code>indexeddb.createIDBKeyRangeLowerBound(lower: any, lowerOpen: boolean)</code></b><br>
|
|
761
782
|
</dl>
|
|
762
783
|
</details>
|
|
763
784
|
<details><summary><b>[lib0/isomorphic]</b> Isomorphic library exports from isomorphic.js.</summary>
|
|
764
|
-
<pre>import * as isomorphic from 'lib0/isomorphic
|
|
785
|
+
<pre>import * as isomorphic from 'lib0/isomorphic'</pre>
|
|
765
786
|
<dl>
|
|
766
787
|
</dl>
|
|
767
788
|
</details>
|
|
768
789
|
<details><summary><b>[lib0/iterator]</b> Utility module to create and manipulate Iterators.</summary>
|
|
769
|
-
<pre>import * as iterator from 'lib0/iterator
|
|
790
|
+
<pre>import * as iterator from 'lib0/iterator'</pre>
|
|
770
791
|
<dl>
|
|
771
792
|
<b><code>iterator.mapIterator(iterator: Iterator<T>, f: function(T):R): IterableIterator<R></code></b><br>
|
|
772
793
|
<b><code>iterator.createIterator(next: function():IteratorResult<T>): IterableIterator<T></code></b><br>
|
|
@@ -775,7 +796,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
775
796
|
</dl>
|
|
776
797
|
</details>
|
|
777
798
|
<details><summary><b>[lib0/json]</b> JSON utility functions.</summary>
|
|
778
|
-
<pre>import * as json from 'lib0/json
|
|
799
|
+
<pre>import * as json from 'lib0/json'</pre>
|
|
779
800
|
<dl>
|
|
780
801
|
<b><code>json.stringify(object: any): string</code></b><br>
|
|
781
802
|
<dd><p>Transform JavaScript object to JSON.</p></dd>
|
|
@@ -783,8 +804,38 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
783
804
|
<dd><p>Parse JSON object.</p></dd>
|
|
784
805
|
</dl>
|
|
785
806
|
</details>
|
|
807
|
+
<details><summary><b>[lib0/list]</b> </summary>
|
|
808
|
+
<pre>import * as list from 'lib0/list'</pre>
|
|
809
|
+
<dl>
|
|
810
|
+
<b><code>new e#ListNode()</code></b><br>
|
|
811
|
+
<b><code>e#next: this|null</code></b><br>
|
|
812
|
+
<b><code>e#prev: this|null</code></b><br>
|
|
813
|
+
<b><code>new st()</code></b><br>
|
|
814
|
+
<b><code>art: N | null</code></b><br>
|
|
815
|
+
<b><code>d: N | null</code></b><br>
|
|
816
|
+
<b><code>(): module:list.List<N></code></b><br>
|
|
817
|
+
<b><code>()</code></b><br>
|
|
818
|
+
<b><code>(queue: module:list.List<N>)</code></b><br>
|
|
819
|
+
<b><code>()</code></b><br>
|
|
820
|
+
<b><code>ode(queue: module:list.List<N>, node: N)</code></b><br>
|
|
821
|
+
<dd><p>Remove a single node from the queue. Only works with Queues that operate on Doubly-linked lists of nodes.</p></dd>
|
|
822
|
+
<b><code>ode()</code></b><br>
|
|
823
|
+
<b><code>etween(queue: module:list.List<N>, left: N| null, right: N| null, node: N)</code></b><br>
|
|
824
|
+
<b><code>etween()</code></b><br>
|
|
825
|
+
<b><code>(queue: module:list.List<N>, n: N)</code></b><br>
|
|
826
|
+
<b><code>()</code></b><br>
|
|
827
|
+
<b><code>nt(queue: module:list.List<N>, n: N)</code></b><br>
|
|
828
|
+
<b><code>nt()</code></b><br>
|
|
829
|
+
<b><code>t(list: module:list.List<N>): N| null</code></b><br>
|
|
830
|
+
<b><code>t()</code></b><br>
|
|
831
|
+
<b><code>(list: module:list.List<N>): N| null</code></b><br>
|
|
832
|
+
<b><code>()</code></b><br>
|
|
833
|
+
<b><code>(list: module:list.List<N>, f: function(N):M): Array<M></code></b><br>
|
|
834
|
+
<b><code>()</code></b><br>
|
|
835
|
+
</dl>
|
|
836
|
+
</details>
|
|
786
837
|
<details><summary><b>[lib0/logging]</b> Isomorphic logging module with support for colors!</summary>
|
|
787
|
-
<pre>import * as logging from 'lib0/logging
|
|
838
|
+
<pre>import * as logging from 'lib0/logging'</pre>
|
|
788
839
|
<dl>
|
|
789
840
|
<b><code>logging.BOLD</code></b><br>
|
|
790
841
|
<b><code>logging.UNBOLD</code></b><br>
|
|
@@ -821,7 +872,7 @@ In practice, when decoding several million small strings, the GC will kick in mo
|
|
|
821
872
|
</dl>
|
|
822
873
|
</details>
|
|
823
874
|
<details><summary><b>[lib0/map]</b> Utility module to work with key-value stores.</summary>
|
|
824
|
-
<pre>import * as map from 'lib0/map
|
|
875
|
+
<pre>import * as map from 'lib0/map'</pre>
|
|
825
876
|
<dl>
|
|
826
877
|
<b><code>map.create(): Map<any, any></code></b><br>
|
|
827
878
|
<dd><p>Creates a new Map instance.</p></dd>
|
|
@@ -841,7 +892,7 @@ listeners.add(listener)
|
|
|
841
892
|
</dl>
|
|
842
893
|
</details>
|
|
843
894
|
<details><summary><b>[lib0/math]</b> Common Math expressions.</summary>
|
|
844
|
-
<pre>import * as math from 'lib0/math
|
|
895
|
+
<pre>import * as math from 'lib0/math'</pre>
|
|
845
896
|
<dl>
|
|
846
897
|
<b><code>math.floor</code></b><br>
|
|
847
898
|
<b><code>math.ceil</code></b><br>
|
|
@@ -864,7 +915,7 @@ listeners.add(listener)
|
|
|
864
915
|
</dl>
|
|
865
916
|
</details>
|
|
866
917
|
<details><summary><b>[lib0/metric]</b> Utility module to convert metric values.</summary>
|
|
867
|
-
<pre>import * as metric from 'lib0/metric
|
|
918
|
+
<pre>import * as metric from 'lib0/metric'</pre>
|
|
868
919
|
<dl>
|
|
869
920
|
<b><code>metric.yotta</code></b><br>
|
|
870
921
|
<b><code>metric.zetta</code></b><br>
|
|
@@ -891,7 +942,7 @@ listeners.add(listener)
|
|
|
891
942
|
</dl>
|
|
892
943
|
</details>
|
|
893
944
|
<details><summary><b>[lib0/mutex]</b> Mutual exclude for JavaScript.</summary>
|
|
894
|
-
<pre>import * as mutex from 'lib0/mutex
|
|
945
|
+
<pre>import * as mutex from 'lib0/mutex'</pre>
|
|
895
946
|
<dl>
|
|
896
947
|
<b><code>mutex.createMutex(): mutex</code></b><br>
|
|
897
948
|
<dd><p>Creates a mutual exclude function with the following property:</p>
|
|
@@ -906,7 +957,7 @@ mutex(() => {
|
|
|
906
957
|
</dl>
|
|
907
958
|
</details>
|
|
908
959
|
<details><summary><b>[lib0/number]</b> </summary>
|
|
909
|
-
<pre>import * as number from 'lib0/number
|
|
960
|
+
<pre>import * as number from 'lib0/number'</pre>
|
|
910
961
|
<dl>
|
|
911
962
|
<b><code>number.MAX_SAFE_INTEGER</code></b><br>
|
|
912
963
|
<b><code>number.MIN_SAFE_INTEGER</code></b><br>
|
|
@@ -914,10 +965,11 @@ mutex(() => {
|
|
|
914
965
|
<b><code>number.HIGHEST_INT32: number</code></b><br>
|
|
915
966
|
<b><code>number.isInteger</code></b><br>
|
|
916
967
|
<b><code>number.isNaN</code></b><br>
|
|
968
|
+
<b><code>number.parseInt</code></b><br>
|
|
917
969
|
</dl>
|
|
918
970
|
</details>
|
|
919
971
|
<details><summary><b>[lib0/object]</b> Utility functions for working with EcmaScript objects.</summary>
|
|
920
|
-
<pre>import * as object from 'lib0/object
|
|
972
|
+
<pre>import * as object from 'lib0/object'</pre>
|
|
921
973
|
<dl>
|
|
922
974
|
<b><code>object.create(): Object<string,any></code></b><br>
|
|
923
975
|
<b><code>object.assign</code></b><br>
|
|
@@ -934,7 +986,7 @@ mutex(() => {
|
|
|
934
986
|
</dl>
|
|
935
987
|
</details>
|
|
936
988
|
<details><summary><b>[lib0/observable]</b> Observable class prototype.</summary>
|
|
937
|
-
<pre>import * as observable from 'lib0/observable
|
|
989
|
+
<pre>import * as observable from 'lib0/observable'</pre>
|
|
938
990
|
<dl>
|
|
939
991
|
<b><code>new observable.Observable()</code></b><br>
|
|
940
992
|
<dd><p>Handles named events.</p></dd>
|
|
@@ -954,7 +1006,7 @@ specified name will receive the event.</p></dd>
|
|
|
954
1006
|
</dl>
|
|
955
1007
|
</details>
|
|
956
1008
|
<details><summary><b>[lib0/pair]</b> Working with value pairs.</summary>
|
|
957
|
-
<pre>import * as pair from 'lib0/pair
|
|
1009
|
+
<pre>import * as pair from 'lib0/pair'</pre>
|
|
958
1010
|
<dl>
|
|
959
1011
|
<b><code>new pair.Pair(left: L, right: R)</code></b><br>
|
|
960
1012
|
<b><code>pair.create(left: L, right: R): module:pair.Pair<L,R></code></b><br>
|
|
@@ -964,7 +1016,7 @@ specified name will receive the event.</p></dd>
|
|
|
964
1016
|
</dl>
|
|
965
1017
|
</details>
|
|
966
1018
|
<details><summary><b>[lib0/prng]</b> Fast Pseudo Random Number Generators.</summary>
|
|
967
|
-
<pre>import * as prng from 'lib0/prng
|
|
1019
|
+
<pre>import * as prng from 'lib0/prng'</pre>
|
|
968
1020
|
|
|
969
1021
|
<p>Given a seed a PRNG generates a sequence of numbers that cannot be reasonably predicted.
|
|
970
1022
|
Two PRNGs must generate the same random sequence of numbers if given the same seed.</p>
|
|
@@ -1002,7 +1054,7 @@ But there are more PRNGs available in ./PRNG/.</p></dd>
|
|
|
1002
1054
|
</dl>
|
|
1003
1055
|
</details>
|
|
1004
1056
|
<details><summary><b>[lib0/promise]</b> Utility helpers to work with promises.</summary>
|
|
1005
|
-
<pre>import * as promise from 'lib0/promise
|
|
1057
|
+
<pre>import * as promise from 'lib0/promise'</pre>
|
|
1006
1058
|
<dl>
|
|
1007
1059
|
<b><code>promise.create(f: function(PromiseResolve<T>,function(Error):void):any): Promise<T></code></b><br>
|
|
1008
1060
|
<b><code>promise.createEmpty(f: function(function():void,function(Error):void):void): Promise<void></code></b><br>
|
|
@@ -1010,6 +1062,7 @@ But there are more PRNGs available in ./PRNG/.</p></dd>
|
|
|
1010
1062
|
<dd><p><code>Promise.all</code> wait for all promises in the array to resolve and return the result</p></dd>
|
|
1011
1063
|
<b><code>promise.reject(reason: Error): Promise<never></code></b><br>
|
|
1012
1064
|
<b><code>promise.resolve(res: T|void): Promise<T|void></code></b><br>
|
|
1065
|
+
<b><code>promise.resolveWith(res: T): Promise<T></code></b><br>
|
|
1013
1066
|
<b><code>promise.until(timeout: number, check: function():boolean, intervalResolution: number): Promise<void></code></b><br>
|
|
1014
1067
|
<b><code>promise.wait(timeout: number): Promise<undefined></code></b><br>
|
|
1015
1068
|
<b><code>promise.isPromise(p: any): boolean</code></b><br>
|
|
@@ -1019,7 +1072,7 @@ library has some insane environment where global Promise objects are overwritten
|
|
|
1019
1072
|
</dl>
|
|
1020
1073
|
</details>
|
|
1021
1074
|
<details><summary><b>[lib0/queue]</b> </summary>
|
|
1022
|
-
<pre>import * as queue from 'lib0/queue
|
|
1075
|
+
<pre>import * as queue from 'lib0/queue'</pre>
|
|
1023
1076
|
<dl>
|
|
1024
1077
|
<b><code>new de#QueueNode()</code></b><br>
|
|
1025
1078
|
<b><code>de#next: module:queue.QueueNode|null</code></b><br>
|
|
@@ -1037,7 +1090,7 @@ library has some insane environment where global Promise objects are overwritten
|
|
|
1037
1090
|
</dl>
|
|
1038
1091
|
</details>
|
|
1039
1092
|
<details><summary><b>[lib0/random]</b> Isomorphic module for true random numbers / buffers / uuids.</summary>
|
|
1040
|
-
<pre>import * as random from 'lib0/random
|
|
1093
|
+
<pre>import * as random from 'lib0/random'</pre>
|
|
1041
1094
|
|
|
1042
1095
|
<p>Attention: falls back to Math.random if the browser does not support crypto.</p>
|
|
1043
1096
|
<dl>
|
|
@@ -1048,14 +1101,16 @@ library has some insane environment where global Promise objects are overwritten
|
|
|
1048
1101
|
</dl>
|
|
1049
1102
|
</details>
|
|
1050
1103
|
<details><summary><b>[lib0/set]</b> Utility module to work with sets.</summary>
|
|
1051
|
-
<pre>import * as set from 'lib0/set
|
|
1104
|
+
<pre>import * as set from 'lib0/set'</pre>
|
|
1052
1105
|
<dl>
|
|
1053
1106
|
<b><code>set.create</code></b><br>
|
|
1054
1107
|
<b><code>set.toArray(set: Set<T>): Array<T></code></b><br>
|
|
1108
|
+
<b><code>set.first(set: Set<T>): T</code></b><br>
|
|
1109
|
+
<b><code>set.from(entries: Iterable<T>): Set<T></code></b><br>
|
|
1055
1110
|
</dl>
|
|
1056
1111
|
</details>
|
|
1057
1112
|
<details><summary><b>[lib0/sort]</b> Efficient sort implementations.</summary>
|
|
1058
|
-
<pre>import * as sort from 'lib0/sort
|
|
1113
|
+
<pre>import * as sort from 'lib0/sort'</pre>
|
|
1059
1114
|
|
|
1060
1115
|
<p>Note: These sort implementations were created to compare different sorting algorithms in JavaScript.
|
|
1061
1116
|
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 +1124,14 @@ integrate this algorithm.</p>
|
|
|
1069
1124
|
</dl>
|
|
1070
1125
|
</details>
|
|
1071
1126
|
<details><summary><b>[lib0/statistics]</b> Utility helpers for generating statistics.</summary>
|
|
1072
|
-
<pre>import * as statistics from 'lib0/statistics
|
|
1127
|
+
<pre>import * as statistics from 'lib0/statistics'</pre>
|
|
1073
1128
|
<dl>
|
|
1074
1129
|
<b><code>statistics.median(arr: Array<number>): number</code></b><br>
|
|
1075
1130
|
<b><code>statistics.average(arr: Array<number>): number</code></b><br>
|
|
1076
1131
|
</dl>
|
|
1077
1132
|
</details>
|
|
1078
1133
|
<details><summary><b>[lib0/storage]</b> Isomorphic variable storage.</summary>
|
|
1079
|
-
<pre>import * as storage from 'lib0/storage
|
|
1134
|
+
<pre>import * as storage from 'lib0/storage'</pre>
|
|
1080
1135
|
|
|
1081
1136
|
<p>Uses LocalStorage in the browser and falls back to in-memory storage.</p>
|
|
1082
1137
|
<dl>
|
|
@@ -1087,7 +1142,7 @@ integrate this algorithm.</p>
|
|
|
1087
1142
|
</dl>
|
|
1088
1143
|
</details>
|
|
1089
1144
|
<details><summary><b>[lib0/string]</b> Utility module to work with strings.</summary>
|
|
1090
|
-
<pre>import * as string from 'lib0/string
|
|
1145
|
+
<pre>import * as string from 'lib0/string'</pre>
|
|
1091
1146
|
<dl>
|
|
1092
1147
|
<b><code>string.fromCharCode</code></b><br>
|
|
1093
1148
|
<b><code>string.fromCodePoint</code></b><br>
|
|
@@ -1098,10 +1153,11 @@ integrate this algorithm.</p>
|
|
|
1098
1153
|
<b><code>string.utf8TextEncoder</code></b><br>
|
|
1099
1154
|
<b><code>string.encodeUtf8</code></b><br>
|
|
1100
1155
|
<b><code>string.decodeUtf8</code></b><br>
|
|
1156
|
+
<b><code>string.splice(str: string, index: number, remove: number, insert: string)</code></b><br>
|
|
1101
1157
|
</dl>
|
|
1102
1158
|
</details>
|
|
1103
1159
|
<details><summary><b>[lib0/symbol]</b> Utility module to work with EcmaScript Symbols.</summary>
|
|
1104
|
-
<pre>import * as symbol from 'lib0/symbol
|
|
1160
|
+
<pre>import * as symbol from 'lib0/symbol'</pre>
|
|
1105
1161
|
<dl>
|
|
1106
1162
|
<b><code>symbol.create(): Symbol</code></b><br>
|
|
1107
1163
|
<dd><p>Return fresh symbol.</p></dd>
|
|
@@ -1109,7 +1165,7 @@ integrate this algorithm.</p>
|
|
|
1109
1165
|
</dl>
|
|
1110
1166
|
</details>
|
|
1111
1167
|
<details><summary><b>[lib0/testing]</b> Testing framework with support for generating tests.</summary>
|
|
1112
|
-
<pre>import * as testing from 'lib0/testing
|
|
1168
|
+
<pre>import * as testing from 'lib0/testing'</pre>
|
|
1113
1169
|
|
|
1114
1170
|
<pre class="prettyprint source lang-js"><code>// test.js template for creating a test executable
|
|
1115
1171
|
import { runTests } from 'lib0/testing.js'
|
|
@@ -1227,7 +1283,7 @@ export const testMyFirstTest = tc => {
|
|
|
1227
1283
|
</dl>
|
|
1228
1284
|
</details>
|
|
1229
1285
|
<details><summary><b>[lib0/time]</b> Utility module to work with time.</summary>
|
|
1230
|
-
<pre>import * as time from 'lib0/time
|
|
1286
|
+
<pre>import * as time from 'lib0/time'</pre>
|
|
1231
1287
|
<dl>
|
|
1232
1288
|
<b><code>time.getDate(): Date</code></b><br>
|
|
1233
1289
|
<dd><p>Return current time.</p></dd>
|
|
@@ -1238,7 +1294,7 @@ export const testMyFirstTest = tc => {
|
|
|
1238
1294
|
</dl>
|
|
1239
1295
|
</details>
|
|
1240
1296
|
<details><summary><b>[lib0/tree]</b> Red-black-tree implementation.</summary>
|
|
1241
|
-
<pre>import * as tree from 'lib0/tree
|
|
1297
|
+
<pre>import * as tree from 'lib0/tree'</pre>
|
|
1242
1298
|
<dl>
|
|
1243
1299
|
<b><code>new tree.Tree()</code></b><br>
|
|
1244
1300
|
<dd><p>This is a Red Black Tree implementation</p></dd>
|
|
@@ -1257,7 +1313,7 @@ export const testMyFirstTest = tc => {
|
|
|
1257
1313
|
</dl>
|
|
1258
1314
|
</details>
|
|
1259
1315
|
<details><summary><b>[lib0/url]</b> Utility module to work with urls.</summary>
|
|
1260
|
-
<pre>import * as url from 'lib0/url
|
|
1316
|
+
<pre>import * as url from 'lib0/url'</pre>
|
|
1261
1317
|
<dl>
|
|
1262
1318
|
<b><code>url.decodeQueryParams(url: string): Object<string,string></code></b><br>
|
|
1263
1319
|
<dd><p>Parse query parameters from an url.</p></dd>
|
|
@@ -1265,7 +1321,7 @@ export const testMyFirstTest = tc => {
|
|
|
1265
1321
|
</dl>
|
|
1266
1322
|
</details>
|
|
1267
1323
|
<details><summary><b>[lib0/websocket]</b> Tiny websocket connection handler.</summary>
|
|
1268
|
-
<pre>import * as websocket from 'lib0/websocket
|
|
1324
|
+
<pre>import * as websocket from 'lib0/websocket'</pre>
|
|
1269
1325
|
|
|
1270
1326
|
<p>Implements exponential backoff reconnects, ping/pong, and a nice event system using [lib0/observable].</p>
|
|
1271
1327
|
<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,51 @@
|
|
|
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 remove<K, V>(cache: Cache<K, V>, key: K): V | undefined;
|
|
24
|
+
export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>, removeNull?: boolean): V | Promise<V>;
|
|
25
|
+
export function create(timeout: number): Cache<any, any>;
|
|
26
|
+
import * as list from "./list.js";
|
|
27
|
+
/**
|
|
28
|
+
* @template K, V
|
|
29
|
+
*
|
|
30
|
+
* @implements {list.ListNode}
|
|
31
|
+
*/
|
|
32
|
+
declare class Entry<K, V> implements list.ListNode {
|
|
33
|
+
/**
|
|
34
|
+
* @param {K} key
|
|
35
|
+
* @param {V | Promise<V>} val
|
|
36
|
+
*/
|
|
37
|
+
constructor(key: K, val: V | Promise<V>);
|
|
38
|
+
/**
|
|
39
|
+
* @type {this | null}
|
|
40
|
+
*/
|
|
41
|
+
prev: Entry<K, V> | null;
|
|
42
|
+
/**
|
|
43
|
+
* @type {this | null}
|
|
44
|
+
*/
|
|
45
|
+
next: Entry<K, V> | null;
|
|
46
|
+
created: number;
|
|
47
|
+
val: V | Promise<V>;
|
|
48
|
+
key: K;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
51
|
+
//# 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;AAQM,wEAON;AAWM,sGAHI,OAAO,kBA2BjB;AAKM,gCAFI,MAAM,mBAEkC;;AAvLnD;;;;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"}
|