lib0 0.2.63 → 0.2.64
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/array.test.d.ts +6 -5
- package/array.test.d.ts.map +1 -1
- package/bin/gendocs.js +0 -1
- package/bin/gentesthtml.js +54 -0
- package/broadcastchannel.d.ts.map +1 -1
- package/broadcastchannel.js +4 -4
- package/buffer.d.ts.map +1 -1
- package/buffer.js +6 -4
- package/conditions.js +1 -1
- package/coverage/tmp/coverage-17397-1678220559587-0.json +1 -0
- package/crypto.d.ts.map +1 -1
- package/crypto.js +6 -5
- package/crypto.test.d.ts.map +1 -1
- package/decoding.d.ts.map +1 -1
- package/decoding.js +7 -4
- package/deno.json +7 -0
- package/deno.lock +122 -0
- package/dist/{array-5347125b.cjs → array-a1682de6.cjs} +2 -2
- package/dist/{array-5347125b.cjs.map → array-a1682de6.cjs.map} +1 -1
- package/dist/array.cjs +2 -2
- package/dist/array.test.d.ts +6 -5
- package/dist/array.test.d.ts.map +1 -1
- package/dist/{broadcastchannel-61da4e94.cjs → broadcastchannel-4e5909e2.cjs} +8 -8
- package/dist/broadcastchannel-4e5909e2.cjs.map +1 -0
- package/dist/broadcastchannel.cjs +12 -12
- package/dist/broadcastchannel.d.ts.map +1 -1
- package/dist/{buffer-884e5a1d.cjs → buffer-9b566988.cjs} +20 -16
- package/dist/buffer-9b566988.cjs.map +1 -0
- package/dist/buffer.cjs +11 -11
- package/dist/buffer.d.ts.map +1 -1
- package/dist/cache.cjs +7 -7
- package/dist/component.cjs +9 -9
- package/dist/{conditions-fb475c70.cjs → conditions-f5c0c102.cjs} +2 -2
- package/dist/conditions-f5c0c102.cjs.map +1 -0
- package/dist/conditions.cjs +1 -1
- package/dist/crypto.cjs +17 -16
- package/dist/crypto.cjs.map +1 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.test.d.ts.map +1 -1
- package/dist/decoding.cjs +11 -11
- package/dist/decoding.d.ts.map +1 -1
- package/dist/{diff-2cbda723.cjs → diff-55061848.cjs} +2 -2
- package/dist/{diff-2cbda723.cjs.map → diff-55061848.cjs.map} +1 -1
- package/dist/diff.cjs +5 -5
- package/dist/{dom-58958c04.cjs → dom-7ef10fba.cjs} +4 -32
- package/dist/dom-7ef10fba.cjs.map +1 -0
- package/dist/dom.cjs +2 -2
- package/dist/dom.d.ts.map +1 -1
- package/dist/encoding.cjs +11 -11
- package/dist/encoding.d.ts.map +1 -1
- package/dist/encoding.test.d.ts +2 -1
- package/dist/encoding.test.d.ts.map +1 -1
- package/dist/{environment-ad5e7386.cjs → environment-01c0e75b.cjs} +20 -19
- package/dist/environment-01c0e75b.cjs.map +1 -0
- package/dist/environment.cjs +8 -8
- package/dist/environment.d.ts.map +1 -1
- package/dist/{error-873c9cbf.cjs → error-8582d695.cjs} +4 -4
- package/dist/error-8582d695.cjs.map +1 -0
- package/dist/error.cjs +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/{eventloop-c60b5658.cjs → eventloop-d0571621.cjs} +5 -5
- package/dist/eventloop-d0571621.cjs.map +1 -0
- package/dist/eventloop.cjs +1 -1
- package/dist/eventloop.d.ts.map +1 -1
- package/dist/eventloop.test.d.ts +6 -5
- package/dist/eventloop.test.d.ts.map +1 -1
- package/dist/{function-3695121b.cjs → function-35e8ddea.cjs} +6 -3
- package/dist/function-35e8ddea.cjs.map +1 -0
- package/dist/function.cjs +4 -4
- package/dist/function.d.ts.map +1 -1
- package/dist/function.test.d.ts +3 -1
- package/dist/function.test.d.ts.map +1 -1
- package/dist/index.cjs +22 -22
- package/dist/{indexeddb-7b2c0026.cjs → indexeddb-1f25af34.cjs} +7 -30
- package/dist/indexeddb-1f25af34.cjs.map +1 -0
- package/dist/indexeddb.cjs +4 -4
- package/dist/indexeddb.d.ts.map +1 -1
- package/dist/list.cjs +7 -6
- package/dist/list.cjs.map +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/list.test.d.ts +2 -2
- package/dist/list.test.d.ts.map +1 -1
- package/dist/{logging-70fd0a99.cjs → logging-641c32f4.cjs} +55 -50
- package/dist/logging-641c32f4.cjs.map +1 -0
- package/dist/logging.cjs +12 -12
- package/dist/logging.d.ts.map +1 -1
- package/dist/{map-28a001c9.cjs → map-9a5915e4.cjs} +6 -5
- package/dist/map-9a5915e4.cjs.map +1 -0
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.test.d.ts +1 -1
- package/dist/map.test.d.ts.map +1 -1
- package/dist/{number-e62129bc.cjs → number-f97e141a.cjs} +2 -2
- package/dist/number-f97e141a.cjs.map +1 -0
- package/dist/number.cjs +1 -1
- package/dist/{object-fe9c0021.cjs → object-aad630ed.cjs} +6 -3
- package/dist/object-aad630ed.cjs.map +1 -0
- package/dist/object.cjs +1 -1
- package/dist/object.d.ts +3 -3
- package/dist/object.d.ts.map +1 -1
- package/dist/object.test.d.ts.map +1 -1
- package/dist/observable.cjs +3 -3
- package/dist/{prng-397a85ab.cjs → prng-cd2451c9.cjs} +5 -4
- package/dist/prng-cd2451c9.cjs.map +1 -0
- package/dist/prng.cjs +12 -12
- package/dist/prng.d.ts.map +1 -1
- package/dist/{promise-1a9fe712.cjs → promise-a4f32c85.cjs} +3 -3
- package/dist/promise-a4f32c85.cjs.map +1 -0
- package/dist/promise.cjs +2 -2
- package/dist/random.test.d.ts +1 -0
- package/dist/random.test.d.ts.map +1 -1
- package/dist/rollup.config.d.ts +2 -28
- package/dist/{set-b596ef38.cjs → set-0f209abb.cjs} +4 -7
- package/dist/set-0f209abb.cjs.map +1 -0
- package/dist/set.cjs +1 -1
- package/dist/set.d.ts.map +1 -1
- package/dist/set.test.d.ts +1 -1
- package/dist/set.test.d.ts.map +1 -1
- package/dist/sort.test.d.ts +2 -1
- package/dist/sort.test.d.ts.map +1 -1
- package/dist/storage.cjs +6 -5
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/{string-ad04f734.cjs → string-b1bee84b.cjs} +8 -7
- package/dist/string-b1bee84b.cjs.map +1 -0
- package/dist/string.cjs +1 -1
- package/dist/string.d.ts.map +1 -1
- package/dist/symbol.test.d.ts +3 -0
- package/dist/symbol.test.d.ts.map +1 -0
- package/dist/testing.cjs +42 -40
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.test.d.ts +1 -0
- package/dist/testing.test.d.ts.map +1 -1
- package/dist/{time-e00067da.cjs → time-bc2081b9.cjs} +2 -2
- package/dist/time-bc2081b9.cjs.map +1 -0
- package/dist/time.cjs +1 -1
- package/dist/{tree-b67c7947.cjs → tree-9f3c8837.cjs} +23 -22
- package/dist/tree-9f3c8837.cjs.map +1 -0
- package/dist/tree.cjs +1 -1
- package/dist/tree.d.ts.map +1 -1
- package/dist/url.cjs +2 -2
- package/dist/url.cjs.map +1 -1
- package/dist/webcrypto.deno.cjs +12 -0
- package/dist/webcrypto.deno.cjs.map +1 -0
- package/dist/webcrypto.deno.d.ts +3 -0
- package/dist/webcrypto.deno.d.ts.map +1 -0
- package/dist/{websocket-dd57e44f.cjs → websocket-85f1d597.cjs} +2 -2
- package/dist/{websocket-dd57e44f.cjs.map → websocket-85f1d597.cjs.map} +1 -1
- package/dist/websocket.cjs +5 -5
- package/dom.d.ts.map +1 -1
- package/dom.js +2 -30
- package/encoding.d.ts.map +1 -1
- package/encoding.js +2 -3
- package/encoding.test.d.ts +2 -1
- package/encoding.test.d.ts.map +1 -1
- package/environment.d.ts.map +1 -1
- package/environment.js +15 -14
- package/error.d.ts.map +1 -1
- package/error.js +3 -3
- package/eventloop.d.ts.map +1 -1
- package/eventloop.js +4 -4
- package/eventloop.test.d.ts +6 -5
- package/eventloop.test.d.ts.map +1 -1
- package/function.d.ts.map +1 -1
- package/function.js +3 -0
- package/function.test.d.ts +3 -1
- package/function.test.d.ts.map +1 -1
- package/indexeddb.d.ts.map +1 -1
- package/indexeddb.js +4 -27
- package/list.d.ts.map +1 -1
- package/list.js +2 -1
- package/list.test.d.ts +2 -2
- package/list.test.d.ts.map +1 -1
- package/logging.d.ts.map +1 -1
- package/logging.js +47 -42
- package/map.d.ts +1 -1
- package/map.d.ts.map +1 -1
- package/map.js +5 -4
- package/map.test.d.ts +1 -1
- package/map.test.d.ts.map +1 -1
- package/number.js +1 -1
- package/object.d.ts +3 -3
- package/object.d.ts.map +1 -1
- package/object.js +5 -2
- package/object.test.d.ts.map +1 -1
- package/package.json +16 -12
- package/prng.d.ts.map +1 -1
- package/prng.js +2 -1
- package/promise.js +1 -1
- package/random.test.d.ts +1 -0
- package/random.test.d.ts.map +1 -1
- package/rollup.config.d.ts +2 -28
- package/set.d.ts.map +1 -1
- package/set.js +3 -6
- package/set.test.d.ts +1 -1
- package/set.test.d.ts.map +1 -1
- package/sort.test.d.ts +2 -1
- package/sort.test.d.ts.map +1 -1
- package/storage.d.ts.map +1 -1
- package/storage.js +6 -5
- package/string.d.ts.map +1 -1
- package/string.js +7 -6
- package/symbol.test.d.ts +3 -0
- package/symbol.test.d.ts.map +1 -0
- package/test.html +148 -2
- package/test.js +5 -3
- package/testing.d.ts +1 -1
- package/testing.d.ts.map +1 -1
- package/testing.js +24 -22
- package/testing.test.d.ts +1 -0
- package/testing.test.d.ts.map +1 -1
- package/time.js +1 -1
- package/tree.d.ts.map +1 -1
- package/tree.js +22 -21
- package/url.js +1 -1
- package/webcrypto.deno.d.ts +3 -0
- package/webcrypto.deno.d.ts.map +1 -0
- package/webcrypto.deno.js +4 -0
- package/dist/broadcastchannel-61da4e94.cjs.map +0 -1
- package/dist/buffer-884e5a1d.cjs.map +0 -1
- package/dist/conditions-fb475c70.cjs.map +0 -1
- package/dist/dom-58958c04.cjs.map +0 -1
- package/dist/environment-ad5e7386.cjs.map +0 -1
- package/dist/error-873c9cbf.cjs.map +0 -1
- package/dist/eventloop-c60b5658.cjs.map +0 -1
- package/dist/function-3695121b.cjs.map +0 -1
- package/dist/indexeddb-7b2c0026.cjs.map +0 -1
- package/dist/logging-70fd0a99.cjs.map +0 -1
- package/dist/map-28a001c9.cjs.map +0 -1
- package/dist/number-e62129bc.cjs.map +0 -1
- package/dist/object-fe9c0021.cjs.map +0 -1
- package/dist/prng-397a85ab.cjs.map +0 -1
- package/dist/promise-1a9fe712.cjs.map +0 -1
- package/dist/set-b596ef38.cjs.map +0 -1
- package/dist/string-ad04f734.cjs.map +0 -1
- package/dist/time-e00067da.cjs.map +0 -1
- package/dist/tree-b67c7947.cjs.map +0 -1
package/logging.js
CHANGED
|
@@ -53,11 +53,11 @@ const _nodeStyleMap = {
|
|
|
53
53
|
[UNCOLOR]: '\x1b[0m'
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
/* istanbul ignore next */
|
|
57
56
|
/**
|
|
58
57
|
* @param {Array<string|Symbol|Object|number>} args
|
|
59
58
|
* @return {Array<string|object|number>}
|
|
60
59
|
*/
|
|
60
|
+
/* c8 ignore start */
|
|
61
61
|
const computeBrowserLoggingArgs = (args) => {
|
|
62
62
|
const strBuilder = []
|
|
63
63
|
const styles = []
|
|
@@ -68,7 +68,6 @@ const computeBrowserLoggingArgs = (args) => {
|
|
|
68
68
|
let logArgs = []
|
|
69
69
|
// try with formatting until we find something unsupported
|
|
70
70
|
let i = 0
|
|
71
|
-
|
|
72
71
|
for (; i < args.length; i++) {
|
|
73
72
|
const arg = args[i]
|
|
74
73
|
// @ts-ignore
|
|
@@ -89,7 +88,6 @@ const computeBrowserLoggingArgs = (args) => {
|
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
|
|
93
91
|
if (i > 0) {
|
|
94
92
|
// create logArgs with what we have so far
|
|
95
93
|
logArgs = styles
|
|
@@ -104,8 +102,9 @@ const computeBrowserLoggingArgs = (args) => {
|
|
|
104
102
|
}
|
|
105
103
|
return logArgs
|
|
106
104
|
}
|
|
105
|
+
/* c8 ignore stop */
|
|
107
106
|
|
|
108
|
-
/*
|
|
107
|
+
/* c8 ignore start */
|
|
109
108
|
/**
|
|
110
109
|
* @param {Array<string|Symbol|Object|number>} args
|
|
111
110
|
* @return {Array<string|object|number>}
|
|
@@ -113,10 +112,8 @@ const computeBrowserLoggingArgs = (args) => {
|
|
|
113
112
|
const computeNoColorLoggingArgs = args => {
|
|
114
113
|
const strBuilder = []
|
|
115
114
|
const logArgs = []
|
|
116
|
-
|
|
117
115
|
// try with formatting until we find something unsupported
|
|
118
116
|
let i = 0
|
|
119
|
-
|
|
120
117
|
for (; i < args.length; i++) {
|
|
121
118
|
const arg = args[i]
|
|
122
119
|
// @ts-ignore
|
|
@@ -135,7 +132,6 @@ const computeNoColorLoggingArgs = args => {
|
|
|
135
132
|
// append the rest
|
|
136
133
|
for (; i < args.length; i++) {
|
|
137
134
|
const arg = args[i]
|
|
138
|
-
/* istanbul ignore else */
|
|
139
135
|
if (!(arg instanceof Symbol)) {
|
|
140
136
|
if (arg.constructor === Object) {
|
|
141
137
|
logArgs.push(JSON.stringify(arg))
|
|
@@ -146,8 +142,9 @@ const computeNoColorLoggingArgs = args => {
|
|
|
146
142
|
}
|
|
147
143
|
return logArgs
|
|
148
144
|
}
|
|
145
|
+
/* c8 ignore stop */
|
|
149
146
|
|
|
150
|
-
/*
|
|
147
|
+
/* c8 ignore start */
|
|
151
148
|
/**
|
|
152
149
|
* @param {Array<string|Symbol|Object|number>} args
|
|
153
150
|
* @return {Array<string|object|number>}
|
|
@@ -155,10 +152,8 @@ const computeNoColorLoggingArgs = args => {
|
|
|
155
152
|
const computeNodeLoggingArgs = (args) => {
|
|
156
153
|
const strBuilder = []
|
|
157
154
|
const logArgs = []
|
|
158
|
-
|
|
159
155
|
// try with formatting until we find something unsupported
|
|
160
156
|
let i = 0
|
|
161
|
-
|
|
162
157
|
for (; i < args.length; i++) {
|
|
163
158
|
const arg = args[i]
|
|
164
159
|
// @ts-ignore
|
|
@@ -181,29 +176,30 @@ const computeNodeLoggingArgs = (args) => {
|
|
|
181
176
|
// append the rest
|
|
182
177
|
for (; i < args.length; i++) {
|
|
183
178
|
const arg = args[i]
|
|
184
|
-
/* istanbul ignore else */
|
|
185
179
|
if (!(arg instanceof Symbol)) {
|
|
186
180
|
logArgs.push(arg)
|
|
187
181
|
}
|
|
188
182
|
}
|
|
189
183
|
return logArgs
|
|
190
184
|
}
|
|
185
|
+
/* c8 ignore stop */
|
|
191
186
|
|
|
192
|
-
/*
|
|
187
|
+
/* c8 ignore start */
|
|
193
188
|
const computeLoggingArgs = env.supportsColor
|
|
194
189
|
? (env.isNode ? computeNodeLoggingArgs : computeBrowserLoggingArgs)
|
|
195
190
|
: computeNoColorLoggingArgs
|
|
191
|
+
/* c8 ignore stop */
|
|
196
192
|
|
|
197
193
|
/**
|
|
198
194
|
* @param {Array<string|Symbol|Object|number>} args
|
|
199
195
|
*/
|
|
200
196
|
export const print = (...args) => {
|
|
201
197
|
console.log(...computeLoggingArgs(args))
|
|
202
|
-
/*
|
|
198
|
+
/* c8 ignore next */
|
|
203
199
|
vconsoles.forEach((vc) => vc.print(args))
|
|
204
200
|
}
|
|
205
201
|
|
|
206
|
-
/*
|
|
202
|
+
/* c8 ignore start */
|
|
207
203
|
/**
|
|
208
204
|
* @param {Array<string|Symbol|Object|number>} args
|
|
209
205
|
*/
|
|
@@ -212,21 +208,23 @@ export const warn = (...args) => {
|
|
|
212
208
|
args.unshift(ORANGE)
|
|
213
209
|
vconsoles.forEach((vc) => vc.print(args))
|
|
214
210
|
}
|
|
211
|
+
/* c8 ignore stop */
|
|
215
212
|
|
|
216
|
-
/* istanbul ignore next */
|
|
217
213
|
/**
|
|
218
214
|
* @param {Error} err
|
|
219
215
|
*/
|
|
216
|
+
/* c8 ignore start */
|
|
220
217
|
export const printError = (err) => {
|
|
221
218
|
console.error(err)
|
|
222
219
|
vconsoles.forEach((vc) => vc.printError(err))
|
|
223
220
|
}
|
|
221
|
+
/* c8 ignore stop */
|
|
224
222
|
|
|
225
|
-
/* istanbul ignore next */
|
|
226
223
|
/**
|
|
227
224
|
* @param {string} url image location
|
|
228
225
|
* @param {number} height height of the image in pixel
|
|
229
226
|
*/
|
|
227
|
+
/* c8 ignore start */
|
|
230
228
|
export const printImg = (url, height) => {
|
|
231
229
|
if (env.isBrowser) {
|
|
232
230
|
console.log(
|
|
@@ -237,12 +235,13 @@ export const printImg = (url, height) => {
|
|
|
237
235
|
}
|
|
238
236
|
vconsoles.forEach((vc) => vc.printImg(url, height))
|
|
239
237
|
}
|
|
238
|
+
/* c8 ignore stop */
|
|
240
239
|
|
|
241
|
-
/* istanbul ignore next */
|
|
242
240
|
/**
|
|
243
241
|
* @param {string} base64
|
|
244
242
|
* @param {number} height
|
|
245
243
|
*/
|
|
244
|
+
/* c8 ignore next 2 */
|
|
246
245
|
export const printImgBase64 = (base64, height) =>
|
|
247
246
|
printImg(`data:image/gif;base64,${base64}`, height)
|
|
248
247
|
|
|
@@ -251,7 +250,7 @@ export const printImgBase64 = (base64, height) =>
|
|
|
251
250
|
*/
|
|
252
251
|
export const group = (...args) => {
|
|
253
252
|
console.group(...computeLoggingArgs(args))
|
|
254
|
-
/*
|
|
253
|
+
/* c8 ignore next */
|
|
255
254
|
vconsoles.forEach((vc) => vc.group(args))
|
|
256
255
|
}
|
|
257
256
|
|
|
@@ -260,38 +259,38 @@ export const group = (...args) => {
|
|
|
260
259
|
*/
|
|
261
260
|
export const groupCollapsed = (...args) => {
|
|
262
261
|
console.groupCollapsed(...computeLoggingArgs(args))
|
|
263
|
-
/*
|
|
262
|
+
/* c8 ignore next */
|
|
264
263
|
vconsoles.forEach((vc) => vc.groupCollapsed(args))
|
|
265
264
|
}
|
|
266
265
|
|
|
267
266
|
export const groupEnd = () => {
|
|
268
267
|
console.groupEnd()
|
|
269
|
-
/*
|
|
268
|
+
/* c8 ignore next */
|
|
270
269
|
vconsoles.forEach((vc) => vc.groupEnd())
|
|
271
270
|
}
|
|
272
271
|
|
|
273
|
-
/* istanbul ignore next */
|
|
274
272
|
/**
|
|
275
273
|
* @param {function():Node} createNode
|
|
276
274
|
*/
|
|
275
|
+
/* c8 ignore next 2 */
|
|
277
276
|
export const printDom = (createNode) =>
|
|
278
277
|
vconsoles.forEach((vc) => vc.printDom(createNode()))
|
|
279
278
|
|
|
280
|
-
/* istanbul ignore next */
|
|
281
279
|
/**
|
|
282
280
|
* @param {HTMLCanvasElement} canvas
|
|
283
281
|
* @param {number} height
|
|
284
282
|
*/
|
|
283
|
+
/* c8 ignore next 2 */
|
|
285
284
|
export const printCanvas = (canvas, height) =>
|
|
286
285
|
printImg(canvas.toDataURL(), height)
|
|
287
286
|
|
|
288
287
|
export const vconsoles = set.create()
|
|
289
288
|
|
|
290
|
-
/* istanbul ignore next */
|
|
291
289
|
/**
|
|
292
290
|
* @param {Array<string|Symbol|Object|number>} args
|
|
293
291
|
* @return {Array<Element>}
|
|
294
292
|
*/
|
|
293
|
+
/* c8 ignore start */
|
|
295
294
|
const _computeLineSpans = (args) => {
|
|
296
295
|
const spans = []
|
|
297
296
|
const currentStyle = new Map()
|
|
@@ -332,11 +331,12 @@ const _computeLineSpans = (args) => {
|
|
|
332
331
|
}
|
|
333
332
|
return spans
|
|
334
333
|
}
|
|
334
|
+
/* c8 ignore stop */
|
|
335
335
|
|
|
336
336
|
const lineStyle =
|
|
337
337
|
'font-family:monospace;border-bottom:1px solid #e2e2e2;padding:2px;'
|
|
338
338
|
|
|
339
|
-
/*
|
|
339
|
+
/* c8 ignore start */
|
|
340
340
|
export class VConsole {
|
|
341
341
|
/**
|
|
342
342
|
* @param {Element} dom
|
|
@@ -461,17 +461,19 @@ export class VConsole {
|
|
|
461
461
|
})
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
+
/* c8 ignore stop */
|
|
464
465
|
|
|
465
|
-
/* istanbul ignore next */
|
|
466
466
|
/**
|
|
467
467
|
* @param {Element} dom
|
|
468
468
|
*/
|
|
469
|
+
/* c8 ignore next */
|
|
469
470
|
export const createVConsole = (dom) => new VConsole(dom)
|
|
470
471
|
|
|
471
472
|
const loggingColors = [GREEN, PURPLE, ORANGE, BLUE]
|
|
472
473
|
let nextColor = 0
|
|
473
474
|
let lastLoggingTime = time.getUnixTime()
|
|
474
475
|
|
|
476
|
+
/* c8 ignore start */
|
|
475
477
|
/**
|
|
476
478
|
* @param {string} moduleName
|
|
477
479
|
* @return {function(...any):void}
|
|
@@ -485,21 +487,24 @@ export const createModuleLogger = (moduleName) => {
|
|
|
485
487
|
nextColor = (nextColor + 1) % loggingColors.length
|
|
486
488
|
moduleName += ': '
|
|
487
489
|
|
|
488
|
-
return !doLogging
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
490
|
+
return !doLogging
|
|
491
|
+
? func.nop
|
|
492
|
+
: (...args) => {
|
|
493
|
+
const timeNow = time.getUnixTime()
|
|
494
|
+
const timeDiff = timeNow - lastLoggingTime
|
|
495
|
+
lastLoggingTime = timeNow
|
|
496
|
+
print(
|
|
497
|
+
color,
|
|
498
|
+
moduleName,
|
|
499
|
+
UNCOLOR,
|
|
500
|
+
...args.map((arg) =>
|
|
501
|
+
(typeof arg === 'string' || typeof arg === 'symbol')
|
|
502
|
+
? arg
|
|
503
|
+
: JSON.stringify(arg)
|
|
504
|
+
),
|
|
505
|
+
color,
|
|
506
|
+
' +' + timeDiff + 'ms'
|
|
507
|
+
)
|
|
508
|
+
}
|
|
505
509
|
}
|
|
510
|
+
/* c8 ignore stop */
|
package/map.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function create(): Map<any, any>;
|
|
2
2
|
export function copy<X, Y>(m: Map<X, Y>): Map<X, Y>;
|
|
3
|
-
export function setIfUndefined<
|
|
3
|
+
export function setIfUndefined<V, K, MAP extends Map<K, V>>(map: MAP, key: K, createT: () => V): V;
|
|
4
4
|
export function map<K, V, R>(m: Map<K, V>, f: (arg0: V, arg1: K) => R): R[];
|
|
5
5
|
export function any<K, V>(m: Map<K, V>, f: (arg0: V, arg1: K) => boolean): boolean;
|
|
6
6
|
export function all<K, V>(m: Map<K, V>, f: (arg0: V, arg1: K) => boolean): boolean;
|
package/map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["map.js"],"names":[],"mappings":"AAcO,0BAJK,IAAI,GAAG,EAAE,GAAG,CAAC,CAIY;AAU9B,oDAIN;
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["map.js"],"names":[],"mappings":"AAcO,0BAJK,IAAI,GAAG,EAAE,GAAG,CAAC,CAIY;AAU9B,oDAIN;AAkBM,mGAMN;AAaM,4EAMN;AAcM,iEAHkB,OAAO,GACpB,OAAO,CASlB;AAYM,iEAHkB,OAAO,GACpB,OAAO,CASlB"}
|
package/map.js
CHANGED
|
@@ -37,11 +37,12 @@ export const copy = m => {
|
|
|
37
37
|
* ```
|
|
38
38
|
*
|
|
39
39
|
* @function
|
|
40
|
-
* @template
|
|
41
|
-
* @
|
|
40
|
+
* @template V,K
|
|
41
|
+
* @template {Map<K,V>} MAP
|
|
42
|
+
* @param {MAP} map
|
|
42
43
|
* @param {K} key
|
|
43
|
-
* @param {function():
|
|
44
|
-
* @return {
|
|
44
|
+
* @param {function():V} createT
|
|
45
|
+
* @return {V}
|
|
45
46
|
*/
|
|
46
47
|
export const setIfUndefined = (map, key, createT) => {
|
|
47
48
|
let set = map.get(key)
|
package/map.test.d.ts
CHANGED
package/map.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.test.d.ts","sourceRoot":"","sources":["map.test.js"],"names":[],"mappings":"AAOO,
|
|
1
|
+
{"version":3,"file":"map.test.d.ts","sourceRoot":"","sources":["map.test.js"],"names":[],"mappings":"AAOO,6BAFI,EAAE,QAAQ,QAsBpB"}
|
package/number.js
CHANGED
|
@@ -20,7 +20,7 @@ export const HIGHEST_INT32 = binary.BITS31
|
|
|
20
20
|
* @module number
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/*
|
|
23
|
+
/* c8 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
26
|
export const parseInt = Number.parseInt
|
package/object.d.ts
CHANGED
|
@@ -17,9 +17,9 @@ export const keys: {
|
|
|
17
17
|
(o: object): string[];
|
|
18
18
|
(o: {}): string[];
|
|
19
19
|
};
|
|
20
|
-
export function forEach(obj: {
|
|
21
|
-
[
|
|
22
|
-
}, f: (arg0:
|
|
20
|
+
export function forEach<V>(obj: {
|
|
21
|
+
[k: string]: V;
|
|
22
|
+
}, f: (arg0: V, arg1: string) => any): void;
|
|
23
23
|
export function map<R>(obj: {
|
|
24
24
|
[x: string]: any;
|
|
25
25
|
}, f: (arg0: any, arg1: string) => R): R[];
|
package/object.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.js"],"names":[],"mappings":"AASO;QAFY,MAAM,GAAC,GAAG;EAEkB;AAE/C;;GAEG;AACH;;;;;EAAmC;AAEnC;;GAEG;AACH;;;EAA+B;
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["object.js"],"names":[],"mappings":"AASO;QAFY,MAAM,GAAC,GAAG;EAEkB;AAE/C;;GAEG;AACH;;;;;EAAmC;AAEnC;;GAEG;AACH;;;EAA+B;AAOxB;;sBAFe,MAAM,KAAE,GAAG,QAMhC;AAUM;QAJW,MAAM,GAAC,GAAG;aACR,GAAG,QAAC,MAAM,aAS7B;AAMM;QAHW,MAAM,GAAC,GAAG;IAChB,MAAM,CAE2B;AAOtC;QAJW,MAAM,GAAC,GAAG;aACR,GAAG,QAAC,MAAM,KAAE,OAAO,GAC3B,OAAO,CASlB;AAKM,6BAFI,MAAM,GAAC,SAAS,WAO1B;AAOM;QAJW,MAAM,GAAC,GAAG;aACR,GAAG,QAAC,MAAM,KAAE,OAAO,GAC3B,OAAO,CASlB;AASM,iCAJI,GAAG,OACH,MAAM,GAAC,MAAM,GACZ,OAAO,CAEoE;AAOhF;QAJW,MAAM,GAAC,GAAG;;QACV,MAAM,GAAC,GAAG;IAChB,OAAO,CAE4I"}
|
package/object.js
CHANGED
|
@@ -20,8 +20,9 @@ export const assign = Object.assign
|
|
|
20
20
|
export const keys = Object.keys
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @
|
|
24
|
-
* @param {
|
|
23
|
+
* @template V
|
|
24
|
+
* @param {{[k:string]:V}} obj
|
|
25
|
+
* @param {function(V,string):any} f
|
|
25
26
|
*/
|
|
26
27
|
export const forEach = (obj, f) => {
|
|
27
28
|
for (const key in obj) {
|
|
@@ -30,6 +31,8 @@ export const forEach = (obj, f) => {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/**
|
|
34
|
+
* @todo implement mapToArray & map
|
|
35
|
+
*
|
|
33
36
|
* @template R
|
|
34
37
|
* @param {Object<string,any>} obj
|
|
35
38
|
* @param {function(any,string):R} f
|
package/object.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.test.d.ts","sourceRoot":"","sources":["object.test.js"],"names":[],"mappings":"AAOO,gCAFI,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"object.test.d.ts","sourceRoot":"","sources":["object.test.js"],"names":[],"mappings":"AAOO,gCAFI,EAAE,QAAQ,QA+BpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lib0",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.64",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"type": "GitHub Sponsors ❤",
|
|
12
12
|
"url": "https://github.com/sponsors/dmonad"
|
|
13
13
|
},
|
|
14
|
+
"bin": {
|
|
15
|
+
"0gentesthtml": "./bin/gentesthtml.js"
|
|
16
|
+
},
|
|
14
17
|
"exports": {
|
|
15
18
|
"./package.json": "./package.json",
|
|
16
19
|
".": {
|
|
@@ -379,6 +382,9 @@
|
|
|
379
382
|
},
|
|
380
383
|
"./webcrypto": {
|
|
381
384
|
"types": "./webcrypto.browser.d.ts",
|
|
385
|
+
"deno": {
|
|
386
|
+
"import": "./webcrypto.deno.js"
|
|
387
|
+
},
|
|
382
388
|
"node": {
|
|
383
389
|
"import": "./webcrypto.node.js",
|
|
384
390
|
"require": "./dist/webcrypto.node.cjs"
|
|
@@ -394,13 +400,11 @@
|
|
|
394
400
|
"isomorphic.js": "^0.2.4"
|
|
395
401
|
},
|
|
396
402
|
"devDependencies": {
|
|
397
|
-
"@
|
|
398
|
-
"
|
|
399
|
-
"concurrently": "^5.3.0",
|
|
403
|
+
"@types/node": "^18.14.0",
|
|
404
|
+
"c8": "^7.13.0",
|
|
400
405
|
"http-server": "^0.12.3",
|
|
401
|
-
"jsdoc-api": "^
|
|
402
|
-
"jsdoc-plugin-typescript": "^2.
|
|
403
|
-
"nyc": "^15.1.0",
|
|
406
|
+
"jsdoc-api": "^8.0.0",
|
|
407
|
+
"jsdoc-plugin-typescript": "^2.2.1",
|
|
404
408
|
"rollup": "^2.42.1",
|
|
405
409
|
"standard": "^14.3.4",
|
|
406
410
|
"typescript": "^4.2.3"
|
|
@@ -409,17 +413,17 @@
|
|
|
409
413
|
"clean": "rm -rf dist *.d.ts */*.d.ts *.d.ts.map */*.d.ts.map",
|
|
410
414
|
"types": "tsc --outDir .",
|
|
411
415
|
"dist": "rollup -c",
|
|
412
|
-
"debug": "
|
|
413
|
-
"test": "
|
|
416
|
+
"debug": "npm run gentesthtml && http-server -o test.html",
|
|
417
|
+
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node --unhandled-rejections=strict ./test.js --repetition-time 50 --production",
|
|
414
418
|
"test-inspect": "node --inspect-brk --unhandled-rejections=strict ./test.js --repetition-time 50 --production",
|
|
415
419
|
"test-extensive": "node test.js && npm test -- --repetition-time 30000 --extensive",
|
|
416
|
-
"test-code-coverage": "npm run clean && npm run dist && nyc --reporter html node ./dist/test.cjs --production",
|
|
417
420
|
"trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.cjs",
|
|
418
421
|
"trace-opt": "clear && rollup -c && node --trace-opt dist/test.cjs",
|
|
419
422
|
"lint": "standard && tsc",
|
|
420
423
|
"gendocs": "node ./bin/gendocs.js",
|
|
421
|
-
"preversion": "npm run clean && npm run
|
|
422
|
-
"postpublish": "npm run clean"
|
|
424
|
+
"preversion": "npm run clean && npm run lint && npm run test && npm run types && npm run dist && git add README.md",
|
|
425
|
+
"postpublish": "npm run clean",
|
|
426
|
+
"gentesthtml": "node ./bin/gentesthtml.js > test.html"
|
|
423
427
|
},
|
|
424
428
|
"repository": {
|
|
425
429
|
"type": "git",
|
package/prng.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prng.d.ts","sourceRoot":"","sources":["prng.js"],"names":[],"mappings":"AAeA;;;;GAIG;AAEH;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"prng.d.ts","sourceRoot":"","sources":["prng.js"],"names":[],"mappings":"AAeA;;;;GAIG;AAEH;;;;;GAKG;AACH,kDAA2C;AAUpC,6BAHI,MAAM,GACL,IAAI,CAEmC;AAQ5C,0BAHI,IAAI,WAG+B;AAUvC,2BALI,IAAI,oCAKuE;AAU/E,4BALI,IAAI,oCAKwD;AAUhE,2BALI,IAAI,oCAKuE;AAU/E,4BALI,IAAI,oCAKoD;AAY5D,2BALI,IAAI,oCAK6C;AAQrD,4BAHI,IAAI,UAGwB;AAUhC,0BALI,IAAI,GACH,MAAM,CAI0C;AAMrD,4BAHI,IAAI,GACH,MAAM,CAE4C;AAQvD,0BALI,IAAI,6DAGH,MAAM,CASjB;AAQM,+BAHI,IAAI,GACH,MAAM,CAKjB;AAMM,iCAHI,IAAI,uCAUd;AAUM,8BALI,IAAI,iBAK4D;AAOpE,gCAJI,IAAI,OACJ,MAAM,GACL,UAAU,CAQrB;AAQM,iCAJI,IAAI,OACJ,MAAM,GACL,WAAW,CAEkE;AAOlF,iCAJI,IAAI,OACJ,MAAM,GACL,WAAW,CAEkE;;;;kCApL5E,MAAM;;;;;;;;UAOL,aAAa"}
|
package/prng.js
CHANGED
|
@@ -25,7 +25,6 @@ import * as buffer from './buffer.js'
|
|
|
25
25
|
* @typedef {Object} PRNG
|
|
26
26
|
* @property {generatorNext} next Generate new number
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
28
|
export const DefaultPRNG = Xoroshiro128plus
|
|
30
29
|
|
|
31
30
|
/**
|
|
@@ -184,6 +183,7 @@ export const uint8Array = (gen, len) => {
|
|
|
184
183
|
return buf
|
|
185
184
|
}
|
|
186
185
|
|
|
186
|
+
/* c8 ignore start */
|
|
187
187
|
/**
|
|
188
188
|
* @param {PRNG} gen
|
|
189
189
|
* @param {number} len
|
|
@@ -197,3 +197,4 @@ export const uint16Array = (gen, len) => new Uint16Array(uint8Array(gen, len * 2
|
|
|
197
197
|
* @return {Uint32Array}
|
|
198
198
|
*/
|
|
199
199
|
export const uint32Array = (gen, len) => new Uint32Array(uint8Array(gen, len * 4).buffer)
|
|
200
|
+
/* c8 ignore stop */
|
package/promise.js
CHANGED
|
@@ -69,7 +69,7 @@ export const until = (timeout, check, intervalResolution = 10) => create((resolv
|
|
|
69
69
|
clearInterval(intervalHandle)
|
|
70
70
|
resolve()
|
|
71
71
|
} else if (hasTimeout) {
|
|
72
|
-
/*
|
|
72
|
+
/* c8 ignore else */
|
|
73
73
|
if (time.getUnixTime() - startTime > timeout) {
|
|
74
74
|
clearInterval(intervalHandle)
|
|
75
75
|
reject(new Error('Timeout'))
|
package/random.test.d.ts
CHANGED
package/random.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.test.d.ts","sourceRoot":"","sources":["random.test.js"],"names":[],"mappings":"AASO,+BAFI,EAAE,QAAQ,QA0BpB;AAKM,+BAFI,EAAE,QAAQ,QAyBpB;AAKM,+BAFI,EAAE,QAAQ,QAIpB;AAKM,uCAFI,EAAE,QAAQ,QAkBpB"}
|
|
1
|
+
{"version":3,"file":"random.test.d.ts","sourceRoot":"","sources":["random.test.js"],"names":[],"mappings":"AASO,+BAFI,EAAE,QAAQ,QAKpB;AAKM,+BAFI,EAAE,QAAQ,QA0BpB;AAKM,+BAFI,EAAE,QAAQ,QAyBpB;AAKM,+BAFI,EAAE,QAAQ,QAIpB;AAKM,uCAFI,EAAE,QAAQ,QAkBpB"}
|
package/rollup.config.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
declare var _default:
|
|
2
|
-
input: string;
|
|
3
|
-
output: {
|
|
4
|
-
file: string;
|
|
5
|
-
format: string;
|
|
6
|
-
sourcemap: boolean;
|
|
7
|
-
dir?: undefined;
|
|
8
|
-
entryFileNames?: undefined;
|
|
9
|
-
chunkFileNames?: undefined;
|
|
10
|
-
};
|
|
11
|
-
plugins: import("rollup").Plugin[];
|
|
12
|
-
external?: undefined;
|
|
13
|
-
} | {
|
|
1
|
+
declare var _default: {
|
|
14
2
|
input: string[];
|
|
15
3
|
output: {
|
|
16
4
|
dir: string;
|
|
@@ -18,22 +6,8 @@ declare var _default: ({
|
|
|
18
6
|
sourcemap: boolean;
|
|
19
7
|
entryFileNames: string;
|
|
20
8
|
chunkFileNames: string;
|
|
21
|
-
file?: undefined;
|
|
22
|
-
};
|
|
23
|
-
external: string[];
|
|
24
|
-
plugins?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
input: string;
|
|
27
|
-
output: {
|
|
28
|
-
dir: string;
|
|
29
|
-
format: string;
|
|
30
|
-
sourcemap: boolean;
|
|
31
|
-
entryFileNames: string;
|
|
32
|
-
chunkFileNames: string;
|
|
33
|
-
file?: undefined;
|
|
34
9
|
};
|
|
35
10
|
external: string[];
|
|
36
|
-
|
|
37
|
-
})[];
|
|
11
|
+
}[];
|
|
38
12
|
export default _default;
|
|
39
13
|
//# sourceMappingURL=rollup.config.d.ts.map
|
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;AAOtC,
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["set.js"],"names":[],"mappings":"AAMO,mCAA8B;AAO9B,6CAAsC;AAOtC,yCACiC;AAOjC,sDAAwC"}
|
package/set.js
CHANGED
|
@@ -18,15 +18,12 @@ export const toArray = set => Array.from(set)
|
|
|
18
18
|
* @param {Set<T>} set
|
|
19
19
|
* @return {T}
|
|
20
20
|
*/
|
|
21
|
-
export const first = set =>
|
|
22
|
-
|
|
23
|
-
}
|
|
21
|
+
export const first = set =>
|
|
22
|
+
set.values().next().value || undefined
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* @template T
|
|
27
26
|
* @param {Iterable<T>} entries
|
|
28
27
|
* @return {Set<T>}
|
|
29
28
|
*/
|
|
30
|
-
export const from = entries =>
|
|
31
|
-
return new Set(entries)
|
|
32
|
-
}
|
|
29
|
+
export const from = entries => new Set(entries)
|
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":"AAOO,+BAFI,EAAE,QAAQ,QAUpB"}
|
package/sort.test.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function testSortUint8(tc: t.TestCase): void;
|
|
2
2
|
export function testSortUint32(tc: t.TestCase): void;
|
|
3
|
+
export function testSortUint16(tc: t.TestCase): void;
|
|
3
4
|
export function testSortObjectUint32(tc: t.TestCase): void;
|
|
4
5
|
export function testListVsArrayPerformance(tc: t.TestCase): void;
|
|
5
6
|
import * as t from "./testing.js";
|
package/sort.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.test.d.ts","sourceRoot":"","sources":["sort.test.js"],"names":[],"mappings":"AAoEO,mCAFI,EAAE,QAAQ,QAqBpB;AAKM,mCAFI,EAAE,QAAQ,QAqBpB;AAKM,yCAFI,EAAE,QAAQ,QAoBpB;AAKM,+CAFI,EAAE,QAAQ,QA4BpB"}
|
|
1
|
+
{"version":3,"file":"sort.test.d.ts","sourceRoot":"","sources":["sort.test.js"],"names":[],"mappings":"AAoEO,kCAFI,EAAE,QAAQ,QAqBpB;AAKM,mCAFI,EAAE,QAAQ,QAqBpB;AAKM,mCAFI,EAAE,QAAQ,QAqBpB;AAKM,yCAFI,EAAE,QAAQ,QAoBpB;AAKM,+CAFI,EAAE,QAAQ,QA4BpB"}
|
package/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["storage.js"],"names":[],"mappings":"AAiDA;;GAEG;
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["storage.js"],"names":[],"mappings":"AAiDA;;GAEG;AAEH,6BAAuC;AAShC,8CAJa;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,KAAG,IAAI,eAIuC"}
|
package/storage.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module storage
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
/*
|
|
11
|
+
/* c8 ignore start */
|
|
12
12
|
class VarStoragePolyfill {
|
|
13
13
|
constructor () {
|
|
14
14
|
this.map = new Map()
|
|
@@ -29,34 +29,35 @@ class VarStoragePolyfill {
|
|
|
29
29
|
return this.map.get(key)
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
/* c8 ignore stop */
|
|
32
33
|
|
|
33
|
-
/* istanbul ignore next */
|
|
34
34
|
/**
|
|
35
35
|
* @type {any}
|
|
36
36
|
*/
|
|
37
37
|
let _localStorage = new VarStoragePolyfill()
|
|
38
38
|
let usePolyfill = true
|
|
39
39
|
|
|
40
|
+
/* c8 ignore start */
|
|
40
41
|
try {
|
|
41
42
|
// if the same-origin rule is violated, accessing localStorage might thrown an error
|
|
42
|
-
/* istanbul ignore next */
|
|
43
43
|
if (typeof localStorage !== 'undefined') {
|
|
44
44
|
_localStorage = localStorage
|
|
45
45
|
usePolyfill = false
|
|
46
46
|
}
|
|
47
47
|
} catch (e) { }
|
|
48
|
+
/* c8 ignore stop */
|
|
48
49
|
|
|
49
|
-
/* istanbul ignore next */
|
|
50
50
|
/**
|
|
51
51
|
* This is basically localStorage in browser, or a polyfill in nodejs
|
|
52
52
|
*/
|
|
53
|
+
/* c8 ignore next */
|
|
53
54
|
export const varStorage = _localStorage
|
|
54
55
|
|
|
55
|
-
/* istanbul ignore next */
|
|
56
56
|
/**
|
|
57
57
|
* A polyfill for `addEventListener('storage', event => {..})` that does nothing if the polyfill is being used.
|
|
58
58
|
*
|
|
59
59
|
* @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler
|
|
60
60
|
* @function
|
|
61
61
|
*/
|
|
62
|
+
/* c8 ignore next */
|
|
62
63
|
export const onChange = eventHandler => usePolyfill || addEventListener('storage', /** @type {any} */ (eventHandler))
|
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,0CAAyH;AAMlH,uCAHI,MAAM,GACL,UAAU,CAE6C;AAjB5D,gCAHI,MAAM,GACL,UAAU,CAUrB;AAsBM,yCAHI,UAAU,GACT,MAAM,CAejB;AAGD,+CAAmI;
|
|
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;AAkB5H,uCAHI,UAAU,GACT,MAAM,CAE8E;AAlCzF,gCAHI,UAAU,GACT,MAAM,CAejB;AAoCM,4BALI,MAAM,SACN,MAAM,UACN,MAAM,WACN,MAAM,UAEkG"}
|