lib0 0.2.77 → 0.2.79
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 +1 -1
- package/array.d.ts +1 -0
- package/array.d.ts.map +1 -1
- package/array.js +18 -0
- package/binary.test.d.ts.map +1 -1
- package/buffer.d.ts +3 -0
- package/buffer.d.ts.map +1 -1
- package/buffer.js +40 -0
- package/buffer.test.d.ts +2 -1
- package/buffer.test.d.ts.map +1 -1
- package/cache.d.ts.map +1 -1
- package/cache.js +0 -1
- package/cache.test.d.ts.map +1 -1
- package/component.d.ts +5 -5
- package/component.d.ts.map +1 -1
- package/component.js +14 -11
- package/coverage/tmp/coverage-10499-1691528887100-0.json +1 -0
- package/decoding.d.ts +2 -0
- package/decoding.d.ts.map +1 -1
- package/decoding.js +26 -0
- package/dist/aes-gcm.cjs +161 -0
- package/dist/aes-gcm.cjs.map +1 -0
- package/dist/{array-fd99bc23.cjs → array-704ca50e.cjs} +22 -2
- package/dist/array-704ca50e.cjs.map +1 -0
- package/dist/array.cjs +2 -1
- package/dist/array.cjs.map +1 -1
- package/dist/array.d.ts +1 -0
- package/dist/array.d.ts.map +1 -1
- package/dist/binary.test.d.ts.map +1 -1
- package/dist/{broadcastchannel-fff713ef.cjs → broadcastchannel-7801969a.cjs} +2 -2
- package/dist/{broadcastchannel-fff713ef.cjs.map → broadcastchannel-7801969a.cjs.map} +1 -1
- package/dist/broadcastchannel.cjs +9 -9
- package/dist/{buffer-621617f6.cjs → buffer-c5d69c70.cjs} +126 -7
- package/dist/buffer-c5d69c70.cjs.map +1 -0
- package/dist/buffer.cjs +12 -9
- package/dist/buffer.cjs.map +1 -1
- package/dist/buffer.d.ts +3 -0
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.test.d.ts +2 -1
- package/dist/buffer.test.d.ts.map +1 -1
- package/dist/cache.cjs +5 -3
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.test.d.ts.map +1 -1
- package/dist/common.cjs +37 -0
- package/dist/common.cjs.map +1 -0
- package/dist/component.cjs +20 -17
- package/dist/component.cjs.map +1 -1
- package/dist/component.d.ts +5 -5
- package/dist/component.d.ts.map +1 -1
- package/dist/decoding.cjs +9 -7
- package/dist/decoding.cjs.map +1 -1
- package/dist/decoding.d.ts +2 -0
- package/dist/decoding.d.ts.map +1 -1
- package/dist/{diff-18852f48.cjs → diff-fbaa426b.cjs} +2 -2
- package/dist/{diff-18852f48.cjs.map → diff-fbaa426b.cjs.map} +1 -1
- package/dist/diff.cjs +4 -4
- package/dist/ecdsa.cjs +118 -0
- package/dist/ecdsa.cjs.map +1 -0
- package/dist/encoding.cjs +9 -7
- package/dist/encoding.cjs.map +1 -1
- package/dist/encoding.d.ts +2 -0
- package/dist/encoding.d.ts.map +1 -1
- package/dist/encoding.test.d.ts +1 -0
- package/dist/encoding.test.d.ts.map +1 -1
- package/dist/{environment-0c5ff22b.cjs → environment-ad129e4d.cjs} +3 -3
- package/dist/{environment-0c5ff22b.cjs.map → environment-ad129e4d.cjs.map} +1 -1
- package/dist/environment.cjs +5 -5
- package/dist/{function-831844d3.cjs → function-314fdc56.cjs} +3 -3
- package/dist/{function-831844d3.cjs.map → function-314fdc56.cjs.map} +1 -1
- package/dist/function.cjs +3 -3
- package/dist/hash/rabin-gf2-polynomial.d.ts +45 -0
- package/dist/hash/rabin-gf2-polynomial.d.ts.map +1 -0
- package/dist/hash/rabin-uncached.d.ts +29 -0
- package/dist/hash/rabin-uncached.d.ts.map +1 -0
- package/dist/hash/rabin.d.ts +27 -0
- package/dist/hash/rabin.d.ts.map +1 -0
- package/dist/hash/rabin.test.d.ts +8 -0
- package/dist/hash/rabin.test.d.ts.map +1 -0
- package/dist/hash/sha256.fallback.d.ts +2 -0
- package/dist/hash/sha256.fallback.d.ts.map +1 -0
- package/dist/hash/sha256.node.d.ts +2 -0
- package/dist/hash/sha256.node.d.ts.map +1 -0
- package/dist/hash/sha256.test.d.ts +6 -0
- package/dist/hash/sha256.test.d.ts.map +1 -0
- package/dist/index.cjs +11 -11
- package/dist/list.cjs +3 -3
- package/dist/logging.cjs +5 -5
- package/dist/logging.common.cjs +21 -21
- package/dist/logging.common.cjs.map +1 -1
- package/dist/logging.node.cjs +5 -5
- package/dist/logging.test.d.ts.map +1 -1
- package/dist/{number-dc113762.cjs → number-466d8922.cjs} +29 -10
- package/dist/number-466d8922.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/number.test.d.ts +1 -1
- package/dist/number.test.d.ts.map +1 -1
- package/dist/{object-aad630ed.cjs → object-fecf6a7b.cjs} +2 -1
- package/dist/object-fecf6a7b.cjs.map +1 -0
- package/dist/object.cjs +1 -1
- package/dist/object.d.ts.map +1 -1
- package/dist/observable.cjs +1 -1
- package/dist/performance.node.cjs +3 -3
- package/dist/{prng-9ccc85f7.cjs → prng-1149c8c4.cjs} +3 -3
- package/dist/{prng-9ccc85f7.cjs.map → prng-1149c8c4.cjs.map} +1 -1
- package/dist/prng.cjs +8 -8
- package/dist/prng.test.d.ts.map +1 -1
- package/dist/queue.cjs.map +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/rabin-gf2-polynomial.cjs +437 -0
- package/dist/rabin-gf2-polynomial.cjs.map +1 -0
- package/dist/rabin-uncached.cjs +87 -0
- package/dist/rabin-uncached.cjs.map +1 -0
- package/dist/rabin.cjs +125 -0
- package/dist/rabin.cjs.map +1 -0
- package/dist/random.cjs +12 -0
- package/dist/random.cjs.map +1 -1
- package/dist/random.d.ts +1 -1
- package/dist/random.d.ts.map +1 -1
- package/dist/rsa-oaep.cjs +112 -0
- package/dist/rsa-oaep.cjs.map +1 -0
- package/dist/set.test.d.ts.map +1 -1
- package/dist/sha256.fallback.cjs +179 -0
- package/dist/sha256.fallback.cjs.map +1 -0
- package/dist/sha256.node.cjs +17 -0
- package/dist/sha256.node.cjs.map +1 -0
- package/dist/{string-e7eb0c1d.cjs → string-6d104757.cjs} +10 -2
- package/dist/string-6d104757.cjs.map +1 -0
- package/dist/string.cjs +3 -2
- package/dist/string.cjs.map +1 -1
- package/dist/string.d.ts +5 -0
- package/dist/string.d.ts.map +1 -1
- package/dist/testing.cjs +23 -17
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts +13 -7
- package/dist/testing.d.ts.map +1 -1
- package/dist/url.cjs +1 -1
- package/dist/webcrypto.node.cjs.map +1 -1
- package/dist/webcrypto.node.d.ts.map +1 -1
- package/dist/{websocket-0632cb8c.cjs → websocket-44e4ead5.cjs} +1 -1
- package/dist/{websocket-0632cb8c.cjs.map → websocket-44e4ead5.cjs.map} +1 -1
- package/dist/websocket.cjs +2 -2
- package/encoding.d.ts +2 -0
- package/encoding.d.ts.map +1 -1
- package/encoding.js +42 -0
- package/encoding.test.d.ts +1 -0
- package/encoding.test.d.ts.map +1 -1
- package/hash/rabin-gf2-polynomial.d.ts +45 -0
- package/hash/rabin-gf2-polynomial.d.ts.map +1 -0
- package/hash/rabin-gf2-polynomial.js +379 -0
- package/hash/rabin-uncached.d.ts +29 -0
- package/hash/rabin-uncached.d.ts.map +1 -0
- package/hash/rabin-uncached.js +68 -0
- package/hash/rabin.d.ts +27 -0
- package/hash/rabin.d.ts.map +1 -0
- package/hash/rabin.js +100 -0
- package/hash/rabin.test.d.ts +8 -0
- package/hash/rabin.test.d.ts.map +1 -0
- package/hash/sha256.fallback.d.ts +2 -0
- package/hash/sha256.fallback.d.ts.map +1 -0
- package/hash/sha256.fallback.js +172 -0
- package/hash/sha256.node.d.ts +2 -0
- package/hash/sha256.node.d.ts.map +1 -0
- package/hash/sha256.node.js +10 -0
- package/hash/sha256.test.d.ts +6 -0
- package/hash/sha256.test.d.ts.map +1 -0
- package/logging.common.js +16 -16
- package/logging.test.d.ts.map +1 -1
- package/number.d.ts +1 -0
- package/number.d.ts.map +1 -1
- package/number.js +17 -0
- package/number.test.d.ts +1 -1
- package/number.test.d.ts.map +1 -1
- package/object.d.ts.map +1 -1
- package/object.js +1 -0
- package/package.json +24 -6
- package/prng.test.d.ts.map +1 -1
- package/queue.d.ts.map +1 -1
- package/queue.js +0 -1
- package/random.d.ts +1 -1
- package/random.d.ts.map +1 -1
- package/random.js +4 -1
- package/set.test.d.ts.map +1 -1
- package/string.d.ts +5 -0
- package/string.d.ts.map +1 -1
- package/string.js +6 -0
- package/test.html +2 -0
- package/test.js +4 -0
- package/testing.d.ts +13 -7
- package/testing.d.ts.map +1 -1
- package/testing.js +14 -8
- package/webcrypto.node.d.ts.map +1 -1
- package/webcrypto.node.js +0 -1
- package/coverage/tmp/coverage-36234-1685177795346-0.json +0 -1
- package/dist/array-fd99bc23.cjs.map +0 -1
- package/dist/buffer-621617f6.cjs.map +0 -1
- package/dist/number-dc113762.cjs.map +0 -1
- package/dist/object-aad630ed.cjs.map +0 -1
- package/dist/string-e7eb0c1d.cjs.map +0 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sha256
|
|
3
|
+
* Spec: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
|
|
4
|
+
* Resources:
|
|
5
|
+
* - https://web.archive.org/web/20150315061807/http://csrc.nist.gov/groups/STM/cavp/documents/shs/sha256-384-512.pdf
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as binary from '../binary.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {number} w - a 32bit uint
|
|
12
|
+
* @param {number} shift
|
|
13
|
+
*/
|
|
14
|
+
const rotr = (w, shift) => (w >>> shift) | (w << (32 - shift))
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Helper for SHA-224 & SHA-256. See 4.1.2.
|
|
18
|
+
* @param {number} x
|
|
19
|
+
*/
|
|
20
|
+
const sum0to256 = x => rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22)
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Helper for SHA-224 & SHA-256. See 4.1.2.
|
|
24
|
+
* @param {number} x
|
|
25
|
+
*/
|
|
26
|
+
const sum1to256 = x => rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25)
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Helper for SHA-224 & SHA-256. See 4.1.2.
|
|
30
|
+
* @param {number} x
|
|
31
|
+
*/
|
|
32
|
+
const sigma0to256 = x => rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Helper for SHA-224 & SHA-256. See 4.1.2.
|
|
36
|
+
* @param {number} x
|
|
37
|
+
*/
|
|
38
|
+
const sigma1to256 = x => rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10
|
|
39
|
+
|
|
40
|
+
// @todo don't init these variables globally
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* See 4.2.2: Constant for sha256 & sha224
|
|
44
|
+
* These words represent the first thirty-two bits of the fractional parts of
|
|
45
|
+
* the cube roots of the first sixty-four prime numbers. In hex, these constant words are (from left to
|
|
46
|
+
* right)
|
|
47
|
+
*/
|
|
48
|
+
const K = new Uint32Array([
|
|
49
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
50
|
+
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
51
|
+
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
52
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
53
|
+
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
54
|
+
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
55
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
56
|
+
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* See 5.3.3. Initial hash value.
|
|
61
|
+
*
|
|
62
|
+
* These words were obtained by taking the first thirty-two bits of the fractional parts of the
|
|
63
|
+
* square roots of the first eight prime numbers.
|
|
64
|
+
*
|
|
65
|
+
* @todo shouldn't be a global variable
|
|
66
|
+
*/
|
|
67
|
+
const HINIT = new Uint32Array([
|
|
68
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
|
69
|
+
])
|
|
70
|
+
|
|
71
|
+
// time to beat: (large value < 4.35s)
|
|
72
|
+
|
|
73
|
+
class Hasher {
|
|
74
|
+
constructor () {
|
|
75
|
+
const buf = new ArrayBuffer(64 + 64 * 4)
|
|
76
|
+
// Init working variables using a single arraybuffer
|
|
77
|
+
this._H = new Uint32Array(buf, 0, 8)
|
|
78
|
+
this._H.set(HINIT)
|
|
79
|
+
// "Message schedule" - a working variable
|
|
80
|
+
this._W = new Uint32Array(buf, 64, 64)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_updateHash () {
|
|
84
|
+
const H = this._H
|
|
85
|
+
const W = this._W
|
|
86
|
+
for (let t = 16; t < 64; t++) {
|
|
87
|
+
W[t] = sigma1to256(W[t - 2]) + W[t - 7] + sigma0to256(W[t - 15]) + W[t - 16]
|
|
88
|
+
}
|
|
89
|
+
let a = H[0]
|
|
90
|
+
let b = H[1]
|
|
91
|
+
let c = H[2]
|
|
92
|
+
let d = H[3]
|
|
93
|
+
let e = H[4]
|
|
94
|
+
let f = H[5]
|
|
95
|
+
let g = H[6]
|
|
96
|
+
let h = H[7]
|
|
97
|
+
for (let tt = 0, T1, T2; tt < 64; tt++) {
|
|
98
|
+
T1 = (h + sum1to256(e) + ((e & f) ^ (~e & g)) + K[tt] + W[tt]) >>> 0
|
|
99
|
+
T2 = (sum0to256(a) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0
|
|
100
|
+
h = g
|
|
101
|
+
g = f
|
|
102
|
+
f = e
|
|
103
|
+
e = (d + T1) >>> 0
|
|
104
|
+
d = c
|
|
105
|
+
c = b
|
|
106
|
+
b = a
|
|
107
|
+
a = (T1 + T2) >>> 0
|
|
108
|
+
}
|
|
109
|
+
H[0] += a
|
|
110
|
+
H[1] += b
|
|
111
|
+
H[2] += c
|
|
112
|
+
H[3] += d
|
|
113
|
+
H[4] += e
|
|
114
|
+
H[5] += f
|
|
115
|
+
H[6] += g
|
|
116
|
+
H[7] += h
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @param {Uint8Array} data
|
|
121
|
+
*/
|
|
122
|
+
digest (data) {
|
|
123
|
+
let i = 0
|
|
124
|
+
for (; i + 56 <= data.length;) {
|
|
125
|
+
// write data in big endianess
|
|
126
|
+
let j = 0
|
|
127
|
+
for (; j < 16 && i + 3 < data.length; j++) {
|
|
128
|
+
this._W[j] = data[i++] << 24 | data[i++] << 16 | data[i++] << 8 | data[i++]
|
|
129
|
+
}
|
|
130
|
+
if (i % 64 !== 0) { // there is still room to write partial content and the ending bit.
|
|
131
|
+
this._W.fill(0, j, 16)
|
|
132
|
+
while (i < data.length) {
|
|
133
|
+
this._W[j] |= data[i] << ((3 - (i % 4)) * 8)
|
|
134
|
+
i++
|
|
135
|
+
}
|
|
136
|
+
this._W[j] |= binary.BIT8 << ((3 - (i % 4)) * 8)
|
|
137
|
+
}
|
|
138
|
+
this._updateHash()
|
|
139
|
+
}
|
|
140
|
+
// same check as earlier - the ending bit has been written
|
|
141
|
+
const isPaddedWith1 = i % 64 !== 0
|
|
142
|
+
this._W.fill(0, 0, 16)
|
|
143
|
+
let j = 0
|
|
144
|
+
for (; i < data.length; j++) {
|
|
145
|
+
for (let ci = 3; ci >= 0 && i < data.length; ci--) {
|
|
146
|
+
this._W[j] |= data[i++] << (ci * 8)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Write padding of the message. See 5.1.2.
|
|
150
|
+
if (!isPaddedWith1) {
|
|
151
|
+
this._W[j - (i % 4 === 0 ? 0 : 1)] |= binary.BIT8 << ((3 - (i % 4)) * 8)
|
|
152
|
+
}
|
|
153
|
+
// write length of message (size in bits) as 64 bit uint
|
|
154
|
+
// @todo test that this works correctly
|
|
155
|
+
this._W[14] = data.byteLength / binary.BIT30 // same as data.byteLength >>> 30 - but works on floats
|
|
156
|
+
this._W[15] = data.byteLength * 8
|
|
157
|
+
this._updateHash()
|
|
158
|
+
// correct H endianness to use big endiannes and return a Uint8Array
|
|
159
|
+
const dv = new Uint8Array(32)
|
|
160
|
+
for (let i = 0; i < this._H.length; i++) {
|
|
161
|
+
for (let ci = 0; ci < 4; ci++) {
|
|
162
|
+
dv[i * 4 + ci] = this._H[i] >>> (3 - ci) * 8
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return dv
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param {Uint8Array} data
|
|
171
|
+
*/
|
|
172
|
+
export const digest = data => new Hasher().digest(data)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.node.d.ts","sourceRoot":"","sources":["sha256.node.js"],"names":[],"mappings":"AAKO,6BAFI,UAAU,UAMpB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function testSha256Basics(_tc: t.TestCase): Promise<void>;
|
|
2
|
+
export function testLargeValue(_tc: t.TestCase): Promise<void>;
|
|
3
|
+
export function testRepeatSha256Hashing(tc: t.TestCase): Promise<void>;
|
|
4
|
+
export function testBenchmarkSha256(_tc: t.TestCase): Promise<void>;
|
|
5
|
+
import * as t from '../testing.js';
|
|
6
|
+
//# sourceMappingURL=sha256.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.test.d.ts","sourceRoot":"","sources":["sha256.test.js"],"names":[],"mappings":"AAcO,sCAFI,EAAE,QAAQ,iBA2BpB;AAOM,oCAFI,EAAE,QAAQ,iBA4BpB;AAKM,4CAFI,EAAE,QAAQ,iBAQpB;AAKM,yCAFI,EAAE,QAAQ,iBAmDpB;mBAzIkB,eAAe"}
|
package/logging.common.js
CHANGED
|
@@ -56,21 +56,21 @@ export const createModuleLogger = (_print, moduleName) => {
|
|
|
56
56
|
return !doLogging
|
|
57
57
|
? func.nop
|
|
58
58
|
: (...args) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
const timeNow = time.getUnixTime()
|
|
60
|
+
const timeDiff = timeNow - lastLoggingTime
|
|
61
|
+
lastLoggingTime = timeNow
|
|
62
|
+
_print(
|
|
63
|
+
color,
|
|
64
|
+
moduleName,
|
|
65
|
+
UNCOLOR,
|
|
66
|
+
...args.map((arg) =>
|
|
67
|
+
(typeof arg === 'string' || typeof arg === 'symbol')
|
|
68
|
+
? arg
|
|
69
|
+
: JSON.stringify(arg)
|
|
70
|
+
),
|
|
71
|
+
color,
|
|
72
|
+
' +' + timeDiff + 'ms'
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
75
|
}
|
|
76
76
|
/* c8 ignore stop */
|
package/logging.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.test.d.ts","sourceRoot":"","sources":["logging.test.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logging.test.d.ts","sourceRoot":"","sources":["logging.test.js"],"names":[],"mappings":"AAEO,oCAcN"}
|
package/number.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export const HIGHEST_UINT32: number;
|
|
|
6
6
|
export const isInteger: (number: unknown) => boolean;
|
|
7
7
|
export const isNaN: (number: unknown) => boolean;
|
|
8
8
|
export const parseInt: (string: string, radix?: number | undefined) => number;
|
|
9
|
+
export function countBits(n: number): number;
|
|
9
10
|
//# 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,mCAA0C;AAC1C,oCAA2C;AAG3C,qDAAyH;AACzH,iDAAiC;AACjC,8EAAuC"}
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["number.js"],"names":[],"mappings":"AASA,sCAAuD;AACvD,sCAAuD;AAEvD,kCAAmC;AACnC,mCAA0C;AAC1C,oCAA2C;AAG3C,qDAAyH;AACzH,iDAAiC;AACjC,8EAAuC;AAShC,6BAFI,MAAM,UAUhB"}
|
package/number.js
CHANGED
|
@@ -18,3 +18,20 @@ export const HIGHEST_UINT32 = binary.BITS32
|
|
|
18
18
|
export const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && math.floor(num) === num)
|
|
19
19
|
export const isNaN = Number.isNaN
|
|
20
20
|
export const parseInt = Number.parseInt
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Count the number of "1" bits in an unsigned 32bit number.
|
|
24
|
+
*
|
|
25
|
+
* Super fun bitcount algorithm by Brian Kernighan.
|
|
26
|
+
*
|
|
27
|
+
* @param {number} n
|
|
28
|
+
*/
|
|
29
|
+
export const countBits = n => {
|
|
30
|
+
n &= binary.BITS32
|
|
31
|
+
let count = 0
|
|
32
|
+
while (n) {
|
|
33
|
+
n &= (n - 1)
|
|
34
|
+
count++
|
|
35
|
+
}
|
|
36
|
+
return count
|
|
37
|
+
}
|
package/number.test.d.ts
CHANGED
package/number.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.test.d.ts","sourceRoot":"","sources":["number.test.js"],"names":[],"mappings":"AAQO
|
|
1
|
+
{"version":3,"file":"number.test.d.ts","sourceRoot":"","sources":["number.test.js"],"names":[],"mappings":"AAQO,gCAFI,EAAE,QAAQ,QAiBpB;AAOM,wCAFI,EAAE,QAAQ,QA6DpB;mBAzFkB,cAAc"}
|
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;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,
|
|
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,WAQ1B;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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lib0",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.79",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -83,19 +83,37 @@
|
|
|
83
83
|
"types": "./crypto/aes-gcm.d.ts",
|
|
84
84
|
"module": "./crypto/aes-gcm.js",
|
|
85
85
|
"import": "./crypto/aes-gcm.js",
|
|
86
|
-
"require": "./dist/
|
|
86
|
+
"require": "./dist/aes-gcm.cjs"
|
|
87
87
|
},
|
|
88
88
|
"./crypto/ecdsa": {
|
|
89
89
|
"types": "./crypto/ecdsa.d.ts",
|
|
90
90
|
"module": "./crypto/ecdsa.js",
|
|
91
91
|
"import": "./crypto/ecdsa.js",
|
|
92
|
-
"require": "./dist/
|
|
92
|
+
"require": "./dist/ecdsa.cjs"
|
|
93
93
|
},
|
|
94
94
|
"./crypto/rsa-oaep": {
|
|
95
95
|
"types": "./crypto/rsa-oaep.d.ts",
|
|
96
96
|
"module": "./crypto/rsa-oaep.js",
|
|
97
97
|
"import": "./crypto/rsa-oaep.js",
|
|
98
|
-
"require": "./dist/
|
|
98
|
+
"require": "./dist/rsa-oaep.cjs"
|
|
99
|
+
},
|
|
100
|
+
"./hash/rabin": {
|
|
101
|
+
"types": "./hash/rabin.d.ts",
|
|
102
|
+
"module": "./hash/rabin.js",
|
|
103
|
+
"import": "./hash/rabin.js",
|
|
104
|
+
"require": "./dist/rabin.cjs"
|
|
105
|
+
},
|
|
106
|
+
"./hash/sha256": {
|
|
107
|
+
"types": "./hash/sha256.fallback.d.ts",
|
|
108
|
+
"node": {
|
|
109
|
+
"require": "./dist/sha256.node.cjs",
|
|
110
|
+
"default": "./hash/sha256.node.js"
|
|
111
|
+
},
|
|
112
|
+
"default": {
|
|
113
|
+
"module": "./hash/sha256.fallback.js",
|
|
114
|
+
"require": "./dist/sha256.fallback.cjs",
|
|
115
|
+
"default": "./hash/sha256.fallback.js"
|
|
116
|
+
}
|
|
99
117
|
},
|
|
100
118
|
"./decoding.js": "./decoding.js",
|
|
101
119
|
"./dist/decoding.cjs": "./dist/decoding.cjs",
|
|
@@ -444,7 +462,7 @@
|
|
|
444
462
|
"jsdoc-api": "^8.0.0",
|
|
445
463
|
"jsdoc-plugin-typescript": "^2.2.1",
|
|
446
464
|
"rollup": "^2.42.1",
|
|
447
|
-
"standard": "^
|
|
465
|
+
"standard": "^17.1.0",
|
|
448
466
|
"typescript": "^5.0.2"
|
|
449
467
|
},
|
|
450
468
|
"scripts": {
|
|
@@ -454,7 +472,7 @@
|
|
|
454
472
|
"debug": "npm run gentesthtml && npx 0serve -o test.html",
|
|
455
473
|
"test": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node --unhandled-rejections=strict ./test.js --repetition-time 50 --production",
|
|
456
474
|
"test-inspect": "node --inspect-brk --unhandled-rejections=strict ./test.js --repetition-time 50 --production",
|
|
457
|
-
"test-extensive": "
|
|
475
|
+
"test-extensive": "c8 --check-coverage --lines 100 --branches 100 --functions 100 --statements 100 node test.js --repetition-time 30000 --extensive --production",
|
|
458
476
|
"trace-deopt": "clear && rollup -c && node --trace-deopt dist/test.cjs",
|
|
459
477
|
"trace-opt": "clear && rollup -c && node --trace-opt dist/test.cjs",
|
|
460
478
|
"lint": "standard && tsc",
|
package/prng.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prng.test.d.ts","sourceRoot":"","sources":["prng.test.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prng.test.d.ts","sourceRoot":"","sources":["prng.test.js"],"names":[],"mappings":"AA4LO,kDAFI,EAAE,QAAQ,QAE2E;AAKzF,4CAFI,EAAE,QAAQ,QAKpB;AAKM,yCAFI,EAAE,QAAQ,QAKpB;AA2BM,4CAFI,EAAE,QAAQ,QAOpB;mBAxOkB,cAAc"}
|
package/queue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["queue.js"],"names":[],"mappings":"AAAA;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/random.d.ts
CHANGED
package/random.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["random.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["random.js"],"names":[],"mappings":"AAYA,gCAA+B;AAExB,iCAA2D;AAE3D,iCAGN;AAOM,sCAAyD;AAQzD,0BAFK,MAAM,CAIjB"}
|
package/random.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
/**
|
|
3
2
|
* Isomorphic module for true random numbers / buffers / uuids.
|
|
4
3
|
*
|
|
@@ -29,6 +28,10 @@ export const oneOf = arr => arr[math.floor(rand() * arr.length)]
|
|
|
29
28
|
|
|
30
29
|
// @ts-ignore
|
|
31
30
|
const uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @return {string}
|
|
34
|
+
*/
|
|
32
35
|
export const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>
|
|
33
36
|
(c ^ uint32() & 15 >> c / 4).toString(16)
|
|
34
37
|
)
|
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":"AAMO,+BAFI,EAAE,QAAQ,QAUpB;mBAdkB,cAAc"}
|
package/string.d.ts
CHANGED
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const fromCharCode: (...codes: number[]) => string;
|
|
7
7
|
export const fromCodePoint: (...codePoints: number[]) => string;
|
|
8
|
+
/**
|
|
9
|
+
* The largest utf16 character.
|
|
10
|
+
* Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)
|
|
11
|
+
*/
|
|
12
|
+
export const MAX_UTF16_CHARACTER: string;
|
|
8
13
|
export function trimLeft(s: string): string;
|
|
9
14
|
export function fromCamelCase(s: string, separator: string): string;
|
|
10
15
|
export function utf8ByteLength(str: string): number;
|
package/string.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,0DAA+C;AAC/C,gEAAiD;
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["string.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,0DAA+C;AAC/C,gEAAiD;AAEjD;;;GAGG;AACH,yCAAsD;AAc/C,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;AAM5G,+BAHI,MAAM,KACN,MAAM,UAE0D"}
|
package/string.js
CHANGED
|
@@ -9,6 +9,12 @@ import * as array from './array.js'
|
|
|
9
9
|
export const fromCharCode = String.fromCharCode
|
|
10
10
|
export const fromCodePoint = String.fromCodePoint
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The largest utf16 character.
|
|
14
|
+
* Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)
|
|
15
|
+
*/
|
|
16
|
+
export const MAX_UTF16_CHARACTER = fromCharCode(65535)
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* @param {string} s
|
|
14
20
|
* @return {string}
|
package/test.html
CHANGED
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
"lib0/crypto/aes-gcm": "./crypto/aes-gcm.js",
|
|
33
33
|
"lib0/crypto/ecdsa": "./crypto/ecdsa.js",
|
|
34
34
|
"lib0/crypto/rsa-oaep": "./crypto/rsa-oaep.js",
|
|
35
|
+
"lib0/hash/rabin": "./hash/rabin.js",
|
|
36
|
+
"lib0/hash/sha256": "./hash/sha256.fallback.js",
|
|
35
37
|
"lib0/decoding.js": "./decoding.js",
|
|
36
38
|
"lib0/dist/decoding.cjs": "./dist/decoding.cjs",
|
|
37
39
|
"lib0/decoding": "./decoding.js",
|
package/test.js
CHANGED
|
@@ -2,6 +2,8 @@ import { runTests } from './testing.js'
|
|
|
2
2
|
import * as array from './array.test.js'
|
|
3
3
|
import * as broadcastchannel from './broadcastchannel.test.js'
|
|
4
4
|
import * as crypto from './crypto.test.js'
|
|
5
|
+
import * as rabin from './hash/rabin.test.js'
|
|
6
|
+
import * as sha256 from './hash/sha256.test.js'
|
|
5
7
|
import * as logging from './logging.test.js'
|
|
6
8
|
import * as string from './string.test.js'
|
|
7
9
|
import * as encoding from './encoding.test.js'
|
|
@@ -44,6 +46,8 @@ runTests({
|
|
|
44
46
|
array,
|
|
45
47
|
broadcastchannel,
|
|
46
48
|
crypto,
|
|
49
|
+
rabin,
|
|
50
|
+
sha256,
|
|
47
51
|
logging,
|
|
48
52
|
string,
|
|
49
53
|
encoding,
|
package/testing.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export class TestCase {
|
|
|
15
15
|
* @type {string}
|
|
16
16
|
*/
|
|
17
17
|
testName: string;
|
|
18
|
+
/**
|
|
19
|
+
* This type can store custom information related to the TestCase
|
|
20
|
+
*
|
|
21
|
+
* @type {Map<string,any>}
|
|
22
|
+
*/
|
|
23
|
+
meta: Map<string, any>;
|
|
18
24
|
_seed: number | null;
|
|
19
25
|
_prng: prng.PRNG | null;
|
|
20
26
|
resetSeed(): void;
|
|
@@ -35,18 +41,18 @@ export function describe(description: string, info?: string): void;
|
|
|
35
41
|
export function info(info: string): void;
|
|
36
42
|
export const printDom: (_createNode: () => Node) => void;
|
|
37
43
|
export const printCanvas: (canvas: HTMLCanvasElement, height: number) => void;
|
|
38
|
-
export function group(description: string, f: (
|
|
39
|
-
export function groupAsync(description: string, f: (
|
|
40
|
-
export function measureTime(message: string, f: () => void): number;
|
|
41
|
-
export function measureTimeAsync(message: string, f: () => Promise<any>): Promise<number>;
|
|
44
|
+
export function group(description: string, f: (...args: any[]) => void): void;
|
|
45
|
+
export function groupAsync(description: string, f: (...args: any[]) => Promise<any>): Promise<void>;
|
|
46
|
+
export function measureTime(message: string, f: (...args: any[]) => void): number;
|
|
47
|
+
export function measureTimeAsync(message: string, f: (...args: any[]) => Promise<any>): Promise<number>;
|
|
42
48
|
export function compareArrays<T>(as: T[], bs: T[], m?: string | undefined): boolean;
|
|
43
49
|
export function compareStrings(a: string, b: string, m?: string | undefined): void;
|
|
44
50
|
export function compareObjects<K, V>(a: any, b: any, m?: string | undefined): void;
|
|
45
51
|
export function compare<T>(a: T, b: T, message?: string | null | undefined, customCompare?: ((arg0: any, arg1: T, arg2: T, arg3: string, arg4: any) => boolean) | undefined): boolean;
|
|
46
52
|
export function assert<T>(property: T, message?: string | null | undefined): asserts property is NonNullable<T>;
|
|
47
|
-
export function promiseRejected(f: () => Promise<any>): Promise<void>;
|
|
48
|
-
export function fails(f: () => void): void;
|
|
49
|
-
export function failsAsync(f: () => Promise<any>): Promise<void>;
|
|
53
|
+
export function promiseRejected(f: (...args: any[]) => Promise<any>): Promise<void>;
|
|
54
|
+
export function fails(f: (...args: any[]) => void): void;
|
|
55
|
+
export function failsAsync(f: (...args: any[]) => Promise<any>): Promise<void>;
|
|
50
56
|
export function runTests(tests: {
|
|
51
57
|
[x: string]: {
|
|
52
58
|
[x: string]: (arg0: TestCase) => void | Promise<any>;
|
package/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["testing.js"],"names":[],"mappings":";AA8DA,gCAAiD;AAGjD,oCAAmG;AAEnG;IACE;;;OAGG;IACH,wBAHW,MAAM,YACN,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["testing.js"],"names":[],"mappings":";AA8DA,gCAAiD;AAGjD,oCAAmG;AAEnG;IACE;;;OAGG;IACH,wBAHW,MAAM,YACN,MAAM,EAmBhB;IAhBC;;OAEG;IACH,YAFU,MAAM,CAEY;IAC5B;;OAEG;IACH,UAFU,MAAM,CAEQ;IACxB;;;;OAIG;IACH,MAFU,IAAI,MAAM,EAAC,GAAG,CAAC,CAEJ;IACrB,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,oBA0EhB;AAcM,sCAHI,MAAM,SACN,MAAM,QAEwF;AAYlG,2BAFI,MAAM,QAE6B;AAE9C,yDAAoC;AAEpC,8EAA0C;AAoBnC,mCAHI,MAAM,eACM,GAAG,OAAE,IAAI,QAS/B;AAoBM,wCAHI,MAAM,eACM,GAAG,OAAE,QAAQ,GAAG,CAAC,iBASvC;AAoBM,qCAJI,MAAM,eACM,GAAG,OAAE,IAAI,GACpB,MAAM,CAYjB;AAoBM,0CAJI,MAAM,eACM,GAAG,OAAE,QAAQ,GAAG,CAAC,GAC5B,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;AAUtH,gHAA8H;AAK9H,6CAFgB,GAAG,OAAE,QAAQ,GAAG,CAAC,iBASvC;AAMM,mCAHgB,GAAG,OAAE,IAAI,QAW/B;AAMM,wCAHgB,GAAG,OAAE,QAAQ,GAAG,CAAC,iBAWvC;AAKM;QAFW,MAAM;YAAS,MAAM,UAAW,QAAQ,KAAE,IAAI,GAAC,QAAQ,GAAG,CAAC;;qBA2C5E;AAQM,6BAHI,MAAM,SAMhB;AAQM,4BAHI,OAAO,QAOjB;sBAvkBqB,WAAW"}
|
package/testing.js
CHANGED
|
@@ -79,6 +79,12 @@ export class TestCase {
|
|
|
79
79
|
* @type {string}
|
|
80
80
|
*/
|
|
81
81
|
this.testName = testName
|
|
82
|
+
/**
|
|
83
|
+
* This type can store custom information related to the TestCase
|
|
84
|
+
*
|
|
85
|
+
* @type {Map<string,any>}
|
|
86
|
+
*/
|
|
87
|
+
this.meta = new Map()
|
|
82
88
|
this._seed = null
|
|
83
89
|
this._prng = null
|
|
84
90
|
}
|
|
@@ -120,7 +126,7 @@ export const repetitionTime = Number(env.getParam('--repetition-time', '50'))
|
|
|
120
126
|
const testFilter = env.hasParam('--filter') ? env.getParam('--filter', '') : null
|
|
121
127
|
|
|
122
128
|
/* c8 ignore next */
|
|
123
|
-
const testFilterRegExp = testFilter !== null ? new RegExp(testFilter) :
|
|
129
|
+
const testFilterRegExp = testFilter !== null ? new RegExp(testFilter) : /.*/
|
|
124
130
|
|
|
125
131
|
const repeatTestRegex = /^(repeat|repeating)\s/
|
|
126
132
|
|
|
@@ -251,7 +257,7 @@ export const printCanvas = log.printCanvas
|
|
|
251
257
|
* ```
|
|
252
258
|
*
|
|
253
259
|
* @param {string} description
|
|
254
|
-
* @param {function(
|
|
260
|
+
* @param {function(...any):void} f
|
|
255
261
|
*/
|
|
256
262
|
export const group = (description, f) => {
|
|
257
263
|
log.group(log.BLUE, description)
|
|
@@ -278,7 +284,7 @@ export const group = (description, f) => {
|
|
|
278
284
|
* ```
|
|
279
285
|
*
|
|
280
286
|
* @param {string} description
|
|
281
|
-
* @param {function(
|
|
287
|
+
* @param {function(...any):Promise<any>} f
|
|
282
288
|
*/
|
|
283
289
|
export const groupAsync = async (description, f) => {
|
|
284
290
|
log.group(log.BLUE, description)
|
|
@@ -304,7 +310,7 @@ export const groupAsync = async (description, f) => {
|
|
|
304
310
|
* ```
|
|
305
311
|
*
|
|
306
312
|
* @param {string} message
|
|
307
|
-
* @param {function():void} f
|
|
313
|
+
* @param {function(...any):void} f
|
|
308
314
|
* @return {number} Returns a promise that resolves the measured duration to apply f
|
|
309
315
|
*/
|
|
310
316
|
export const measureTime = (message, f) => {
|
|
@@ -334,7 +340,7 @@ export const measureTime = (message, f) => {
|
|
|
334
340
|
* ```
|
|
335
341
|
*
|
|
336
342
|
* @param {string} message
|
|
337
|
-
* @param {function():Promise<any>} f
|
|
343
|
+
* @param {function(...any):Promise<any>} f
|
|
338
344
|
* @return {Promise<number>} Returns a promise that resolves the measured duration to apply f
|
|
339
345
|
*/
|
|
340
346
|
export const measureTimeAsync = async (message, f) => {
|
|
@@ -520,7 +526,7 @@ export const compare = (a, b, message = null, customCompare = compareValues) =>
|
|
|
520
526
|
export const assert = (property, message = null) => { property || fail(`Assertion failed${message !== null ? `: ${message}` : ''}`) }
|
|
521
527
|
|
|
522
528
|
/**
|
|
523
|
-
* @param {function():Promise<any>} f
|
|
529
|
+
* @param {function(...any):Promise<any>} f
|
|
524
530
|
*/
|
|
525
531
|
export const promiseRejected = async f => {
|
|
526
532
|
try {
|
|
@@ -532,7 +538,7 @@ export const promiseRejected = async f => {
|
|
|
532
538
|
}
|
|
533
539
|
|
|
534
540
|
/**
|
|
535
|
-
* @param {function():void} f
|
|
541
|
+
* @param {function(...any):void} f
|
|
536
542
|
* @throws {TestError}
|
|
537
543
|
*/
|
|
538
544
|
export const fails = f => {
|
|
@@ -546,7 +552,7 @@ export const fails = f => {
|
|
|
546
552
|
}
|
|
547
553
|
|
|
548
554
|
/**
|
|
549
|
-
* @param {function():Promise<any>} f
|
|
555
|
+
* @param {function(...any):Promise<any>} f
|
|
550
556
|
* @throws {TestError}
|
|
551
557
|
*/
|
|
552
558
|
export const failsAsync = async f => {
|
package/webcrypto.node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webcrypto.node.d.ts","sourceRoot":"","sources":["webcrypto.node.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webcrypto.node.d.ts","sourceRoot":"","sources":["webcrypto.node.js"],"names":[],"mappings":"AAEA,yBAA2D;AAC3D,kCAA6F"}
|
package/webcrypto.node.js
CHANGED