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/indexeddb.js
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Helpers to work with IndexedDB.
|
|
5
5
|
*
|
|
6
|
-
* @module
|
|
6
|
+
* @module indexeddb
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as promise from './promise.js'
|
|
10
10
|
import * as error from './error.js'
|
|
11
11
|
|
|
12
|
+
/* istanbul ignore next */
|
|
12
13
|
/**
|
|
13
14
|
* IDB Request to Promise transformer
|
|
14
15
|
*
|
|
15
16
|
* @param {IDBRequest} request
|
|
16
17
|
* @return {Promise<any>}
|
|
17
18
|
*/
|
|
18
|
-
/* istanbul ignore next */
|
|
19
19
|
export const rtop = request => promise.create((resolve, reject) => {
|
|
20
20
|
/* istanbul ignore next */
|
|
21
21
|
// @ts-ignore
|
|
@@ -27,12 +27,12 @@ export const rtop = request => promise.create((resolve, reject) => {
|
|
|
27
27
|
request.onsuccess = event => resolve(event.target.result)
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
+
/* istanbul ignore next */
|
|
30
31
|
/**
|
|
31
32
|
* @param {string} name
|
|
32
33
|
* @param {function(IDBDatabase):any} initDB Called when the database is first created
|
|
33
34
|
* @return {Promise<IDBDatabase>}
|
|
34
35
|
*/
|
|
35
|
-
/* istanbul ignore next */
|
|
36
36
|
export const openDB = (name, initDB) => promise.create((resolve, reject) => {
|
|
37
37
|
const request = indexedDB.open(name)
|
|
38
38
|
/**
|
|
@@ -64,17 +64,17 @@ export const openDB = (name, initDB) => promise.create((resolve, reject) => {
|
|
|
64
64
|
}
|
|
65
65
|
})
|
|
66
66
|
|
|
67
|
+
/* istanbul ignore next */
|
|
67
68
|
/**
|
|
68
69
|
* @param {string} name
|
|
69
70
|
*/
|
|
70
|
-
/* istanbul ignore next */
|
|
71
71
|
export const deleteDB = name => rtop(indexedDB.deleteDatabase(name))
|
|
72
72
|
|
|
73
|
+
/* istanbul ignore next */
|
|
73
74
|
/**
|
|
74
75
|
* @param {IDBDatabase} db
|
|
75
76
|
* @param {Array<Array<string>|Array<string|IDBObjectStoreParameters|undefined>>} definitions
|
|
76
77
|
*/
|
|
77
|
-
/* istanbul ignore next */
|
|
78
78
|
export const createStores = (db, definitions) => definitions.forEach(d =>
|
|
79
79
|
// @ts-ignore
|
|
80
80
|
db.createObjectStore.apply(db, d)
|
|
@@ -91,75 +91,75 @@ export const transact = (db, stores, access = 'readwrite') => {
|
|
|
91
91
|
return stores.map(store => getStore(transaction, store))
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/* istanbul ignore next */
|
|
94
95
|
/**
|
|
95
96
|
* @param {IDBObjectStore} store
|
|
96
97
|
* @param {IDBKeyRange} [range]
|
|
97
98
|
* @return {Promise<number>}
|
|
98
99
|
*/
|
|
99
|
-
/* istanbul ignore next */
|
|
100
100
|
export const count = (store, range) =>
|
|
101
101
|
rtop(store.count(range))
|
|
102
102
|
|
|
103
|
+
/* istanbul ignore next */
|
|
103
104
|
/**
|
|
104
105
|
* @param {IDBObjectStore} store
|
|
105
106
|
* @param {String | number | ArrayBuffer | Date | Array<any> } key
|
|
106
107
|
* @return {Promise<String | number | ArrayBuffer | Date | Array<any>>}
|
|
107
108
|
*/
|
|
108
|
-
/* istanbul ignore next */
|
|
109
109
|
export const get = (store, key) =>
|
|
110
110
|
rtop(store.get(key))
|
|
111
111
|
|
|
112
|
+
/* istanbul ignore next */
|
|
112
113
|
/**
|
|
113
114
|
* @param {IDBObjectStore} store
|
|
114
115
|
* @param {String | number | ArrayBuffer | Date | IDBKeyRange | Array<any> } key
|
|
115
116
|
*/
|
|
116
|
-
/* istanbul ignore next */
|
|
117
117
|
export const del = (store, key) =>
|
|
118
118
|
rtop(store.delete(key))
|
|
119
119
|
|
|
120
|
+
/* istanbul ignore next */
|
|
120
121
|
/**
|
|
121
122
|
* @param {IDBObjectStore} store
|
|
122
123
|
* @param {String | number | ArrayBuffer | Date | boolean} item
|
|
123
124
|
* @param {String | number | ArrayBuffer | Date | Array<any>} [key]
|
|
124
125
|
*/
|
|
125
|
-
/* istanbul ignore next */
|
|
126
126
|
export const put = (store, item, key) =>
|
|
127
127
|
rtop(store.put(item, key))
|
|
128
128
|
|
|
129
|
+
/* istanbul ignore next */
|
|
129
130
|
/**
|
|
130
131
|
* @param {IDBObjectStore} store
|
|
131
132
|
* @param {String | number | ArrayBuffer | Date | boolean} item
|
|
132
133
|
* @param {String | number | ArrayBuffer | Date | Array<any>} key
|
|
133
134
|
* @return {Promise<any>}
|
|
134
135
|
*/
|
|
135
|
-
/* istanbul ignore next */
|
|
136
136
|
export const add = (store, item, key) =>
|
|
137
137
|
rtop(store.add(item, key))
|
|
138
138
|
|
|
139
|
+
/* istanbul ignore next */
|
|
139
140
|
/**
|
|
140
141
|
* @param {IDBObjectStore} store
|
|
141
142
|
* @param {String | number | ArrayBuffer | Date} item
|
|
142
143
|
* @return {Promise<number>} Returns the generated key
|
|
143
144
|
*/
|
|
144
|
-
/* istanbul ignore next */
|
|
145
145
|
export const addAutoKey = (store, item) =>
|
|
146
146
|
rtop(store.add(item))
|
|
147
147
|
|
|
148
|
+
/* istanbul ignore next */
|
|
148
149
|
/**
|
|
149
150
|
* @param {IDBObjectStore} store
|
|
150
151
|
* @param {IDBKeyRange} [range]
|
|
151
152
|
* @return {Promise<Array<any>>}
|
|
152
153
|
*/
|
|
153
|
-
/* istanbul ignore next */
|
|
154
154
|
export const getAll = (store, range) =>
|
|
155
155
|
rtop(store.getAll(range))
|
|
156
156
|
|
|
157
|
+
/* istanbul ignore next */
|
|
157
158
|
/**
|
|
158
159
|
* @param {IDBObjectStore} store
|
|
159
160
|
* @param {IDBKeyRange} [range]
|
|
160
161
|
* @return {Promise<Array<any>>}
|
|
161
162
|
*/
|
|
162
|
-
/* istanbul ignore next */
|
|
163
163
|
export const getAllKeys = (store, range) =>
|
|
164
164
|
rtop(store.getAllKeys(range))
|
|
165
165
|
|
|
@@ -182,15 +182,17 @@ export const queryFirst = (store, query, direction) => {
|
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
184
|
* @param {IDBObjectStore} store
|
|
185
|
+
* @param {IDBKeyRange?} [range]
|
|
185
186
|
* @return {Promise<any>}
|
|
186
187
|
*/
|
|
187
|
-
export const getLastKey = store => queryFirst(store,
|
|
188
|
+
export const getLastKey = (store, range = null) => queryFirst(store, range, 'prev')
|
|
188
189
|
|
|
189
190
|
/**
|
|
190
191
|
* @param {IDBObjectStore} store
|
|
192
|
+
* @param {IDBKeyRange?} [range]
|
|
191
193
|
* @return {Promise<any>}
|
|
192
194
|
*/
|
|
193
|
-
export const getFirstKey = store => queryFirst(store,
|
|
195
|
+
export const getFirstKey = (store, range = null) => queryFirst(store, range, 'next')
|
|
194
196
|
|
|
195
197
|
/**
|
|
196
198
|
* @typedef KeyValuePair
|
|
@@ -199,22 +201,22 @@ export const getFirstKey = store => queryFirst(store, null, 'prev')
|
|
|
199
201
|
* @property {any} v Value
|
|
200
202
|
*/
|
|
201
203
|
|
|
204
|
+
/* istanbul ignore next */
|
|
202
205
|
/**
|
|
203
206
|
* @param {IDBObjectStore} store
|
|
204
207
|
* @param {IDBKeyRange} [range]
|
|
205
208
|
* @return {Promise<Array<KeyValuePair>>}
|
|
206
209
|
*/
|
|
207
|
-
/* istanbul ignore next */
|
|
208
210
|
export const getAllKeysValues = (store, range) =>
|
|
209
211
|
// @ts-ignore
|
|
210
212
|
promise.all([getAllKeys(store, range), getAll(store, range)]).then(([ks, vs]) => ks.map((k, i) => ({ k, v: vs[i] })))
|
|
211
213
|
|
|
214
|
+
/* istanbul ignore next */
|
|
212
215
|
/**
|
|
213
216
|
* @param {any} request
|
|
214
217
|
* @param {function(IDBCursorWithValue):void|boolean} f
|
|
215
218
|
* @return {Promise<void>}
|
|
216
219
|
*/
|
|
217
|
-
/* istanbul ignore next */
|
|
218
220
|
const iterateOnRequest = (request, f) => promise.create((resolve, reject) => {
|
|
219
221
|
/* istanbul ignore next */
|
|
220
222
|
request.onerror = reject
|
|
@@ -230,6 +232,7 @@ const iterateOnRequest = (request, f) => promise.create((resolve, reject) => {
|
|
|
230
232
|
}
|
|
231
233
|
})
|
|
232
234
|
|
|
235
|
+
/* istanbul ignore next */
|
|
233
236
|
/**
|
|
234
237
|
* Iterate on keys and values
|
|
235
238
|
* @param {IDBObjectStore} store
|
|
@@ -237,10 +240,10 @@ const iterateOnRequest = (request, f) => promise.create((resolve, reject) => {
|
|
|
237
240
|
* @param {function(any,any):void|boolean} f Callback that receives (value, key)
|
|
238
241
|
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
|
|
239
242
|
*/
|
|
240
|
-
/* istanbul ignore next */
|
|
241
243
|
export const iterate = (store, keyrange, f, direction = 'next') =>
|
|
242
244
|
iterateOnRequest(store.openCursor(keyrange, direction), cursor => f(cursor.value, cursor.key))
|
|
243
245
|
|
|
246
|
+
/* istanbul ignore next */
|
|
244
247
|
/**
|
|
245
248
|
* Iterate on the keys (no values)
|
|
246
249
|
*
|
|
@@ -249,38 +252,37 @@ export const iterate = (store, keyrange, f, direction = 'next') =>
|
|
|
249
252
|
* @param {function(any):void|boolean} f callback that receives the key
|
|
250
253
|
* @param {'next'|'prev'|'nextunique'|'prevunique'} direction
|
|
251
254
|
*/
|
|
252
|
-
/* istanbul ignore next */
|
|
253
255
|
export const iterateKeys = (store, keyrange, f, direction = 'next') =>
|
|
254
256
|
iterateOnRequest(store.openKeyCursor(keyrange, direction), cursor => f(cursor.key))
|
|
255
257
|
|
|
258
|
+
/* istanbul ignore next */
|
|
256
259
|
/**
|
|
257
260
|
* Open store from transaction
|
|
258
261
|
* @param {IDBTransaction} t
|
|
259
262
|
* @param {String} store
|
|
260
263
|
* @returns {IDBObjectStore}
|
|
261
264
|
*/
|
|
262
|
-
/* istanbul ignore next */
|
|
263
265
|
export const getStore = (t, store) => t.objectStore(store)
|
|
264
266
|
|
|
267
|
+
/* istanbul ignore next */
|
|
265
268
|
/**
|
|
266
269
|
* @param {any} lower
|
|
267
270
|
* @param {any} upper
|
|
268
271
|
* @param {boolean} lowerOpen
|
|
269
272
|
* @param {boolean} upperOpen
|
|
270
273
|
*/
|
|
271
|
-
/* istanbul ignore next */
|
|
272
274
|
export const createIDBKeyRangeBound = (lower, upper, lowerOpen, upperOpen) => IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen)
|
|
273
275
|
|
|
276
|
+
/* istanbul ignore next */
|
|
274
277
|
/**
|
|
275
278
|
* @param {any} upper
|
|
276
279
|
* @param {boolean} upperOpen
|
|
277
280
|
*/
|
|
278
|
-
/* istanbul ignore next */
|
|
279
281
|
export const createIDBKeyRangeUpperBound = (upper, upperOpen) => IDBKeyRange.upperBound(upper, upperOpen)
|
|
280
282
|
|
|
283
|
+
/* istanbul ignore next */
|
|
281
284
|
/**
|
|
282
285
|
* @param {any} lower
|
|
283
286
|
* @param {boolean} lowerOpen
|
|
284
287
|
*/
|
|
285
|
-
/* istanbul ignore next */
|
|
286
288
|
export const createIDBKeyRangeLowerBound = (lower, lowerOpen) => IDBKeyRange.lowerBound(lower, lowerOpen)
|
package/list.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class ListNode {
|
|
2
|
+
/**
|
|
3
|
+
* @type {this|null}
|
|
4
|
+
*/
|
|
5
|
+
next: ListNode | null;
|
|
6
|
+
/**
|
|
7
|
+
* @type {this|null}
|
|
8
|
+
*/
|
|
9
|
+
prev: ListNode | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @template {ListNode} N
|
|
13
|
+
*/
|
|
14
|
+
export class List<N extends ListNode> {
|
|
15
|
+
/**
|
|
16
|
+
* @type {N | null}
|
|
17
|
+
*/
|
|
18
|
+
start: N | null;
|
|
19
|
+
/**
|
|
20
|
+
* @type {N | null}
|
|
21
|
+
*/
|
|
22
|
+
end: N | null;
|
|
23
|
+
}
|
|
24
|
+
export function create<N extends ListNode>(): List<N>;
|
|
25
|
+
export function isEmpty<N extends ListNode>(queue: List<N>): boolean;
|
|
26
|
+
export function removeNode<N extends ListNode>(queue: List<N>, node: N): N;
|
|
27
|
+
export function insertBetween<N extends ListNode>(queue: List<N>, left: N | null, right: N | null, node: N): void;
|
|
28
|
+
export function pushEnd<N extends ListNode>(queue: List<N>, n: N): void;
|
|
29
|
+
export function pushFront<N extends ListNode>(queue: List<N>, n: N): void;
|
|
30
|
+
export function popFront<N extends ListNode>(list: List<N>): N | null;
|
|
31
|
+
export function popEnd<N extends ListNode>(list: List<N>): N | null;
|
|
32
|
+
export function map<N extends ListNode, M>(list: List<N>, f: (arg0: N) => M): M[];
|
|
33
|
+
//# sourceMappingURL=list.d.ts.map
|
package/list.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["list.js"],"names":[],"mappings":"AAEA;IAEI;;OAEG;IACH,sBAAgB;IAChB;;OAEG;IACH,sBAAgB;CAEnB;AAED;;GAEG;AACH;IAEI;;OAEG;IACH,OAFU,CAAC,GAAG,IAAI,CAED;IACjB;;OAEG;IACH,KAFU,CAAC,GAAG,IAAI,CAEH;CAElB;AAUM,sDAA+B;AAO/B,qEAA6C;AAU7C,2EAcN;AAUM,kHAiBN;AAQM,wEACmC;AAQnC,0EACqC;AAQrC,sEAC2C;AAQ3C,oEACuC;AAUvC,kFAWN"}
|
package/list.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as error from './error.js'
|
|
2
|
+
|
|
3
|
+
export class ListNode {
|
|
4
|
+
constructor () {
|
|
5
|
+
/**
|
|
6
|
+
* @type {this|null}
|
|
7
|
+
*/
|
|
8
|
+
this.next = null
|
|
9
|
+
/**
|
|
10
|
+
* @type {this|null}
|
|
11
|
+
*/
|
|
12
|
+
this.prev = null
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @template {ListNode} N
|
|
18
|
+
*/
|
|
19
|
+
export class List {
|
|
20
|
+
constructor () {
|
|
21
|
+
/**
|
|
22
|
+
* @type {N | null}
|
|
23
|
+
*/
|
|
24
|
+
this.start = null
|
|
25
|
+
/**
|
|
26
|
+
* @type {N | null}
|
|
27
|
+
*/
|
|
28
|
+
this.end = null
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @note The queue implementation is experimental and unfinished.
|
|
34
|
+
* Don't use this in production yet.
|
|
35
|
+
*
|
|
36
|
+
* @template {ListNode} N
|
|
37
|
+
*
|
|
38
|
+
* @return {List<N>}
|
|
39
|
+
*/
|
|
40
|
+
export const create = () => new List()
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @template {ListNode} N
|
|
44
|
+
*
|
|
45
|
+
* @param {List<N>} queue
|
|
46
|
+
*/
|
|
47
|
+
export const isEmpty = queue => queue.start === null
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Remove a single node from the queue. Only works with Queues that operate on Doubly-linked lists of nodes.
|
|
51
|
+
*
|
|
52
|
+
* @template {ListNode} N
|
|
53
|
+
*
|
|
54
|
+
* @param {List<N>} queue
|
|
55
|
+
* @param {N} node
|
|
56
|
+
*/
|
|
57
|
+
export const removeNode = (queue, node) => {
|
|
58
|
+
const prev = node.prev
|
|
59
|
+
const next = node.next
|
|
60
|
+
if (prev) {
|
|
61
|
+
prev.next = next
|
|
62
|
+
} else {
|
|
63
|
+
queue.start = next
|
|
64
|
+
}
|
|
65
|
+
if (next) {
|
|
66
|
+
next.prev = prev
|
|
67
|
+
} else {
|
|
68
|
+
queue.end = prev
|
|
69
|
+
}
|
|
70
|
+
return node
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @template {ListNode} N
|
|
75
|
+
*
|
|
76
|
+
* @param {List<N>} queue
|
|
77
|
+
* @param {N| null} left
|
|
78
|
+
* @param {N| null} right
|
|
79
|
+
* @param {N} node
|
|
80
|
+
*/
|
|
81
|
+
export const insertBetween = (queue, left, right, node) => {
|
|
82
|
+
/* istanbul ignore if */
|
|
83
|
+
if (left != null && left.next !== right) {
|
|
84
|
+
throw error.unexpectedCase()
|
|
85
|
+
}
|
|
86
|
+
if (left) {
|
|
87
|
+
left.next = node
|
|
88
|
+
} else {
|
|
89
|
+
queue.start = node
|
|
90
|
+
}
|
|
91
|
+
if (right) {
|
|
92
|
+
right.prev = node
|
|
93
|
+
} else {
|
|
94
|
+
queue.end = node
|
|
95
|
+
}
|
|
96
|
+
node.prev = left
|
|
97
|
+
node.next = right
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @template {ListNode} N
|
|
102
|
+
*
|
|
103
|
+
* @param {List<N>} queue
|
|
104
|
+
* @param {N} n
|
|
105
|
+
*/
|
|
106
|
+
export const pushEnd = (queue, n) =>
|
|
107
|
+
insertBetween(queue, queue.end, null, n)
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @template {ListNode} N
|
|
111
|
+
*
|
|
112
|
+
* @param {List<N>} queue
|
|
113
|
+
* @param {N} n
|
|
114
|
+
*/
|
|
115
|
+
export const pushFront = (queue, n) =>
|
|
116
|
+
insertBetween(queue, null, queue.start, n)
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @template {ListNode} N
|
|
120
|
+
*
|
|
121
|
+
* @param {List<N>} list
|
|
122
|
+
* @return {N| null}
|
|
123
|
+
*/
|
|
124
|
+
export const popFront = list =>
|
|
125
|
+
list.start ? removeNode(list, list.start) : null
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @template {ListNode} N
|
|
129
|
+
*
|
|
130
|
+
* @param {List<N>} list
|
|
131
|
+
* @return {N| null}
|
|
132
|
+
*/
|
|
133
|
+
export const popEnd = list =>
|
|
134
|
+
list.end ? removeNode(list, list.end) : null
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @template {ListNode} N
|
|
138
|
+
* @template M
|
|
139
|
+
*
|
|
140
|
+
* @param {List<N>} list
|
|
141
|
+
* @param {function(N):M} f
|
|
142
|
+
* @return {Array<M>}
|
|
143
|
+
*/
|
|
144
|
+
export const map = (list, f) => {
|
|
145
|
+
/**
|
|
146
|
+
* @type {Array<M>}
|
|
147
|
+
*/
|
|
148
|
+
const arr = []
|
|
149
|
+
let n = list.start
|
|
150
|
+
while (n) {
|
|
151
|
+
arr.push(f(n))
|
|
152
|
+
n = n.next
|
|
153
|
+
}
|
|
154
|
+
return arr
|
|
155
|
+
}
|
package/list.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.test.d.ts","sourceRoot":"","sources":["list.test.js"],"names":[],"mappings":"AAgBO,uCAFI,EAAE,QAAQ,QA8BpB;AAKM,qCAFI,EAAE,QAAQ,QAkBpB"}
|
package/number.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export const HIGHEST_INT32: number;
|
|
|
10
10
|
*/
|
|
11
11
|
export const isInteger: (number: unknown) => boolean;
|
|
12
12
|
export const isNaN: (number: unknown) => boolean;
|
|
13
|
+
export const parseInt: (string: string, radix?: number | undefined) => number;
|
|
13
14
|
//# sourceMappingURL=number.d.ts.map
|
package/number.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.js"],"names":[],"mappings":"AASA,sCAAuD;AACvD,sCAAuD;AAEvD,kCAAmC;AACnC;;GAEG;AACH,4BAFU,MAAM,CAE0B;AAE1C;;GAEG;AAGH,qDAAyH;AACzH,iDAAiC"}
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.js"],"names":[],"mappings":"AASA,sCAAuD;AACvD,sCAAuD;AAEvD,kCAAmC;AACnC;;GAEG;AACH,4BAFU,MAAM,CAE0B;AAE1C;;GAEG;AAGH,qDAAyH;AACzH,iDAAiC;AACjC,8EAAuC"}
|
package/number.js
CHANGED
|
@@ -23,3 +23,4 @@ export const HIGHEST_INT32 = binary.BITS31
|
|
|
23
23
|
/* istanbul ignore next */
|
|
24
24
|
export const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && math.floor(num) === num)
|
|
25
25
|
export const isNaN = Number.isNaN
|
|
26
|
+
export const parseInt = Number.parseInt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lib0",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -41,14 +41,20 @@
|
|
|
41
41
|
"import": "./buffer.js",
|
|
42
42
|
"require": "./dist/buffer.cjs"
|
|
43
43
|
},
|
|
44
|
+
"./cache.js": "./cache.js",
|
|
45
|
+
"./dist/cache.cjs": "./dist/cache.cjs",
|
|
46
|
+
"./cache": {
|
|
47
|
+
"import": "./cache.js",
|
|
48
|
+
"require": "./dist/cache.cjs"
|
|
49
|
+
},
|
|
44
50
|
"./component.js": "./component.js",
|
|
45
51
|
"./dist/component.cjs": "./dist/component.cjs",
|
|
46
52
|
"./component": {
|
|
47
53
|
"import": "./component.js",
|
|
48
54
|
"require": "./dist/component.cjs"
|
|
49
55
|
},
|
|
50
|
-
"./
|
|
51
|
-
"./dist/
|
|
56
|
+
"./conditions.js": "./conditions.js",
|
|
57
|
+
"./dist/conditions.cjs": "./dist/conditions.cjs",
|
|
52
58
|
"./conditions": {
|
|
53
59
|
"import": "./condititons.js",
|
|
54
60
|
"require": "./dist/conditions.cjs"
|
|
@@ -125,6 +131,12 @@
|
|
|
125
131
|
"import": "./json.js",
|
|
126
132
|
"require": "./dist/json.cjs"
|
|
127
133
|
},
|
|
134
|
+
"./list.js": "./list.js",
|
|
135
|
+
"./dist/list.cjs": "./dist/list.cjs",
|
|
136
|
+
"./list": {
|
|
137
|
+
"import": "./list.js",
|
|
138
|
+
"require": "./dist/list.cjs"
|
|
139
|
+
},
|
|
128
140
|
"./logging.js": "./logging.js",
|
|
129
141
|
"./dist/logging.cjs": "./dist/logging.cjs",
|
|
130
142
|
"./logging": {
|
package/promise.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export function createEmpty(f: (arg0: () => void, arg1: (arg0: Error) => void) =
|
|
|
3
3
|
export function all<T>(arrp: Promise<T>[]): Promise<T[]>;
|
|
4
4
|
export function reject(reason?: Error | undefined): Promise<never>;
|
|
5
5
|
export function resolve<T>(res: void | T): Promise<void | T>;
|
|
6
|
+
export function resolveWith<T>(res: T): Promise<T>;
|
|
6
7
|
export function until(timeout: number, check: () => boolean, intervalResolution?: number | undefined): Promise<void>;
|
|
7
8
|
export function wait(timeout: number): Promise<undefined>;
|
|
8
9
|
export function isPromise(p: any): boolean;
|
package/promise.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["promise.js"],"names":[],"mappings":"AAmBO,oEAHwC,KAAK,KAAE,IAAI,KAAE,GAAG,cAGM;AAM9D,4CAHwB,IAAI,eAAU,KAAK,KAAE,IAAI,KAAE,IAAI,GAClD,QAAQ,IAAI,CAAC,CAEqB;AAQvC,yDAAqC;AAMrC,oDAFK,QAAQ,KAAK,CAAC,CAE4B;AAO/C,6DAA2C;
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["promise.js"],"names":[],"mappings":"AAmBO,oEAHwC,KAAK,KAAE,IAAI,KAAE,GAAG,cAGM;AAM9D,4CAHwB,IAAI,eAAU,KAAK,KAAE,IAAI,KAAE,IAAI,GAClD,QAAQ,IAAI,CAAC,CAEqB;AAQvC,yDAAqC;AAMrC,oDAFK,QAAQ,KAAK,CAAC,CAE4B;AAO/C,6DAA2C;AAO3C,mDAA+C;AAU/C,+BALI,MAAM,eACK,OAAO,4CAEjB,QAAQ,IAAI,CAAC,CAkBvB;AAMK,8BAHI,MAAM,GACL,QAAQ,SAAS,CAAC,CAE0D;AAWjF,6BAHI,GAAG,GACF,OAAO,CAEwE"}
|
package/promise.js
CHANGED
|
@@ -46,6 +46,13 @@ export const reject = reason => Promise.reject(reason)
|
|
|
46
46
|
*/
|
|
47
47
|
export const resolve = res => Promise.resolve(res)
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @template T
|
|
51
|
+
* @param {T} res
|
|
52
|
+
* @return {Promise<T>}
|
|
53
|
+
*/
|
|
54
|
+
export const resolveWith = res => Promise.resolve(res)
|
|
55
|
+
|
|
49
56
|
/**
|
|
50
57
|
* @todo Next version, reorder parameters: check, [timeout, [intervalResolution]]
|
|
51
58
|
*
|
package/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AACA;IAEI;;OAEG;IACH,MAFU,SAAS,GAAC,IAAI,CAER;CAEnB;AAED;IAEI;;OAEG;IACH,OAFU,SAAS,GAAG,IAAI,CAET;IACjB;;OAEG;IACH,KAFU,SAAS,GAAG,IAAI,CAEX;CAElB;AAQM,0BAFK,KAAK,CAEsB;AAKhC,+BAFI,KAAK,WAEoC;AAM7C,+BAHI,KAAK,KACL,SAAS,QAUnB;AAMM,+BAHI,KAAK,GACJ,SAAS,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AACA;IAEI;;OAEG;IACH,MAFU,SAAS,GAAC,IAAI,CAER;CAEnB;AAED;IAEI;;OAEG;IACH,OAFU,SAAS,GAAG,IAAI,CAET;IACjB;;OAEG;IACH,KAFU,SAAS,GAAG,IAAI,CAEX;CAElB;AAQM,0BAFK,KAAK,CAEsB;AAKhC,+BAFI,KAAK,WAEoC;AAM7C,+BAHI,KAAK,KACL,SAAS,QAUnB;AAMM,+BAHI,KAAK,GACJ,SAAS,GAAG,IAAI,CAa3B"}
|
package/queue.js
CHANGED
package/queue.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.test.d.ts","sourceRoot":"","sources":["queue.test.js"],"names":[],"mappings":"AAgBO,uCAFI,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"queue.test.d.ts","sourceRoot":"","sources":["queue.test.js"],"names":[],"mappings":"AAgBO,uCAFI,EAAE,QAAQ,QA8BpB"}
|
package/set.d.ts
CHANGED
package/set.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["set.js"],"names":[],"mappings":"AAMO,mCAA8B;AAO9B,6CAAsC"}
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["set.js"],"names":[],"mappings":"AAMO,mCAA8B;AAO9B,6CAAsC;AAOtC,yCAEN;AAOM,sDAEN"}
|
package/set.js
CHANGED
|
@@ -12,3 +12,21 @@ export const create = () => new Set()
|
|
|
12
12
|
* @return {Array<T>}
|
|
13
13
|
*/
|
|
14
14
|
export const toArray = set => Array.from(set)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @template T
|
|
18
|
+
* @param {Set<T>} set
|
|
19
|
+
* @return {T}
|
|
20
|
+
*/
|
|
21
|
+
export const first = set => {
|
|
22
|
+
return set.values().next().value || undefined
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @template T
|
|
27
|
+
* @param {Iterable<T>} entries
|
|
28
|
+
* @return {Set<T>}
|
|
29
|
+
*/
|
|
30
|
+
export const from = entries => {
|
|
31
|
+
return new Set(entries)
|
|
32
|
+
}
|
package/set.test.d.ts
CHANGED
package/set.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.test.d.ts","sourceRoot":"","sources":["set.test.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"set.test.d.ts","sourceRoot":"","sources":["set.test.js"],"names":[],"mappings":"AAQO,iCAFI,EAAE,QAAQ,QASpB"}
|
package/string.d.ts
CHANGED
|
@@ -16,4 +16,5 @@ export function _decodeUtf8Polyfill(buf: Uint8Array): string;
|
|
|
16
16
|
export let utf8TextDecoder: TextDecoder | null;
|
|
17
17
|
export function _decodeUtf8Native(buf: Uint8Array): string;
|
|
18
18
|
export function decodeUtf8(buf: Uint8Array): string;
|
|
19
|
+
export function splice(str: string, index: number, remove: number, insert?: string): string;
|
|
19
20
|
//# sourceMappingURL=string.d.ts.map
|
package/string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0DAA+C;AAC/C,gEAAiD;AAc1C,4BAHI,MAAM,GACL,MAAM,CAEuC;AASlD,iCAJI,MAAM,aACN,MAAM,GACL,MAAM,CAEkH;AAO7H,oCAHI,MAAM,GACL,MAAM,CAE2D;AAMtE,yCAHI,MAAM,GACL,UAAU,CAUrB;AAGD,
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0DAA+C;AAC/C,gEAAiD;AAc1C,4BAHI,MAAM,GACL,MAAM,CAEuC;AASlD,iCAJI,MAAM,aACN,MAAM,GACL,MAAM,CAEkH;AAO7H,oCAHI,MAAM,GACL,MAAM,CAE2D;AAMtE,yCAHI,MAAM,GACL,UAAU,CAUrB;AAGD,0CAAyH;AAMlH,uCAHI,MAAM,GACL,UAAU,CAE6C;AAjB5D,gCAHI,MAAM,GACL,UAAU,CAUrB;AAsBM,yCAHI,UAAU,GACT,MAAM,CAejB;AAGD,+CAAmI;AAiB5H,uCAHI,UAAU,GACT,MAAM,CAE8E;AAjCzF,gCAHI,UAAU,GACT,MAAM,CAejB;AAmCM,4BALI,MAAM,SACN,MAAM,UACN,MAAM,WACN,MAAM,UAEkG"}
|
package/string.js
CHANGED
|
@@ -112,3 +112,11 @@ export const _decodeUtf8Native = buf => /** @type {TextDecoder} */ (utf8TextDeco
|
|
|
112
112
|
*/
|
|
113
113
|
/* istanbul ignore next */
|
|
114
114
|
export const decodeUtf8 = utf8TextDecoder ? _decodeUtf8Native : _decodeUtf8Polyfill
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @param {string} str The initial string
|
|
118
|
+
* @param {number} index Starting position
|
|
119
|
+
* @param {number} remove Number of characters to remove
|
|
120
|
+
* @param {string} insert New content to insert
|
|
121
|
+
*/
|
|
122
|
+
export const splice = (str, index, remove, insert = '') => str.slice(0, index) + insert + str.slice(index + remove)
|
package/string.test.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export function testLowercaseTransformation(tc: t.TestCase): void;
|
|
|
2
2
|
export function testRepeatStringUtf8Encoding(tc: t.TestCase): void;
|
|
3
3
|
export function testRepeatStringUtf8Decoding(tc: t.TestCase): void;
|
|
4
4
|
export function testBomEncodingDecoding(tc: t.TestCase): void;
|
|
5
|
+
export function testSplice(tc: t.TestCase): void;
|
|
5
6
|
import * as t from "./testing.js";
|
|
6
7
|
//# sourceMappingURL=string.test.d.ts.map
|
package/string.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.test.d.ts","sourceRoot":"","sources":["string.test.js"],"names":[],"mappings":"AAOO,gDAFI,EAAE,QAAQ,QAOpB;AAKM,iDAFI,EAAE,QAAQ,QAapB;AAKM,iDAFI,EAAE,QAAQ,QAapB;AAKM,4CAFI,EAAE,QAAQ,QAYpB"}
|
|
1
|
+
{"version":3,"file":"string.test.d.ts","sourceRoot":"","sources":["string.test.js"],"names":[],"mappings":"AAOO,gDAFI,EAAE,QAAQ,QAOpB;AAKM,iDAFI,EAAE,QAAQ,QAapB;AAKM,iDAFI,EAAE,QAAQ,QAapB;AAKM,4CAFI,EAAE,QAAQ,QAYpB;AAKM,+BAFI,EAAE,QAAQ,QAMpB"}
|
package/test.js
CHANGED
|
@@ -21,11 +21,14 @@ import * as object from './object.test.js'
|
|
|
21
21
|
import * as math from './math.test.js'
|
|
22
22
|
import * as number from './number.test.js'
|
|
23
23
|
import * as buffer from './buffer.test.js'
|
|
24
|
+
import * as set from './set.test.js'
|
|
24
25
|
import * as sort from './sort.test.js'
|
|
25
26
|
import * as url from './url.test.js'
|
|
26
27
|
import * as metric from './metric.test.js'
|
|
27
28
|
import * as func from './function.test.js'
|
|
28
29
|
import * as storage from './storage.test.js'
|
|
30
|
+
import * as list from './list.test.js'
|
|
31
|
+
import * as cache from './cache.test.js'
|
|
29
32
|
|
|
30
33
|
import { isBrowser, isNode } from './environment.js'
|
|
31
34
|
|
|
@@ -56,11 +59,14 @@ runTests({
|
|
|
56
59
|
math,
|
|
57
60
|
number,
|
|
58
61
|
buffer,
|
|
62
|
+
set,
|
|
59
63
|
sort,
|
|
60
64
|
url,
|
|
61
65
|
metric,
|
|
62
66
|
func,
|
|
63
|
-
storage
|
|
67
|
+
storage,
|
|
68
|
+
list,
|
|
69
|
+
cache
|
|
64
70
|
}).then(success => {
|
|
65
71
|
/* istanbul ignore next */
|
|
66
72
|
if (isNode) {
|