lib0 0.2.39 → 0.2.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +84 -76
  2. package/bin/gendocs.js +1 -1
  3. package/broadcastchannel.js +1 -1
  4. package/component.d.ts +4 -1
  5. package/component.d.ts.map +1 -1
  6. package/component.js +4 -1
  7. package/decoding.d.ts +0 -12
  8. package/decoding.d.ts.map +1 -1
  9. package/decoding.js +8 -8
  10. package/diff.d.ts.map +1 -1
  11. package/dist/{broadcastchannel-cb74c2ae.cjs → broadcastchannel-044f32d2.cjs} +3 -3
  12. package/dist/broadcastchannel-044f32d2.cjs.map +1 -0
  13. package/dist/broadcastchannel.cjs +4 -4
  14. package/dist/{buffer-097552c3.cjs → buffer-49880125.cjs} +16 -15
  15. package/dist/buffer-49880125.cjs.map +1 -0
  16. package/dist/buffer.cjs +3 -3
  17. package/dist/component.cjs +5 -2
  18. package/dist/component.cjs.map +1 -1
  19. package/dist/component.d.ts +4 -1
  20. package/dist/component.d.ts.map +1 -1
  21. package/dist/decoding.cjs +3 -3
  22. package/dist/decoding.d.ts +0 -12
  23. package/dist/decoding.d.ts.map +1 -1
  24. package/dist/diff.d.ts.map +1 -1
  25. package/dist/encoding.cjs +3 -3
  26. package/dist/encoding.d.ts.map +1 -1
  27. package/dist/{environment-bf1f625d.cjs → environment-7e2ffaea.cjs} +1 -1
  28. package/dist/{environment-bf1f625d.cjs.map → environment-7e2ffaea.cjs.map} +1 -1
  29. package/dist/environment.cjs +1 -1
  30. package/dist/{error-55a9a8c8.cjs → error-873c9cbf.cjs} +4 -4
  31. package/dist/error-873c9cbf.cjs.map +1 -0
  32. package/dist/error.cjs +1 -1
  33. package/dist/error.d.ts.map +1 -1
  34. package/dist/index.cjs +9 -9
  35. package/dist/{indexeddb-44227700.cjs → indexeddb-5b4b0e13.cjs} +27 -25
  36. package/dist/indexeddb-5b4b0e13.cjs.map +1 -0
  37. package/dist/indexeddb.cjs +3 -3
  38. package/dist/indexeddb.d.ts +2 -2
  39. package/dist/indexeddb.d.ts.map +1 -1
  40. package/dist/isomorphic.cjs +2 -6
  41. package/dist/isomorphic.cjs.map +1 -1
  42. package/dist/{logging-4941d274.cjs → logging-7cc36806.cjs} +2 -2
  43. package/dist/{logging-4941d274.cjs.map → logging-7cc36806.cjs.map} +1 -1
  44. package/dist/logging.cjs +2 -2
  45. package/dist/{number-24f1eabe.cjs → number-e62129bc.cjs} +5 -2
  46. package/dist/number-e62129bc.cjs.map +1 -0
  47. package/dist/number.cjs +2 -1
  48. package/dist/number.cjs.map +1 -1
  49. package/dist/number.d.ts +1 -0
  50. package/dist/number.d.ts.map +1 -1
  51. package/dist/observable.d.ts.map +1 -1
  52. package/dist/pair.d.ts.map +1 -1
  53. package/dist/{prng-70808343.cjs → prng-97174619.cjs} +2 -2
  54. package/dist/{prng-70808343.cjs.map → prng-97174619.cjs.map} +1 -1
  55. package/dist/prng.cjs +4 -4
  56. package/dist/{promise-f0a086b2.cjs → promise-1a9fe712.cjs} +10 -1
  57. package/dist/{promise-f0a086b2.cjs.map → promise-1a9fe712.cjs.map} +1 -1
  58. package/dist/promise.cjs +2 -1
  59. package/dist/promise.cjs.map +1 -1
  60. package/dist/promise.d.ts +1 -0
  61. package/dist/promise.d.ts.map +1 -1
  62. package/dist/storage.cjs +16 -4
  63. package/dist/storage.cjs.map +1 -1
  64. package/dist/storage.d.ts +5 -0
  65. package/dist/storage.d.ts.map +1 -1
  66. package/dist/storage.test.d.ts +3 -0
  67. package/dist/storage.test.d.ts.map +1 -0
  68. package/dist/string.cjs +1 -3
  69. package/dist/string.cjs.map +1 -1
  70. package/dist/test.cjs +264 -225
  71. package/dist/test.cjs.map +1 -1
  72. package/dist/test.js +266 -227
  73. package/dist/test.js.map +1 -1
  74. package/dist/testing.cjs +15 -12
  75. package/dist/testing.cjs.map +1 -1
  76. package/dist/testing.d.ts +1 -1
  77. package/dist/testing.d.ts.map +1 -1
  78. package/dist/testing.test.d.ts +1 -1
  79. package/dist/tree.d.ts +1 -1
  80. package/dist/tree.d.ts.map +1 -1
  81. package/dist/websocket.d.ts +1 -1
  82. package/dist/websocket.d.ts.map +1 -1
  83. package/encoding.d.ts.map +1 -1
  84. package/encoding.js +5 -4
  85. package/error.d.ts.map +1 -1
  86. package/error.js +3 -3
  87. package/indexeddb.d.ts +2 -2
  88. package/indexeddb.d.ts.map +1 -1
  89. package/indexeddb.js +25 -23
  90. package/number.d.ts +1 -0
  91. package/number.d.ts.map +1 -1
  92. package/number.js +1 -0
  93. package/observable.d.ts.map +1 -1
  94. package/package.json +11 -10
  95. package/pair.d.ts.map +1 -1
  96. package/promise.d.ts +1 -0
  97. package/promise.d.ts.map +1 -1
  98. package/promise.js +7 -0
  99. package/storage.d.ts +5 -0
  100. package/storage.d.ts.map +1 -1
  101. package/storage.js +15 -4
  102. package/storage.test.d.ts +3 -0
  103. package/storage.test.d.ts.map +1 -0
  104. package/test.js +3 -1
  105. package/testing.d.ts +1 -1
  106. package/testing.d.ts.map +1 -1
  107. package/testing.js +9 -6
  108. package/testing.test.d.ts +1 -1
  109. package/tree.d.ts +1 -1
  110. package/tree.d.ts.map +1 -1
  111. package/websocket.d.ts +1 -1
  112. package/websocket.d.ts.map +1 -1
  113. package/dist/broadcastchannel-cb74c2ae.cjs.map +0 -1
  114. package/dist/buffer-097552c3.cjs.map +0 -1
  115. package/dist/error-55a9a8c8.cjs.map +0 -1
  116. package/dist/indexeddb-44227700.cjs.map +0 -1
  117. package/dist/number-24f1eabe.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 idb
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, null, 'prev')
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, null, 'prev')
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/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
@@ -1 +1 @@
1
- {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["observable.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH;IAEI;;;OAGG;IACH,wBAA8B;IAGhC;;;OAGG;IACH,+BAEC;IAED;;;OAGG;IACH,iCASC;IAED;;;OAGG;IACH,gCAQC;IAED;;;;;;;;OAQG;IACH,oBAFW,MAAM,GAAG,CAAC,QAKpB;IAED,gBAEC;CACF"}
1
+ {"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["observable.js"],"names":[],"mappings":"AAUA;;;;GAIG;AACH;IAEI;;;OAGG;IACH,YAFU,IAAI,CAAC,EAAE,GAAG,CAAC,CAES;IAGhC;;;OAGG;IACH,SAHW,CAAC,qBAKX;IAED;;;OAGG;IACH,WAHW,CAAC,qBAYX;IAED;;;OAGG;IACH,UAHW,CAAC,qBAWX;IAED;;;;;;;;OAQG;IACH,WAHW,CAAC,QACD,MAAM,GAAG,CAAC,QAKpB;IAED,gBAEC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lib0",
3
- "version": "0.2.39",
3
+ "version": "0.2.43",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -12,6 +12,7 @@
12
12
  "url": "https://github.com/sponsors/dmonad"
13
13
  },
14
14
  "exports": {
15
+ "./package.json": "./package.json",
15
16
  ".": {
16
17
  "import": "./index.js",
17
18
  "require": "./dist/index.cjs"
@@ -46,8 +47,8 @@
46
47
  "import": "./component.js",
47
48
  "require": "./dist/component.cjs"
48
49
  },
49
- "./condititons.js": "./condititons.js",
50
- "./dist/condititons.cjs": "./dist/condititons.cjs",
50
+ "./conditions.js": "./conditions.js",
51
+ "./dist/conditions.cjs": "./dist/conditions.cjs",
51
52
  "./conditions": {
52
53
  "import": "./condititons.js",
53
54
  "require": "./dist/conditions.cjs"
@@ -98,7 +99,7 @@
98
99
  "./dist/function.cjs": "./dist/function.cjs",
99
100
  "./function": {
100
101
  "import": "./function.js",
101
- "require": "./dist/.cjs"
102
+ "require": "./dist/function.cjs"
102
103
  },
103
104
  "./indexeddb.js": "./indexeddb.js",
104
105
  "./dist/indexeddb.cjs": "./dist/indexeddb.cjs",
@@ -270,7 +271,7 @@
270
271
  }
271
272
  },
272
273
  "dependencies": {
273
- "isomorphic.js": "^0.2.0"
274
+ "isomorphic.js": "^0.2.4"
274
275
  },
275
276
  "devDependencies": {
276
277
  "@rollup/plugin-commonjs": "^17.1.0",
@@ -280,18 +281,18 @@
280
281
  "jsdoc-api": "^5.0.4",
281
282
  "jsdoc-plugin-typescript": "^2.0.6",
282
283
  "nyc": "^15.1.0",
283
- "rollup": "^2.39.0",
284
+ "rollup": "^2.42.1",
284
285
  "standard": "^14.3.4",
285
- "typescript": "^4.1.5"
286
+ "typescript": "^4.2.3"
286
287
  },
287
288
  "scripts": {
288
289
  "clean": "rm -rf dist *.d.ts */*.d.ts *.d.ts.map */*.d.ts.map",
289
290
  "types": "tsc --outDir .",
290
291
  "dist": "rollup -c",
291
292
  "debug": "rollup -c && concurrently 'rollup -wc' 'http-server -o test.html'",
292
- "test": "npm run clean && npm run lint && npm run dist && nyc --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node --unhandled-rejections=strict ./dist/test.cjs --repitition-time 50 --production",
293
- "test-inspect": "node --inspect-brk --unhandled-rejections=strict ./test.js --repitition-time 50 --production",
294
- "test-extensive": "node test.js && npm test -- --repitition-time 30000 --extensive",
293
+ "test": "npm run clean && npm run lint && npm run dist && nyc --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node --unhandled-rejections=strict ./dist/test.cjs --repetition-time 50 --production",
294
+ "test-inspect": "node --inspect-brk --unhandled-rejections=strict ./test.js --repetition-time 50 --production",
295
+ "test-extensive": "node test.js && npm test -- --repetition-time 30000 --extensive",
295
296
  "test-code-coverage": "npm run clean && npm run dist && nyc --reporter html node ./dist/test.cjs --production",
296
297
  "trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.cjs",
297
298
  "trace-opt": "clear && rollup -c && node --trace-opt dist/test.cjs",
package/pair.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pair.d.ts","sourceRoot":"","sources":["pair.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH;IACE;;;OAGG;IACH,+BAGC;IAFC,QAAgB;IAChB,SAAkB;CAErB;AAQM,4DAAqD;AAQrD,oEAA6D;AAO7D,0EAFmB,GAAG,QAE0C;AAQhE,iFAAwD"}
1
+ {"version":3,"file":"pair.d.ts","sourceRoot":"","sources":["pair.js"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH;IACE;;;OAGG;IACH,kBAHW,CAAC,SACD,CAAC,EAKX;IAFC,QAAgB;IAChB,SAAkB;CAErB;AAQM,4DAAqD;AAQrD,oEAA6D;AAO7D,0EAFmB,GAAG,QAE0C;AAQhE,iFAAwD"}
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;AAU3C,+BALI,MAAM,eACK,OAAO,4CAEjB,QAAQ,IAAI,CAAC,CAkBvB;AAMK,8BAHI,MAAM,GACL,QAAQ,SAAS,CAAC,CAE0D;AAWjF,6BAHI,GAAG,GACF,OAAO,CAEwE"}
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/storage.d.ts CHANGED
@@ -2,4 +2,9 @@
2
2
  * This is basically localStorage in browser, or a polyfill in nodejs
3
3
  */
4
4
  export const varStorage: any;
5
+ export function onChange(eventHandler: (arg0: {
6
+ key: string;
7
+ newValue: string;
8
+ oldValue: string;
9
+ }) => void): true | void;
5
10
  //# sourceMappingURL=storage.d.ts.map
package/storage.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["storage.js"],"names":[],"mappings":"AA+CA;;GAEG;AACH,6BAAuC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["storage.js"],"names":[],"mappings":"AAiDA;;GAEG;AACH,6BAAuC;AAShC,8CAHa;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,KAAG,IAAI,eAGuC"}
package/storage.js CHANGED
@@ -1,4 +1,4 @@
1
- /* global localStorage */
1
+ /* global localStorage, addEventListener */
2
2
 
3
3
  /**
4
4
  * Isomorphic variable storage.
@@ -16,10 +16,10 @@ class VarStoragePolyfill {
16
16
 
17
17
  /**
18
18
  * @param {string} key
19
- * @param {any} value
19
+ * @param {any} newValue
20
20
  */
21
- setItem (key, value) {
22
- this.map.set(key, value)
21
+ setItem (key, newValue) {
22
+ this.map.set(key, newValue)
23
23
  }
24
24
 
25
25
  /**
@@ -35,12 +35,14 @@ class VarStoragePolyfill {
35
35
  * @type {any}
36
36
  */
37
37
  let _localStorage = new VarStoragePolyfill()
38
+ let usePolyfill = true
38
39
 
39
40
  try {
40
41
  // if the same-origin rule is violated, accessing localStorage might thrown an error
41
42
  /* istanbul ignore next */
42
43
  if (typeof localStorage !== 'undefined') {
43
44
  _localStorage = localStorage
45
+ usePolyfill = false
44
46
  }
45
47
  } catch (e) { }
46
48
 
@@ -49,3 +51,12 @@ try {
49
51
  * This is basically localStorage in browser, or a polyfill in nodejs
50
52
  */
51
53
  export const varStorage = _localStorage
54
+
55
+ /* istanbul ignore next */
56
+ /**
57
+ * A polyfill for `addEventListener('storage', event => {..})` that does nothing if the polyfill is being used.
58
+ *
59
+ * @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler
60
+ * @function
61
+ */
62
+ export const onChange = eventHandler => usePolyfill || addEventListener('storage', /** @type {any} */ (eventHandler))
@@ -0,0 +1,3 @@
1
+ export function testStorageModule(tc: t.TestCase): void;
2
+ import * as t from "./testing.js";
3
+ //# sourceMappingURL=storage.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.test.d.ts","sourceRoot":"","sources":["storage.test.js"],"names":[],"mappings":"AAMO,sCAFI,EAAE,QAAQ,QAapB"}
package/test.js CHANGED
@@ -25,6 +25,7 @@ import * as sort from './sort.test.js'
25
25
  import * as url from './url.test.js'
26
26
  import * as metric from './metric.test.js'
27
27
  import * as func from './function.test.js'
28
+ import * as storage from './storage.test.js'
28
29
 
29
30
  import { isBrowser, isNode } from './environment.js'
30
31
 
@@ -58,7 +59,8 @@ runTests({
58
59
  sort,
59
60
  url,
60
61
  metric,
61
- func
62
+ func,
63
+ storage
62
64
  }).then(success => {
63
65
  /* istanbul ignore next */
64
66
  if (isNode) {
package/testing.d.ts CHANGED
@@ -29,7 +29,7 @@ export class TestCase {
29
29
  */
30
30
  get prng(): prng.PRNG;
31
31
  }
32
- export const repititionTime: number;
32
+ export const repetitionTime: number;
33
33
  export function run(moduleName: string, name: string, f: (arg0: TestCase) => void | Promise<any>, i: number, numberOfTests: number): Promise<boolean>;
34
34
  export function describe(description: string, info?: string): void;
35
35
  export function info(info: string): void;
package/testing.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["testing.js"],"names":[],"mappings":";AA+DA,gCAAiD;AAGjD,oCAAmG;AAEnG;IACE;;;OAGG;IACH,wBAHW,MAAM,YACN,MAAM,EAahB;IAVC;;OAEG;IACH,YAFU,MAAM,CAEY;IAC5B;;OAEG;IACH,UAFU,MAAM,CAEQ;IACxB,qBAAiB;IACjB,wBAAiB;IAGnB,kBAGC;IAED;;OAEG;IAEH,mBAOC;IAED;;;;OAIG;IACH,sBAMC;CACF;AAED,oCAA6E;AAgBtE,gCANI,MAAM,QACN,MAAM,YACG,QAAQ,KAAE,IAAI,GAAC,QAAQ,GAAG,CAAC,KACpC,MAAM,iBACN,MAAM,oBAsEhB;AAcM,sCAHI,MAAM,SACN,MAAM,QAEwF;AAYlG,2BAFI,MAAM,QAE6B;AAE9C,wDAAoC;AAEpC,8EAA0C;AAoBnC,mCAHI,MAAM,YACG,IAAI,KAAE,IAAI,QAS7B;AAoBM,wCAHI,MAAM,YACG,IAAI,KAAE,QAAQ,GAAG,CAAC,iBASrC;AAoBM,qCAJI,MAAM,WACK,IAAI,GACd,MAAM,CAYjB;AAoBM,0CAJI,MAAM,WACK,QAAQ,GAAG,CAAC,GACtB,QAAQ,MAAM,CAAC,CAY1B;AASM,4EAFK,OAAO,CAYlB;AAQM,kCALI,MAAM,KACN,MAAM,gCAUhB;AASM,mFAA2F;AAsH3F,oGAFa,GAAG,0BAAK,MAAM,QAAC,GAAG,KAAE,OAAO,wBAE8E;AAQtH,kCAJI,OAAO,6CAIiH;AAM5H,+BAHe,IAAI,QAezB;AAKM;QAFW,MAAM;YAAS,MAAM,UAAW,QAAQ,KAAE,IAAI,GAAC,QAAQ,GAAG,CAAC;;qBAwC5E;AAQM,6BAHI,MAAM,SAMhB;AAQM,4BAHI,OAAO,QAOjB"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["testing.js"],"names":[],"mappings":";AA+DA,gCAAiD;AAGjD,oCAAmG;AAEnG;IACE;;;OAGG;IACH,wBAHW,MAAM,YACN,MAAM,EAahB;IAVC;;OAEG;IACH,YAFU,MAAM,CAEY;IAC5B;;OAEG;IACH,UAFU,MAAM,CAEQ;IACxB,qBAAiB;IACjB,wBAAiB;IAGnB,kBAGC;IAED;;OAEG;IAEH,mBAOC;IAED;;;;OAIG;IACH,sBAMC;CACF;AAED,oCAA6E;AAgBtE,gCANI,MAAM,QACN,MAAM,YACG,QAAQ,KAAE,IAAI,GAAC,QAAQ,GAAG,CAAC,KACpC,MAAM,iBACN,MAAM,oBAyEhB;AAcM,sCAHI,MAAM,SACN,MAAM,QAEwF;AAYlG,2BAFI,MAAM,QAE6B;AAE9C,wDAAoC;AAEpC,8EAA0C;AAoBnC,mCAHI,MAAM,YACG,IAAI,KAAE,IAAI,QAS7B;AAoBM,wCAHI,MAAM,YACG,IAAI,KAAE,QAAQ,GAAG,CAAC,iBASrC;AAoBM,qCAJI,MAAM,WACK,IAAI,GACd,MAAM,CAYjB;AAoBM,0CAJI,MAAM,WACK,QAAQ,GAAG,CAAC,GACtB,QAAQ,MAAM,CAAC,CAY1B;AASM,4EAFK,OAAO,CAYlB;AAQM,kCALI,MAAM,KACN,MAAM,gCAUhB;AASM,mFAA2F;AAsH3F,oGAFa,GAAG,0BAAK,MAAM,QAAC,GAAG,KAAE,OAAO,wBAE8E;AAQtH,kCAJI,OAAO,6CAIiH;AAM5H,+BAHe,IAAI,QAezB;AAKM;QAFW,MAAM;YAAS,MAAM,UAAW,QAAQ,KAAE,IAAI,GAAC,QAAQ,GAAG,CAAC;;qBAwC5E;AAQM,6BAHI,MAAM,SAMhB;AAQM,4BAHI,OAAO,QAOjB"}
package/testing.js CHANGED
@@ -44,7 +44,7 @@
44
44
  */
45
45
 
46
46
  import * as log from './logging.js'
47
- import { simpleDiff } from './diff.js'
47
+ import { simpleDiffString } from './diff.js'
48
48
  import * as object from './object.js'
49
49
  import * as string from './string.js'
50
50
  import * as math from './math.js'
@@ -116,7 +116,7 @@ export class TestCase {
116
116
  }
117
117
  }
118
118
 
119
- export const repititionTime = Number(env.getParam('--repitition-time', '50'))
119
+ export const repetitionTime = Number(env.getParam('--repetition-time', '50'))
120
120
  /* istanbul ignore next */
121
121
  const testFilter = env.hasParam('--filter') ? env.getParam('--filter', '') : null
122
122
 
@@ -151,6 +151,9 @@ export const run = async (moduleName, name, f, i, numberOfTests) => {
151
151
  const times = []
152
152
  const start = performance.now()
153
153
  let lastTime = start
154
+ /**
155
+ * @type {any}
156
+ */
154
157
  let err = null
155
158
  performance.mark(`${name}-start`)
156
159
  do {
@@ -165,12 +168,12 @@ export const run = async (moduleName, name, f, i, numberOfTests) => {
165
168
  const currTime = performance.now()
166
169
  times.push(currTime - lastTime)
167
170
  lastTime = currTime
168
- if (repeat && err === null && (lastTime - start) < repititionTime) {
171
+ if (repeat && err === null && (lastTime - start) < repetitionTime) {
169
172
  tc.resetSeed()
170
173
  } else {
171
174
  break
172
175
  }
173
- } while (err === null && (lastTime - start) < repititionTime)
176
+ } while (err === null && (lastTime - start) < repetitionTime)
174
177
  performance.mark(`${name}-end`)
175
178
  /* istanbul ignore if */
176
179
  if (err !== null && err.constructor !== SkipError) {
@@ -186,7 +189,7 @@ export const run = async (moduleName, name, f, i, numberOfTests) => {
186
189
  ? ` - ${window.location.href}?filter=\\[${i + 1}/${tc._seed === null ? '' : `&seed=${tc._seed}`}`
187
190
  : `\nrepeat: npm run test -- --filter "\\[${i + 1}/" ${tc._seed === null ? '' : `--seed ${tc._seed}`}`
188
191
  const timeInfo = (repeat && err === null)
189
- ? ` - ${times.length} repititions in ${time.humanizeDuration(duration)} (best: ${time.humanizeDuration(times[0])}, worst: ${time.humanizeDuration(array.last(times))}, median: ${time.humanizeDuration(statistics.median(times))}, average: ${time.humanizeDuration(statistics.average(times))})`
192
+ ? ` - ${times.length} repetitions in ${time.humanizeDuration(duration)} (best: ${time.humanizeDuration(times[0])}, worst: ${time.humanizeDuration(array.last(times))}, median: ${time.humanizeDuration(statistics.median(times))}, average: ${time.humanizeDuration(statistics.average(times))})`
190
193
  : ` in ${time.humanizeDuration(duration)}`
191
194
  if (err !== null) {
192
195
  /* istanbul ignore else */
@@ -373,7 +376,7 @@ export const compareArrays = (as, bs, m = 'Arrays match') => {
373
376
  */
374
377
  export const compareStrings = (a, b, m = 'Strings match') => {
375
378
  if (a !== b) {
376
- const diff = simpleDiff(a, b)
379
+ const diff = simpleDiffString(a, b)
377
380
  log.print(log.GREY, a.slice(0, diff.index), log.RED, a.slice(diff.index, diff.remove), log.GREEN, diff.insert, log.GREY, a.slice(diff.index + diff.remove))
378
381
  fail(m)
379
382
  }
package/testing.test.d.ts CHANGED
@@ -2,6 +2,6 @@ export function testComparing(tc: t.TestCase): void;
2
2
  export function testFailing(): void;
3
3
  export function testSkipping(): void;
4
4
  export function testAsync(): Promise<void>;
5
- export function testRepeatRepitition(): void;
5
+ export function testRepeatRepetition(): void;
6
6
  import * as t from "./testing.js";
7
7
  //# sourceMappingURL=testing.test.d.ts.map
package/tree.d.ts CHANGED
@@ -51,7 +51,7 @@ export class Tree<K, V> {
51
51
  * @param {K} id
52
52
  * @return {N<V>|null}
53
53
  */
54
- findNode(id: K): any;
54
+ findNode(id: K): N<V> | null;
55
55
  /**
56
56
  * @param {K} id
57
57
  */
package/tree.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.js"],"names":[],"mappings":"AAyIA;;;;GAIG;AACH;IAEI,UAAgB;IAChB,eAAe;IAGjB;;OAEG;IACH,mBAIC;IAED;;OAEG;IACH,mBAIC;IAED;;OAEG;IACH,qCAwBC;IAED;;OAEG;IACH,mCA2BC;IAED;;OAEG;IACH,sBAMC;IAED;;;OAGG;IACH,+BAGC;IAED;;;OAGG;IACH,6BAGC;IAED;;;;OAIG;IACH,0CAFuB,IAAI,QAoB1B;IAED;;;OAGG;IACH,sBAOC;IAED;;;OAGG;IACH,qBAkBC;IAED;;OAEG;IACH,oBAiEC;IAED,yBAmEC;IAED,iBA+BC;IAED,yBA8CC;CACF;AArgBD;IAEE,sBAMC;IALC,SAAc;IACd,eAAiB;IACjB,WAAiB;IACjB,YAAkB;IAClB,aAAmB;IAGrB,iBAA8B;IAC9B,mBAAiC;IACjC,YAA4C;IAC5C,aAA8C;IAC9C,uBAEC;IAED,kBAEC;IAED,mBAGC;IAUD,mBAKC;IAbD,gBAEC;IAaD,oBAKC;IAhBD,iBAEC;IAgBD,4BAOC;IAED,YAeC;IAED,YAeC;IAED,6BAOC;IAED,gBAOC;CACF"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.js"],"names":[],"mappings":"AAyIA;;;;GAIG;AACH;IAEI,UAAgB;IAChB,eAAe;IAGjB;;OAEG;IACH,aAFW,CAAC,KAMX;IAED;;OAEG;IACH,aAFW,CAAC,KAMX;IAED;;OAEG;IACH,6BAFW,CAAC,OA0BX;IAED;;OAEG;IACH,2BAFW,CAAC,OA6BX;IAED;;OAEG;IACH,oBAFY,CAAC,CAQZ;IAED;;;OAGG;IACH,yBAHW,CAAC,GACA,CAAC,CAKZ;IAED;;;OAGG;IACH,uBAHW,CAAC,GACA,CAAC,CAKZ;IAED;;;;OAIG;IACH,cAJW,CAAC,qBAEQ,CAAC,KAAE,IAAI,QAoB1B;IAED;;;OAGG;IACH,SAHW,CAAC,GACA,CAAC,GAAC,IAAI,CASjB;IAED;;;OAGG;IACH,aAHW,CAAC,GACA,EAAE,CAAC,CAAC,GAAC,IAAI,CAoBpB;IAED;;OAEG;IACH,WAFW,CAAC,QAmEX;IAED,yBAmEC;IAED,iBA+BC;IAED,yBA8CC;CACF;AArgBD;IAEE,sBAMC;IALC,SAAc;IACd,eAAiB;IACjB,WAAiB;IACjB,YAAkB;IAClB,aAAmB;IAGrB,iBAA8B;IAC9B,mBAAiC;IACjC,YAA4C;IAC5C,aAA8C;IAC9C,uBAEC;IAED,kBAEC;IAED,mBAGC;IAUD,mBAKC;IAbD,gBAEC;IAaD,oBAKC;IAhBD,iBAEC;IAgBD,4BAOC;IAED,YAeC;IAED,YAeC;IAED,6BAOC;IAED,gBAOC;CACF"}
package/websocket.d.ts CHANGED
@@ -25,7 +25,7 @@ export class WebsocketClient extends Observable<string> {
25
25
  * @type {boolean}
26
26
  */
27
27
  shouldConnect: boolean;
28
- _checkInterval: NodeJS.Timeout;
28
+ _checkInterval: NodeJS.Timer;
29
29
  /**
30
30
  * @param {any} message
31
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["websocket.js"],"names":[],"mappings":"AAwFA;;GAEG;AACH;IACE;;;;OAIG;IACH,iBAJW,MAAM;;mBA6BhB;IAvBC,YAAc;IACd;;OAEG;IACH,IAFU,SAAS,QAEL;IACd,0CAAoC;IACpC,mBAAsB;IACtB,oBAAuB;IACvB,+BAA+B;IAC/B,4BAA4B;IAC5B;;;OAGG;IACH,eAFU,OAAO,CAEQ;IACzB,+BAM+B;IAIjC;;OAEG;IACH,cAFW,GAAG,QAMb;IAQD,mBAKC;IAED,gBAKC;CACF"}
1
+ {"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["websocket.js"],"names":[],"mappings":"AAwFA;;GAEG;AACH;IACE;;;;OAIG;IACH,iBAJW,MAAM;;mBA6BhB;IAvBC,YAAc;IACd;;OAEG;IACH,IAFU,SAAS,QAEL;IACd,0CAAoC;IACpC,mBAAsB;IACtB,oBAAuB;IACvB,+BAA+B;IAC/B,4BAA4B;IAC5B;;;OAGG;IACH,eAFU,OAAO,CAEQ;IACzB,6BAM+B;IAIjC;;OAEG;IACH,cAFW,GAAG,QAMb;IAQD,mBAKC;IAED,gBAKC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"broadcastchannel-cb74c2ae.cjs","sources":["../broadcastchannel.js"],"sourcesContent":["/* eslint-env browser */\n\n/**\n * Helpers for cross-tab communication using broadcastchannel with LocalStorage fallback.\n *\n * ```js\n * // In browser window A:\n * broadcastchannel.subscribe('my events', data => console.log(data))\n * broadcastchannel.publish('my events', 'Hello world!') // => A: 'Hello world!' fires synchronously in same tab\n *\n * // In browser window B:\n * broadcastchannel.publish('my events', 'hello from tab B') // => A: 'hello from tab B'\n * ```\n *\n * @module broadcastchannel\n */\n\n// @todo before next major: use Uint8Array instead as buffer object\n\nimport * as map from './map.js'\nimport * as buffer from './buffer.js'\nimport * as storage from './storage.js'\n\n/**\n * @typedef {Object} Channel\n * @property {Set<Function>} Channel.subs\n * @property {any} Channel.bc\n */\n\n/**\n * @type {Map<string, Channel>}\n */\nconst channels = new Map()\n\nclass LocalStoragePolyfill {\n /**\n * @param {string} room\n */\n constructor (room) {\n this.room = room\n /**\n * @type {null|function({data:ArrayBuffer}):void}\n */\n this.onmessage = null\n addEventListener('storage', e => e.key === room && this.onmessage !== null && this.onmessage({ data: buffer.fromBase64(e.newValue || '') }))\n }\n\n /**\n * @param {ArrayBuffer} buf\n */\n postMessage (buf) {\n storage.varStorage.setItem(this.room, buffer.toBase64(buffer.createUint8ArrayFromArrayBuffer(buf)))\n }\n}\n\n// Use BroadcastChannel or Polyfill\nconst BC = typeof BroadcastChannel === 'undefined' ? LocalStoragePolyfill : BroadcastChannel\n\n/**\n * @param {string} room\n * @return {Channel}\n */\nconst getChannel = room =>\n map.setIfUndefined(channels, room, () => {\n const subs = new Set()\n const bc = new BC(room)\n /**\n * @param {{data:ArrayBuffer}} e\n */\n bc.onmessage = e => subs.forEach(sub => sub(e.data))\n return {\n bc, subs\n }\n })\n\n/**\n * Subscribe to global `publish` events.\n *\n * @function\n * @param {string} room\n * @param {function(any):any} f\n */\nexport const subscribe = (room, f) => getChannel(room).subs.add(f)\n\n/**\n * Unsubscribe from `publish` global events.\n *\n * @function\n * @param {string} room\n * @param {function(any):any} f\n */\nexport const unsubscribe = (room, f) => getChannel(room).subs.delete(f)\n\n/**\n * Publish data to all subscribers (including subscribers on this tab)\n *\n * @function\n * @param {string} room\n * @param {any} data\n */\nexport const publish = (room, data) => {\n const c = getChannel(room)\n c.bc.postMessage(data)\n c.subs.forEach(sub => sub(data))\n}\n"],"names":["buffer.fromBase64","storage.varStorage","buffer.toBase64","buffer.createUint8ArrayFromArrayBuffer","map.setIfUndefined"],"mappings":";;;;;;AAAA;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAE;AAC1B;AACA,MAAM,oBAAoB,CAAC;AAC3B;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,IAAI,EAAE;AACrB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAI;AACpB;AACA;AACA;AACA,IAAI,IAAI,CAAC,SAAS,GAAG,KAAI;AACzB,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAEA,mBAAiB,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC,EAAC;AAChJ,GAAG;AACH;AACA;AACA;AACA;AACA,EAAE,WAAW,CAAC,CAAC,GAAG,EAAE;AACpB,IAAIC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAEC,iBAAe,CAACC,wCAAsC,CAAC,GAAG,CAAC,CAAC,EAAC;AACvG,GAAG;AACH,CAAC;AACD;AACA;AACA,MAAM,EAAE,GAAG,OAAO,gBAAgB,KAAK,WAAW,GAAG,oBAAoB,GAAG,iBAAgB;AAC5F;AACA;AACA;AACA;AACA;AACA,MAAM,UAAU,GAAG,IAAI;AACvB,EAAEC,kBAAkB,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM;AAC3C,IAAI,MAAM,IAAI,GAAG,IAAI,GAAG,GAAE;AAC1B,IAAI,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI,EAAC;AAC3B;AACA;AACA;AACA,IAAI,EAAE,CAAC,SAAS,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAC;AACxD,IAAI,OAAO;AACX,MAAM,EAAE,EAAE,IAAI;AACd,KAAK;AACL,GAAG,EAAC;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAC;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,WAAW,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAC;AACvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK;AACvC,EAAE,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,EAAC;AAC5B,EAAE,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,EAAC;AACxB,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,EAAC;AAClC;;;;;;;;;;;;;;"}