@nsshunt/stsfhirpg 1.2.20 → 1.2.21
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/dist/index.cjs +1304 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1326 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
- package/types/fhir-utils/fhirHashUtils.d.ts +1 -1
- package/types/fhir-utils/fhirHashUtils.d.ts.map +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DateTime } from "luxon";
|
|
2
|
-
import { x64 } from "murmurhash3js";
|
|
3
2
|
import fs from "node:fs";
|
|
4
3
|
import crypto, { randomUUID } from "crypto";
|
|
5
4
|
import { Sleep, defaultLogger } from "@nsshunt/stsutils";
|
|
@@ -13,6 +12,29 @@ import { isAbsoluteUrl } from "@nsshunt/stsfhirclient";
|
|
|
13
12
|
import cluster from "cluster";
|
|
14
13
|
import { Pool } from "pg";
|
|
15
14
|
import { TinyEmitter } from "tiny-emitter";
|
|
15
|
+
//#region \0rolldown/runtime.js
|
|
16
|
+
var __create = Object.create;
|
|
17
|
+
var __defProp = Object.defineProperty;
|
|
18
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
19
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
20
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
21
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
22
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
+
key = keys[i];
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
27
|
+
get: ((k) => from[k]).bind(null, key),
|
|
28
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
34
|
+
value: mod,
|
|
35
|
+
enumerable: true
|
|
36
|
+
}) : target, mod));
|
|
37
|
+
//#endregion
|
|
16
38
|
//#region src/fhir-utils/fhirDateUtils.ts
|
|
17
39
|
var FHIRDateUtils = class {
|
|
18
40
|
static fullDateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -70,45 +92,1338 @@ var FHIRDateUtils = class {
|
|
|
70
92
|
}
|
|
71
93
|
};
|
|
72
94
|
//#endregion
|
|
95
|
+
//#region node_modules/cuint/lib/uint32.js
|
|
96
|
+
var require_uint32 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
97
|
+
(function(root) {
|
|
98
|
+
UINT32(Math.pow(36, 5)), UINT32(Math.pow(16, 7)), UINT32(Math.pow(10, 9)), UINT32(Math.pow(2, 30));
|
|
99
|
+
UINT32(36), UINT32(16), UINT32(10), UINT32(2);
|
|
100
|
+
/**
|
|
101
|
+
* Represents an unsigned 32 bits integer
|
|
102
|
+
* @constructor
|
|
103
|
+
* @param {Number|String|Number} low bits | integer as a string | integer as a number
|
|
104
|
+
* @param {Number|Number|Undefined} high bits | radix (optional, default=10)
|
|
105
|
+
* @return
|
|
106
|
+
*/
|
|
107
|
+
function UINT32(l, h) {
|
|
108
|
+
if (!(this instanceof UINT32)) return new UINT32(l, h);
|
|
109
|
+
this._low = 0;
|
|
110
|
+
this._high = 0;
|
|
111
|
+
this.remainder = null;
|
|
112
|
+
if (typeof h == "undefined") return fromNumber.call(this, l);
|
|
113
|
+
if (typeof l == "string") return fromString.call(this, l, h);
|
|
114
|
+
fromBits.call(this, l, h);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Set the current _UINT32_ object with its low and high bits
|
|
118
|
+
* @method fromBits
|
|
119
|
+
* @param {Number} low bits
|
|
120
|
+
* @param {Number} high bits
|
|
121
|
+
* @return ThisExpression
|
|
122
|
+
*/
|
|
123
|
+
function fromBits(l, h) {
|
|
124
|
+
this._low = l | 0;
|
|
125
|
+
this._high = h | 0;
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
UINT32.prototype.fromBits = fromBits;
|
|
129
|
+
/**
|
|
130
|
+
* Set the current _UINT32_ object from a number
|
|
131
|
+
* @method fromNumber
|
|
132
|
+
* @param {Number} number
|
|
133
|
+
* @return ThisExpression
|
|
134
|
+
*/
|
|
135
|
+
function fromNumber(value) {
|
|
136
|
+
this._low = value & 65535;
|
|
137
|
+
this._high = value >>> 16;
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
UINT32.prototype.fromNumber = fromNumber;
|
|
141
|
+
/**
|
|
142
|
+
* Set the current _UINT32_ object from a string
|
|
143
|
+
* @method fromString
|
|
144
|
+
* @param {String} integer as a string
|
|
145
|
+
* @param {Number} radix (optional, default=10)
|
|
146
|
+
* @return ThisExpression
|
|
147
|
+
*/
|
|
148
|
+
function fromString(s, radix) {
|
|
149
|
+
var value = parseInt(s, radix || 10);
|
|
150
|
+
this._low = value & 65535;
|
|
151
|
+
this._high = value >>> 16;
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
UINT32.prototype.fromString = fromString;
|
|
155
|
+
/**
|
|
156
|
+
* Convert this _UINT32_ to a number
|
|
157
|
+
* @method toNumber
|
|
158
|
+
* @return {Number} the converted UINT32
|
|
159
|
+
*/
|
|
160
|
+
UINT32.prototype.toNumber = function() {
|
|
161
|
+
return this._high * 65536 + this._low;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Convert this _UINT32_ to a string
|
|
165
|
+
* @method toString
|
|
166
|
+
* @param {Number} radix (optional, default=10)
|
|
167
|
+
* @return {String} the converted UINT32
|
|
168
|
+
*/
|
|
169
|
+
UINT32.prototype.toString = function(radix) {
|
|
170
|
+
return this.toNumber().toString(radix || 10);
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Add two _UINT32_. The current _UINT32_ stores the result
|
|
174
|
+
* @method add
|
|
175
|
+
* @param {Object} other UINT32
|
|
176
|
+
* @return ThisExpression
|
|
177
|
+
*/
|
|
178
|
+
UINT32.prototype.add = function(other) {
|
|
179
|
+
var a00 = this._low + other._low;
|
|
180
|
+
var a16 = a00 >>> 16;
|
|
181
|
+
a16 += this._high + other._high;
|
|
182
|
+
this._low = a00 & 65535;
|
|
183
|
+
this._high = a16 & 65535;
|
|
184
|
+
return this;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Subtract two _UINT32_. The current _UINT32_ stores the result
|
|
188
|
+
* @method subtract
|
|
189
|
+
* @param {Object} other UINT32
|
|
190
|
+
* @return ThisExpression
|
|
191
|
+
*/
|
|
192
|
+
UINT32.prototype.subtract = function(other) {
|
|
193
|
+
return this.add(other.clone().negate());
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* Multiply two _UINT32_. The current _UINT32_ stores the result
|
|
197
|
+
* @method multiply
|
|
198
|
+
* @param {Object} other UINT32
|
|
199
|
+
* @return ThisExpression
|
|
200
|
+
*/
|
|
201
|
+
UINT32.prototype.multiply = function(other) {
|
|
202
|
+
var a16 = this._high;
|
|
203
|
+
var a00 = this._low;
|
|
204
|
+
var b16 = other._high;
|
|
205
|
+
var b00 = other._low;
|
|
206
|
+
var c16, c00 = a00 * b00;
|
|
207
|
+
c16 = c00 >>> 16;
|
|
208
|
+
c16 += a16 * b00;
|
|
209
|
+
c16 &= 65535;
|
|
210
|
+
c16 += a00 * b16;
|
|
211
|
+
this._low = c00 & 65535;
|
|
212
|
+
this._high = c16 & 65535;
|
|
213
|
+
return this;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Divide two _UINT32_. The current _UINT32_ stores the result.
|
|
217
|
+
* The remainder is made available as the _remainder_ property on
|
|
218
|
+
* the _UINT32_ object. It can be null, meaning there are no remainder.
|
|
219
|
+
* @method div
|
|
220
|
+
* @param {Object} other UINT32
|
|
221
|
+
* @return ThisExpression
|
|
222
|
+
*/
|
|
223
|
+
UINT32.prototype.div = function(other) {
|
|
224
|
+
if (other._low == 0 && other._high == 0) throw Error("division by zero");
|
|
225
|
+
if (other._high == 0 && other._low == 1) {
|
|
226
|
+
this.remainder = new UINT32(0);
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
if (other.gt(this)) {
|
|
230
|
+
this.remainder = this.clone();
|
|
231
|
+
this._low = 0;
|
|
232
|
+
this._high = 0;
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
if (this.eq(other)) {
|
|
236
|
+
this.remainder = new UINT32(0);
|
|
237
|
+
this._low = 1;
|
|
238
|
+
this._high = 0;
|
|
239
|
+
return this;
|
|
240
|
+
}
|
|
241
|
+
var _other = other.clone();
|
|
242
|
+
var i = -1;
|
|
243
|
+
while (!this.lt(_other)) {
|
|
244
|
+
_other.shiftLeft(1, true);
|
|
245
|
+
i++;
|
|
246
|
+
}
|
|
247
|
+
this.remainder = this.clone();
|
|
248
|
+
this._low = 0;
|
|
249
|
+
this._high = 0;
|
|
250
|
+
for (; i >= 0; i--) {
|
|
251
|
+
_other.shiftRight(1);
|
|
252
|
+
if (!this.remainder.lt(_other)) {
|
|
253
|
+
this.remainder.subtract(_other);
|
|
254
|
+
if (i >= 16) this._high |= 1 << i - 16;
|
|
255
|
+
else this._low |= 1 << i;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return this;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Negate the current _UINT32_
|
|
262
|
+
* @method negate
|
|
263
|
+
* @return ThisExpression
|
|
264
|
+
*/
|
|
265
|
+
UINT32.prototype.negate = function() {
|
|
266
|
+
var v = (~this._low & 65535) + 1;
|
|
267
|
+
this._low = v & 65535;
|
|
268
|
+
this._high = ~this._high + (v >>> 16) & 65535;
|
|
269
|
+
return this;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Equals
|
|
273
|
+
* @method eq
|
|
274
|
+
* @param {Object} other UINT32
|
|
275
|
+
* @return {Boolean}
|
|
276
|
+
*/
|
|
277
|
+
UINT32.prototype.equals = UINT32.prototype.eq = function(other) {
|
|
278
|
+
return this._low == other._low && this._high == other._high;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Greater than (strict)
|
|
282
|
+
* @method gt
|
|
283
|
+
* @param {Object} other UINT32
|
|
284
|
+
* @return {Boolean}
|
|
285
|
+
*/
|
|
286
|
+
UINT32.prototype.greaterThan = UINT32.prototype.gt = function(other) {
|
|
287
|
+
if (this._high > other._high) return true;
|
|
288
|
+
if (this._high < other._high) return false;
|
|
289
|
+
return this._low > other._low;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Less than (strict)
|
|
293
|
+
* @method lt
|
|
294
|
+
* @param {Object} other UINT32
|
|
295
|
+
* @return {Boolean}
|
|
296
|
+
*/
|
|
297
|
+
UINT32.prototype.lessThan = UINT32.prototype.lt = function(other) {
|
|
298
|
+
if (this._high < other._high) return true;
|
|
299
|
+
if (this._high > other._high) return false;
|
|
300
|
+
return this._low < other._low;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Bitwise OR
|
|
304
|
+
* @method or
|
|
305
|
+
* @param {Object} other UINT32
|
|
306
|
+
* @return ThisExpression
|
|
307
|
+
*/
|
|
308
|
+
UINT32.prototype.or = function(other) {
|
|
309
|
+
this._low |= other._low;
|
|
310
|
+
this._high |= other._high;
|
|
311
|
+
return this;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Bitwise AND
|
|
315
|
+
* @method and
|
|
316
|
+
* @param {Object} other UINT32
|
|
317
|
+
* @return ThisExpression
|
|
318
|
+
*/
|
|
319
|
+
UINT32.prototype.and = function(other) {
|
|
320
|
+
this._low &= other._low;
|
|
321
|
+
this._high &= other._high;
|
|
322
|
+
return this;
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* Bitwise NOT
|
|
326
|
+
* @method not
|
|
327
|
+
* @return ThisExpression
|
|
328
|
+
*/
|
|
329
|
+
UINT32.prototype.not = function() {
|
|
330
|
+
this._low = ~this._low & 65535;
|
|
331
|
+
this._high = ~this._high & 65535;
|
|
332
|
+
return this;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Bitwise XOR
|
|
336
|
+
* @method xor
|
|
337
|
+
* @param {Object} other UINT32
|
|
338
|
+
* @return ThisExpression
|
|
339
|
+
*/
|
|
340
|
+
UINT32.prototype.xor = function(other) {
|
|
341
|
+
this._low ^= other._low;
|
|
342
|
+
this._high ^= other._high;
|
|
343
|
+
return this;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Bitwise shift right
|
|
347
|
+
* @method shiftRight
|
|
348
|
+
* @param {Number} number of bits to shift
|
|
349
|
+
* @return ThisExpression
|
|
350
|
+
*/
|
|
351
|
+
UINT32.prototype.shiftRight = UINT32.prototype.shiftr = function(n) {
|
|
352
|
+
if (n > 16) {
|
|
353
|
+
this._low = this._high >> n - 16;
|
|
354
|
+
this._high = 0;
|
|
355
|
+
} else if (n == 16) {
|
|
356
|
+
this._low = this._high;
|
|
357
|
+
this._high = 0;
|
|
358
|
+
} else {
|
|
359
|
+
this._low = this._low >> n | this._high << 16 - n & 65535;
|
|
360
|
+
this._high >>= n;
|
|
361
|
+
}
|
|
362
|
+
return this;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Bitwise shift left
|
|
366
|
+
* @method shiftLeft
|
|
367
|
+
* @param {Number} number of bits to shift
|
|
368
|
+
* @param {Boolean} allow overflow
|
|
369
|
+
* @return ThisExpression
|
|
370
|
+
*/
|
|
371
|
+
UINT32.prototype.shiftLeft = UINT32.prototype.shiftl = function(n, allowOverflow) {
|
|
372
|
+
if (n > 16) {
|
|
373
|
+
this._high = this._low << n - 16;
|
|
374
|
+
this._low = 0;
|
|
375
|
+
if (!allowOverflow) this._high &= 65535;
|
|
376
|
+
} else if (n == 16) {
|
|
377
|
+
this._high = this._low;
|
|
378
|
+
this._low = 0;
|
|
379
|
+
} else {
|
|
380
|
+
this._high = this._high << n | this._low >> 16 - n;
|
|
381
|
+
this._low = this._low << n & 65535;
|
|
382
|
+
if (!allowOverflow) this._high &= 65535;
|
|
383
|
+
}
|
|
384
|
+
return this;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Bitwise rotate left
|
|
388
|
+
* @method rotl
|
|
389
|
+
* @param {Number} number of bits to rotate
|
|
390
|
+
* @return ThisExpression
|
|
391
|
+
*/
|
|
392
|
+
UINT32.prototype.rotateLeft = UINT32.prototype.rotl = function(n) {
|
|
393
|
+
var v = this._high << 16 | this._low;
|
|
394
|
+
v = v << n | v >>> 32 - n;
|
|
395
|
+
this._low = v & 65535;
|
|
396
|
+
this._high = v >>> 16;
|
|
397
|
+
return this;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Bitwise rotate right
|
|
401
|
+
* @method rotr
|
|
402
|
+
* @param {Number} number of bits to rotate
|
|
403
|
+
* @return ThisExpression
|
|
404
|
+
*/
|
|
405
|
+
UINT32.prototype.rotateRight = UINT32.prototype.rotr = function(n) {
|
|
406
|
+
var v = this._high << 16 | this._low;
|
|
407
|
+
v = v >>> n | v << 32 - n;
|
|
408
|
+
this._low = v & 65535;
|
|
409
|
+
this._high = v >>> 16;
|
|
410
|
+
return this;
|
|
411
|
+
};
|
|
412
|
+
/**
|
|
413
|
+
* Clone the current _UINT32_
|
|
414
|
+
* @method clone
|
|
415
|
+
* @return {Object} cloned UINT32
|
|
416
|
+
*/
|
|
417
|
+
UINT32.prototype.clone = function() {
|
|
418
|
+
return new UINT32(this._low, this._high);
|
|
419
|
+
};
|
|
420
|
+
if (typeof define != "undefined" && define.amd) define([], function() {
|
|
421
|
+
return UINT32;
|
|
422
|
+
});
|
|
423
|
+
else if (typeof module != "undefined" && module.exports) module.exports = UINT32;
|
|
424
|
+
else root["UINT32"] = UINT32;
|
|
425
|
+
})(exports);
|
|
426
|
+
}));
|
|
427
|
+
//#endregion
|
|
428
|
+
//#region node_modules/cuint/lib/uint64.js
|
|
429
|
+
var require_uint64 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
430
|
+
(function(root) {
|
|
431
|
+
var radixPowerCache = {
|
|
432
|
+
16: UINT64(Math.pow(16, 5)),
|
|
433
|
+
10: UINT64(Math.pow(10, 5)),
|
|
434
|
+
2: UINT64(Math.pow(2, 5))
|
|
435
|
+
};
|
|
436
|
+
var radixCache = {
|
|
437
|
+
16: UINT64(16),
|
|
438
|
+
10: UINT64(10),
|
|
439
|
+
2: UINT64(2)
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Represents an unsigned 64 bits integer
|
|
443
|
+
* @constructor
|
|
444
|
+
* @param {Number} first low bits (8)
|
|
445
|
+
* @param {Number} second low bits (8)
|
|
446
|
+
* @param {Number} first high bits (8)
|
|
447
|
+
* @param {Number} second high bits (8)
|
|
448
|
+
* or
|
|
449
|
+
* @param {Number} low bits (32)
|
|
450
|
+
* @param {Number} high bits (32)
|
|
451
|
+
* or
|
|
452
|
+
* @param {String|Number} integer as a string | integer as a number
|
|
453
|
+
* @param {Number|Undefined} radix (optional, default=10)
|
|
454
|
+
* @return
|
|
455
|
+
*/
|
|
456
|
+
function UINT64(a00, a16, a32, a48) {
|
|
457
|
+
if (!(this instanceof UINT64)) return new UINT64(a00, a16, a32, a48);
|
|
458
|
+
this.remainder = null;
|
|
459
|
+
if (typeof a00 == "string") return fromString.call(this, a00, a16);
|
|
460
|
+
if (typeof a16 == "undefined") return fromNumber.call(this, a00);
|
|
461
|
+
fromBits.apply(this, arguments);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Set the current _UINT64_ object with its low and high bits
|
|
465
|
+
* @method fromBits
|
|
466
|
+
* @param {Number} first low bits (8)
|
|
467
|
+
* @param {Number} second low bits (8)
|
|
468
|
+
* @param {Number} first high bits (8)
|
|
469
|
+
* @param {Number} second high bits (8)
|
|
470
|
+
* or
|
|
471
|
+
* @param {Number} low bits (32)
|
|
472
|
+
* @param {Number} high bits (32)
|
|
473
|
+
* @return ThisExpression
|
|
474
|
+
*/
|
|
475
|
+
function fromBits(a00, a16, a32, a48) {
|
|
476
|
+
if (typeof a32 == "undefined") {
|
|
477
|
+
this._a00 = a00 & 65535;
|
|
478
|
+
this._a16 = a00 >>> 16;
|
|
479
|
+
this._a32 = a16 & 65535;
|
|
480
|
+
this._a48 = a16 >>> 16;
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
this._a00 = a00 | 0;
|
|
484
|
+
this._a16 = a16 | 0;
|
|
485
|
+
this._a32 = a32 | 0;
|
|
486
|
+
this._a48 = a48 | 0;
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
UINT64.prototype.fromBits = fromBits;
|
|
490
|
+
/**
|
|
491
|
+
* Set the current _UINT64_ object from a number
|
|
492
|
+
* @method fromNumber
|
|
493
|
+
* @param {Number} number
|
|
494
|
+
* @return ThisExpression
|
|
495
|
+
*/
|
|
496
|
+
function fromNumber(value) {
|
|
497
|
+
this._a00 = value & 65535;
|
|
498
|
+
this._a16 = value >>> 16;
|
|
499
|
+
this._a32 = 0;
|
|
500
|
+
this._a48 = 0;
|
|
501
|
+
return this;
|
|
502
|
+
}
|
|
503
|
+
UINT64.prototype.fromNumber = fromNumber;
|
|
504
|
+
/**
|
|
505
|
+
* Set the current _UINT64_ object from a string
|
|
506
|
+
* @method fromString
|
|
507
|
+
* @param {String} integer as a string
|
|
508
|
+
* @param {Number} radix (optional, default=10)
|
|
509
|
+
* @return ThisExpression
|
|
510
|
+
*/
|
|
511
|
+
function fromString(s, radix) {
|
|
512
|
+
radix = radix || 10;
|
|
513
|
+
this._a00 = 0;
|
|
514
|
+
this._a16 = 0;
|
|
515
|
+
this._a32 = 0;
|
|
516
|
+
this._a48 = 0;
|
|
517
|
+
var radixUint = radixPowerCache[radix] || new UINT64(Math.pow(radix, 5));
|
|
518
|
+
for (var i = 0, len = s.length; i < len; i += 5) {
|
|
519
|
+
var size = Math.min(5, len - i);
|
|
520
|
+
var value = parseInt(s.slice(i, i + size), radix);
|
|
521
|
+
this.multiply(size < 5 ? new UINT64(Math.pow(radix, size)) : radixUint).add(new UINT64(value));
|
|
522
|
+
}
|
|
523
|
+
return this;
|
|
524
|
+
}
|
|
525
|
+
UINT64.prototype.fromString = fromString;
|
|
526
|
+
/**
|
|
527
|
+
* Convert this _UINT64_ to a number (last 32 bits are dropped)
|
|
528
|
+
* @method toNumber
|
|
529
|
+
* @return {Number} the converted UINT64
|
|
530
|
+
*/
|
|
531
|
+
UINT64.prototype.toNumber = function() {
|
|
532
|
+
return this._a16 * 65536 + this._a00;
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* Convert this _UINT64_ to a string
|
|
536
|
+
* @method toString
|
|
537
|
+
* @param {Number} radix (optional, default=10)
|
|
538
|
+
* @return {String} the converted UINT64
|
|
539
|
+
*/
|
|
540
|
+
UINT64.prototype.toString = function(radix) {
|
|
541
|
+
radix = radix || 10;
|
|
542
|
+
var radixUint = radixCache[radix] || new UINT64(radix);
|
|
543
|
+
if (!this.gt(radixUint)) return this.toNumber().toString(radix);
|
|
544
|
+
var self = this.clone();
|
|
545
|
+
var res = new Array(64);
|
|
546
|
+
for (var i = 63; i >= 0; i--) {
|
|
547
|
+
self.div(radixUint);
|
|
548
|
+
res[i] = self.remainder.toNumber().toString(radix);
|
|
549
|
+
if (!self.gt(radixUint)) break;
|
|
550
|
+
}
|
|
551
|
+
res[i - 1] = self.toNumber().toString(radix);
|
|
552
|
+
return res.join("");
|
|
553
|
+
};
|
|
554
|
+
/**
|
|
555
|
+
* Add two _UINT64_. The current _UINT64_ stores the result
|
|
556
|
+
* @method add
|
|
557
|
+
* @param {Object} other UINT64
|
|
558
|
+
* @return ThisExpression
|
|
559
|
+
*/
|
|
560
|
+
UINT64.prototype.add = function(other) {
|
|
561
|
+
var a00 = this._a00 + other._a00;
|
|
562
|
+
var a16 = a00 >>> 16;
|
|
563
|
+
a16 += this._a16 + other._a16;
|
|
564
|
+
var a32 = a16 >>> 16;
|
|
565
|
+
a32 += this._a32 + other._a32;
|
|
566
|
+
var a48 = a32 >>> 16;
|
|
567
|
+
a48 += this._a48 + other._a48;
|
|
568
|
+
this._a00 = a00 & 65535;
|
|
569
|
+
this._a16 = a16 & 65535;
|
|
570
|
+
this._a32 = a32 & 65535;
|
|
571
|
+
this._a48 = a48 & 65535;
|
|
572
|
+
return this;
|
|
573
|
+
};
|
|
574
|
+
/**
|
|
575
|
+
* Subtract two _UINT64_. The current _UINT64_ stores the result
|
|
576
|
+
* @method subtract
|
|
577
|
+
* @param {Object} other UINT64
|
|
578
|
+
* @return ThisExpression
|
|
579
|
+
*/
|
|
580
|
+
UINT64.prototype.subtract = function(other) {
|
|
581
|
+
return this.add(other.clone().negate());
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Multiply two _UINT64_. The current _UINT64_ stores the result
|
|
585
|
+
* @method multiply
|
|
586
|
+
* @param {Object} other UINT64
|
|
587
|
+
* @return ThisExpression
|
|
588
|
+
*/
|
|
589
|
+
UINT64.prototype.multiply = function(other) {
|
|
590
|
+
var a00 = this._a00;
|
|
591
|
+
var a16 = this._a16;
|
|
592
|
+
var a32 = this._a32;
|
|
593
|
+
var a48 = this._a48;
|
|
594
|
+
var b00 = other._a00;
|
|
595
|
+
var b16 = other._a16;
|
|
596
|
+
var b32 = other._a32;
|
|
597
|
+
var b48 = other._a48;
|
|
598
|
+
var c00 = a00 * b00;
|
|
599
|
+
var c16 = c00 >>> 16;
|
|
600
|
+
c16 += a00 * b16;
|
|
601
|
+
var c32 = c16 >>> 16;
|
|
602
|
+
c16 &= 65535;
|
|
603
|
+
c16 += a16 * b00;
|
|
604
|
+
c32 += c16 >>> 16;
|
|
605
|
+
c32 += a00 * b32;
|
|
606
|
+
var c48 = c32 >>> 16;
|
|
607
|
+
c32 &= 65535;
|
|
608
|
+
c32 += a16 * b16;
|
|
609
|
+
c48 += c32 >>> 16;
|
|
610
|
+
c32 &= 65535;
|
|
611
|
+
c32 += a32 * b00;
|
|
612
|
+
c48 += c32 >>> 16;
|
|
613
|
+
c48 += a00 * b48;
|
|
614
|
+
c48 &= 65535;
|
|
615
|
+
c48 += a16 * b32;
|
|
616
|
+
c48 &= 65535;
|
|
617
|
+
c48 += a32 * b16;
|
|
618
|
+
c48 &= 65535;
|
|
619
|
+
c48 += a48 * b00;
|
|
620
|
+
this._a00 = c00 & 65535;
|
|
621
|
+
this._a16 = c16 & 65535;
|
|
622
|
+
this._a32 = c32 & 65535;
|
|
623
|
+
this._a48 = c48 & 65535;
|
|
624
|
+
return this;
|
|
625
|
+
};
|
|
626
|
+
/**
|
|
627
|
+
* Divide two _UINT64_. The current _UINT64_ stores the result.
|
|
628
|
+
* The remainder is made available as the _remainder_ property on
|
|
629
|
+
* the _UINT64_ object. It can be null, meaning there are no remainder.
|
|
630
|
+
* @method div
|
|
631
|
+
* @param {Object} other UINT64
|
|
632
|
+
* @return ThisExpression
|
|
633
|
+
*/
|
|
634
|
+
UINT64.prototype.div = function(other) {
|
|
635
|
+
if (other._a16 == 0 && other._a32 == 0 && other._a48 == 0) {
|
|
636
|
+
if (other._a00 == 0) throw Error("division by zero");
|
|
637
|
+
if (other._a00 == 1) {
|
|
638
|
+
this.remainder = new UINT64(0);
|
|
639
|
+
return this;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
if (other.gt(this)) {
|
|
643
|
+
this.remainder = this.clone();
|
|
644
|
+
this._a00 = 0;
|
|
645
|
+
this._a16 = 0;
|
|
646
|
+
this._a32 = 0;
|
|
647
|
+
this._a48 = 0;
|
|
648
|
+
return this;
|
|
649
|
+
}
|
|
650
|
+
if (this.eq(other)) {
|
|
651
|
+
this.remainder = new UINT64(0);
|
|
652
|
+
this._a00 = 1;
|
|
653
|
+
this._a16 = 0;
|
|
654
|
+
this._a32 = 0;
|
|
655
|
+
this._a48 = 0;
|
|
656
|
+
return this;
|
|
657
|
+
}
|
|
658
|
+
var _other = other.clone();
|
|
659
|
+
var i = -1;
|
|
660
|
+
while (!this.lt(_other)) {
|
|
661
|
+
_other.shiftLeft(1, true);
|
|
662
|
+
i++;
|
|
663
|
+
}
|
|
664
|
+
this.remainder = this.clone();
|
|
665
|
+
this._a00 = 0;
|
|
666
|
+
this._a16 = 0;
|
|
667
|
+
this._a32 = 0;
|
|
668
|
+
this._a48 = 0;
|
|
669
|
+
for (; i >= 0; i--) {
|
|
670
|
+
_other.shiftRight(1);
|
|
671
|
+
if (!this.remainder.lt(_other)) {
|
|
672
|
+
this.remainder.subtract(_other);
|
|
673
|
+
if (i >= 48) this._a48 |= 1 << i - 48;
|
|
674
|
+
else if (i >= 32) this._a32 |= 1 << i - 32;
|
|
675
|
+
else if (i >= 16) this._a16 |= 1 << i - 16;
|
|
676
|
+
else this._a00 |= 1 << i;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
return this;
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* Negate the current _UINT64_
|
|
683
|
+
* @method negate
|
|
684
|
+
* @return ThisExpression
|
|
685
|
+
*/
|
|
686
|
+
UINT64.prototype.negate = function() {
|
|
687
|
+
var v = (~this._a00 & 65535) + 1;
|
|
688
|
+
this._a00 = v & 65535;
|
|
689
|
+
v = (~this._a16 & 65535) + (v >>> 16);
|
|
690
|
+
this._a16 = v & 65535;
|
|
691
|
+
v = (~this._a32 & 65535) + (v >>> 16);
|
|
692
|
+
this._a32 = v & 65535;
|
|
693
|
+
this._a48 = ~this._a48 + (v >>> 16) & 65535;
|
|
694
|
+
return this;
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
|
|
698
|
+
* @method eq
|
|
699
|
+
* @param {Object} other UINT64
|
|
700
|
+
* @return {Boolean}
|
|
701
|
+
*/
|
|
702
|
+
UINT64.prototype.equals = UINT64.prototype.eq = function(other) {
|
|
703
|
+
return this._a48 == other._a48 && this._a00 == other._a00 && this._a32 == other._a32 && this._a16 == other._a16;
|
|
704
|
+
};
|
|
705
|
+
/**
|
|
706
|
+
* Greater than (strict)
|
|
707
|
+
* @method gt
|
|
708
|
+
* @param {Object} other UINT64
|
|
709
|
+
* @return {Boolean}
|
|
710
|
+
*/
|
|
711
|
+
UINT64.prototype.greaterThan = UINT64.prototype.gt = function(other) {
|
|
712
|
+
if (this._a48 > other._a48) return true;
|
|
713
|
+
if (this._a48 < other._a48) return false;
|
|
714
|
+
if (this._a32 > other._a32) return true;
|
|
715
|
+
if (this._a32 < other._a32) return false;
|
|
716
|
+
if (this._a16 > other._a16) return true;
|
|
717
|
+
if (this._a16 < other._a16) return false;
|
|
718
|
+
return this._a00 > other._a00;
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Less than (strict)
|
|
722
|
+
* @method lt
|
|
723
|
+
* @param {Object} other UINT64
|
|
724
|
+
* @return {Boolean}
|
|
725
|
+
*/
|
|
726
|
+
UINT64.prototype.lessThan = UINT64.prototype.lt = function(other) {
|
|
727
|
+
if (this._a48 < other._a48) return true;
|
|
728
|
+
if (this._a48 > other._a48) return false;
|
|
729
|
+
if (this._a32 < other._a32) return true;
|
|
730
|
+
if (this._a32 > other._a32) return false;
|
|
731
|
+
if (this._a16 < other._a16) return true;
|
|
732
|
+
if (this._a16 > other._a16) return false;
|
|
733
|
+
return this._a00 < other._a00;
|
|
734
|
+
};
|
|
735
|
+
/**
|
|
736
|
+
* Bitwise OR
|
|
737
|
+
* @method or
|
|
738
|
+
* @param {Object} other UINT64
|
|
739
|
+
* @return ThisExpression
|
|
740
|
+
*/
|
|
741
|
+
UINT64.prototype.or = function(other) {
|
|
742
|
+
this._a00 |= other._a00;
|
|
743
|
+
this._a16 |= other._a16;
|
|
744
|
+
this._a32 |= other._a32;
|
|
745
|
+
this._a48 |= other._a48;
|
|
746
|
+
return this;
|
|
747
|
+
};
|
|
748
|
+
/**
|
|
749
|
+
* Bitwise AND
|
|
750
|
+
* @method and
|
|
751
|
+
* @param {Object} other UINT64
|
|
752
|
+
* @return ThisExpression
|
|
753
|
+
*/
|
|
754
|
+
UINT64.prototype.and = function(other) {
|
|
755
|
+
this._a00 &= other._a00;
|
|
756
|
+
this._a16 &= other._a16;
|
|
757
|
+
this._a32 &= other._a32;
|
|
758
|
+
this._a48 &= other._a48;
|
|
759
|
+
return this;
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* Bitwise XOR
|
|
763
|
+
* @method xor
|
|
764
|
+
* @param {Object} other UINT64
|
|
765
|
+
* @return ThisExpression
|
|
766
|
+
*/
|
|
767
|
+
UINT64.prototype.xor = function(other) {
|
|
768
|
+
this._a00 ^= other._a00;
|
|
769
|
+
this._a16 ^= other._a16;
|
|
770
|
+
this._a32 ^= other._a32;
|
|
771
|
+
this._a48 ^= other._a48;
|
|
772
|
+
return this;
|
|
773
|
+
};
|
|
774
|
+
/**
|
|
775
|
+
* Bitwise NOT
|
|
776
|
+
* @method not
|
|
777
|
+
* @return ThisExpression
|
|
778
|
+
*/
|
|
779
|
+
UINT64.prototype.not = function() {
|
|
780
|
+
this._a00 = ~this._a00 & 65535;
|
|
781
|
+
this._a16 = ~this._a16 & 65535;
|
|
782
|
+
this._a32 = ~this._a32 & 65535;
|
|
783
|
+
this._a48 = ~this._a48 & 65535;
|
|
784
|
+
return this;
|
|
785
|
+
};
|
|
786
|
+
/**
|
|
787
|
+
* Bitwise shift right
|
|
788
|
+
* @method shiftRight
|
|
789
|
+
* @param {Number} number of bits to shift
|
|
790
|
+
* @return ThisExpression
|
|
791
|
+
*/
|
|
792
|
+
UINT64.prototype.shiftRight = UINT64.prototype.shiftr = function(n) {
|
|
793
|
+
n %= 64;
|
|
794
|
+
if (n >= 48) {
|
|
795
|
+
this._a00 = this._a48 >> n - 48;
|
|
796
|
+
this._a16 = 0;
|
|
797
|
+
this._a32 = 0;
|
|
798
|
+
this._a48 = 0;
|
|
799
|
+
} else if (n >= 32) {
|
|
800
|
+
n -= 32;
|
|
801
|
+
this._a00 = (this._a32 >> n | this._a48 << 16 - n) & 65535;
|
|
802
|
+
this._a16 = this._a48 >> n & 65535;
|
|
803
|
+
this._a32 = 0;
|
|
804
|
+
this._a48 = 0;
|
|
805
|
+
} else if (n >= 16) {
|
|
806
|
+
n -= 16;
|
|
807
|
+
this._a00 = (this._a16 >> n | this._a32 << 16 - n) & 65535;
|
|
808
|
+
this._a16 = (this._a32 >> n | this._a48 << 16 - n) & 65535;
|
|
809
|
+
this._a32 = this._a48 >> n & 65535;
|
|
810
|
+
this._a48 = 0;
|
|
811
|
+
} else {
|
|
812
|
+
this._a00 = (this._a00 >> n | this._a16 << 16 - n) & 65535;
|
|
813
|
+
this._a16 = (this._a16 >> n | this._a32 << 16 - n) & 65535;
|
|
814
|
+
this._a32 = (this._a32 >> n | this._a48 << 16 - n) & 65535;
|
|
815
|
+
this._a48 = this._a48 >> n & 65535;
|
|
816
|
+
}
|
|
817
|
+
return this;
|
|
818
|
+
};
|
|
819
|
+
/**
|
|
820
|
+
* Bitwise shift left
|
|
821
|
+
* @method shiftLeft
|
|
822
|
+
* @param {Number} number of bits to shift
|
|
823
|
+
* @param {Boolean} allow overflow
|
|
824
|
+
* @return ThisExpression
|
|
825
|
+
*/
|
|
826
|
+
UINT64.prototype.shiftLeft = UINT64.prototype.shiftl = function(n, allowOverflow) {
|
|
827
|
+
n %= 64;
|
|
828
|
+
if (n >= 48) {
|
|
829
|
+
this._a48 = this._a00 << n - 48;
|
|
830
|
+
this._a32 = 0;
|
|
831
|
+
this._a16 = 0;
|
|
832
|
+
this._a00 = 0;
|
|
833
|
+
} else if (n >= 32) {
|
|
834
|
+
n -= 32;
|
|
835
|
+
this._a48 = this._a16 << n | this._a00 >> 16 - n;
|
|
836
|
+
this._a32 = this._a00 << n & 65535;
|
|
837
|
+
this._a16 = 0;
|
|
838
|
+
this._a00 = 0;
|
|
839
|
+
} else if (n >= 16) {
|
|
840
|
+
n -= 16;
|
|
841
|
+
this._a48 = this._a32 << n | this._a16 >> 16 - n;
|
|
842
|
+
this._a32 = (this._a16 << n | this._a00 >> 16 - n) & 65535;
|
|
843
|
+
this._a16 = this._a00 << n & 65535;
|
|
844
|
+
this._a00 = 0;
|
|
845
|
+
} else {
|
|
846
|
+
this._a48 = this._a48 << n | this._a32 >> 16 - n;
|
|
847
|
+
this._a32 = (this._a32 << n | this._a16 >> 16 - n) & 65535;
|
|
848
|
+
this._a16 = (this._a16 << n | this._a00 >> 16 - n) & 65535;
|
|
849
|
+
this._a00 = this._a00 << n & 65535;
|
|
850
|
+
}
|
|
851
|
+
if (!allowOverflow) this._a48 &= 65535;
|
|
852
|
+
return this;
|
|
853
|
+
};
|
|
854
|
+
/**
|
|
855
|
+
* Bitwise rotate left
|
|
856
|
+
* @method rotl
|
|
857
|
+
* @param {Number} number of bits to rotate
|
|
858
|
+
* @return ThisExpression
|
|
859
|
+
*/
|
|
860
|
+
UINT64.prototype.rotateLeft = UINT64.prototype.rotl = function(n) {
|
|
861
|
+
n %= 64;
|
|
862
|
+
if (n == 0) return this;
|
|
863
|
+
if (n >= 32) {
|
|
864
|
+
var v = this._a00;
|
|
865
|
+
this._a00 = this._a32;
|
|
866
|
+
this._a32 = v;
|
|
867
|
+
v = this._a48;
|
|
868
|
+
this._a48 = this._a16;
|
|
869
|
+
this._a16 = v;
|
|
870
|
+
if (n == 32) return this;
|
|
871
|
+
n -= 32;
|
|
872
|
+
}
|
|
873
|
+
var high = this._a48 << 16 | this._a32;
|
|
874
|
+
var low = this._a16 << 16 | this._a00;
|
|
875
|
+
var _high = high << n | low >>> 32 - n;
|
|
876
|
+
var _low = low << n | high >>> 32 - n;
|
|
877
|
+
this._a00 = _low & 65535;
|
|
878
|
+
this._a16 = _low >>> 16;
|
|
879
|
+
this._a32 = _high & 65535;
|
|
880
|
+
this._a48 = _high >>> 16;
|
|
881
|
+
return this;
|
|
882
|
+
};
|
|
883
|
+
/**
|
|
884
|
+
* Bitwise rotate right
|
|
885
|
+
* @method rotr
|
|
886
|
+
* @param {Number} number of bits to rotate
|
|
887
|
+
* @return ThisExpression
|
|
888
|
+
*/
|
|
889
|
+
UINT64.prototype.rotateRight = UINT64.prototype.rotr = function(n) {
|
|
890
|
+
n %= 64;
|
|
891
|
+
if (n == 0) return this;
|
|
892
|
+
if (n >= 32) {
|
|
893
|
+
var v = this._a00;
|
|
894
|
+
this._a00 = this._a32;
|
|
895
|
+
this._a32 = v;
|
|
896
|
+
v = this._a48;
|
|
897
|
+
this._a48 = this._a16;
|
|
898
|
+
this._a16 = v;
|
|
899
|
+
if (n == 32) return this;
|
|
900
|
+
n -= 32;
|
|
901
|
+
}
|
|
902
|
+
var high = this._a48 << 16 | this._a32;
|
|
903
|
+
var low = this._a16 << 16 | this._a00;
|
|
904
|
+
var _high = high >>> n | low << 32 - n;
|
|
905
|
+
var _low = low >>> n | high << 32 - n;
|
|
906
|
+
this._a00 = _low & 65535;
|
|
907
|
+
this._a16 = _low >>> 16;
|
|
908
|
+
this._a32 = _high & 65535;
|
|
909
|
+
this._a48 = _high >>> 16;
|
|
910
|
+
return this;
|
|
911
|
+
};
|
|
912
|
+
/**
|
|
913
|
+
* Clone the current _UINT64_
|
|
914
|
+
* @method clone
|
|
915
|
+
* @return {Object} cloned UINT64
|
|
916
|
+
*/
|
|
917
|
+
UINT64.prototype.clone = function() {
|
|
918
|
+
return new UINT64(this._a00, this._a16, this._a32, this._a48);
|
|
919
|
+
};
|
|
920
|
+
if (typeof define != "undefined" && define.amd) define([], function() {
|
|
921
|
+
return UINT64;
|
|
922
|
+
});
|
|
923
|
+
else if (typeof module != "undefined" && module.exports) module.exports = UINT64;
|
|
924
|
+
else root["UINT64"] = UINT64;
|
|
925
|
+
})(exports);
|
|
926
|
+
}));
|
|
927
|
+
//#endregion
|
|
928
|
+
//#region node_modules/cuint/index.js
|
|
929
|
+
var require_cuint = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
930
|
+
exports.UINT32 = require_uint32();
|
|
931
|
+
exports.UINT64 = require_uint64();
|
|
932
|
+
}));
|
|
933
|
+
//#endregion
|
|
934
|
+
//#region node_modules/xxhashjs/lib/xxhash.js
|
|
935
|
+
var require_xxhash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
936
|
+
/**
|
|
937
|
+
xxHash implementation in pure Javascript
|
|
938
|
+
|
|
939
|
+
Copyright (C) 2013, Pierre Curto
|
|
940
|
+
MIT license
|
|
941
|
+
*/
|
|
942
|
+
var UINT32 = require_cuint().UINT32;
|
|
943
|
+
UINT32.prototype.xxh_update = function(low, high) {
|
|
944
|
+
var b00 = PRIME32_2._low;
|
|
945
|
+
var b16 = PRIME32_2._high;
|
|
946
|
+
var c16, c00 = low * b00;
|
|
947
|
+
c16 = c00 >>> 16;
|
|
948
|
+
c16 += high * b00;
|
|
949
|
+
c16 &= 65535;
|
|
950
|
+
c16 += low * b16;
|
|
951
|
+
var a00 = this._low + (c00 & 65535);
|
|
952
|
+
var a16 = a00 >>> 16;
|
|
953
|
+
a16 += this._high + (c16 & 65535);
|
|
954
|
+
var v = a16 << 16 | a00 & 65535;
|
|
955
|
+
v = v << 13 | v >>> 19;
|
|
956
|
+
a00 = v & 65535;
|
|
957
|
+
a16 = v >>> 16;
|
|
958
|
+
b00 = PRIME32_1._low;
|
|
959
|
+
b16 = PRIME32_1._high;
|
|
960
|
+
c00 = a00 * b00;
|
|
961
|
+
c16 = c00 >>> 16;
|
|
962
|
+
c16 += a16 * b00;
|
|
963
|
+
c16 &= 65535;
|
|
964
|
+
c16 += a00 * b16;
|
|
965
|
+
this._low = c00 & 65535;
|
|
966
|
+
this._high = c16 & 65535;
|
|
967
|
+
};
|
|
968
|
+
var PRIME32_1 = UINT32("2654435761");
|
|
969
|
+
var PRIME32_2 = UINT32("2246822519");
|
|
970
|
+
var PRIME32_3 = UINT32("3266489917");
|
|
971
|
+
var PRIME32_4 = UINT32("668265263");
|
|
972
|
+
var PRIME32_5 = UINT32("374761393");
|
|
973
|
+
/**
|
|
974
|
+
* Convert string to proper UTF-8 array
|
|
975
|
+
* @param str Input string
|
|
976
|
+
* @returns {Uint8Array} UTF8 array is returned as uint8 array
|
|
977
|
+
*/
|
|
978
|
+
function toUTF8Array(str) {
|
|
979
|
+
var utf8 = [];
|
|
980
|
+
for (var i = 0, n = str.length; i < n; i++) {
|
|
981
|
+
var charcode = str.charCodeAt(i);
|
|
982
|
+
if (charcode < 128) utf8.push(charcode);
|
|
983
|
+
else if (charcode < 2048) utf8.push(192 | charcode >> 6, 128 | charcode & 63);
|
|
984
|
+
else if (charcode < 55296 || charcode >= 57344) utf8.push(224 | charcode >> 12, 128 | charcode >> 6 & 63, 128 | charcode & 63);
|
|
985
|
+
else {
|
|
986
|
+
i++;
|
|
987
|
+
charcode = 65536 + ((charcode & 1023) << 10 | str.charCodeAt(i) & 1023);
|
|
988
|
+
utf8.push(240 | charcode >> 18, 128 | charcode >> 12 & 63, 128 | charcode >> 6 & 63, 128 | charcode & 63);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return new Uint8Array(utf8);
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* XXH object used as a constructor or a function
|
|
995
|
+
* @constructor
|
|
996
|
+
* or
|
|
997
|
+
* @param {Object|String} input data
|
|
998
|
+
* @param {Number|UINT32} seed
|
|
999
|
+
* @return ThisExpression
|
|
1000
|
+
* or
|
|
1001
|
+
* @return {UINT32} xxHash
|
|
1002
|
+
*/
|
|
1003
|
+
function XXH() {
|
|
1004
|
+
if (arguments.length == 2) return new XXH(arguments[1]).update(arguments[0]).digest();
|
|
1005
|
+
if (!(this instanceof XXH)) return new XXH(arguments[0]);
|
|
1006
|
+
init.call(this, arguments[0]);
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Initialize the XXH instance with the given seed
|
|
1010
|
+
* @method init
|
|
1011
|
+
* @param {Number|Object} seed as a number or an unsigned 32 bits integer
|
|
1012
|
+
* @return ThisExpression
|
|
1013
|
+
*/
|
|
1014
|
+
function init(seed) {
|
|
1015
|
+
this.seed = seed instanceof UINT32 ? seed.clone() : UINT32(seed);
|
|
1016
|
+
this.v1 = this.seed.clone().add(PRIME32_1).add(PRIME32_2);
|
|
1017
|
+
this.v2 = this.seed.clone().add(PRIME32_2);
|
|
1018
|
+
this.v3 = this.seed.clone();
|
|
1019
|
+
this.v4 = this.seed.clone().subtract(PRIME32_1);
|
|
1020
|
+
this.total_len = 0;
|
|
1021
|
+
this.memsize = 0;
|
|
1022
|
+
this.memory = null;
|
|
1023
|
+
return this;
|
|
1024
|
+
}
|
|
1025
|
+
XXH.prototype.init = init;
|
|
1026
|
+
/**
|
|
1027
|
+
* Add data to be computed for the XXH hash
|
|
1028
|
+
* @method update
|
|
1029
|
+
* @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer
|
|
1030
|
+
* @return ThisExpression
|
|
1031
|
+
*/
|
|
1032
|
+
XXH.prototype.update = function(input) {
|
|
1033
|
+
var isString = typeof input == "string";
|
|
1034
|
+
var isArrayBuffer;
|
|
1035
|
+
if (isString) {
|
|
1036
|
+
input = toUTF8Array(input);
|
|
1037
|
+
isString = false;
|
|
1038
|
+
isArrayBuffer = true;
|
|
1039
|
+
}
|
|
1040
|
+
if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) {
|
|
1041
|
+
isArrayBuffer = true;
|
|
1042
|
+
input = new Uint8Array(input);
|
|
1043
|
+
}
|
|
1044
|
+
var p = 0;
|
|
1045
|
+
var len = input.length;
|
|
1046
|
+
var bEnd = p + len;
|
|
1047
|
+
if (len == 0) return this;
|
|
1048
|
+
this.total_len += len;
|
|
1049
|
+
if (this.memsize == 0) if (isString) this.memory = "";
|
|
1050
|
+
else if (isArrayBuffer) this.memory = new Uint8Array(16);
|
|
1051
|
+
else this.memory = new Buffer(16);
|
|
1052
|
+
if (this.memsize + len < 16) {
|
|
1053
|
+
if (isString) this.memory += input;
|
|
1054
|
+
else if (isArrayBuffer) this.memory.set(input.subarray(0, len), this.memsize);
|
|
1055
|
+
else input.copy(this.memory, this.memsize, 0, len);
|
|
1056
|
+
this.memsize += len;
|
|
1057
|
+
return this;
|
|
1058
|
+
}
|
|
1059
|
+
if (this.memsize > 0) {
|
|
1060
|
+
if (isString) this.memory += input.slice(0, 16 - this.memsize);
|
|
1061
|
+
else if (isArrayBuffer) this.memory.set(input.subarray(0, 16 - this.memsize), this.memsize);
|
|
1062
|
+
else input.copy(this.memory, this.memsize, 0, 16 - this.memsize);
|
|
1063
|
+
var p32 = 0;
|
|
1064
|
+
if (isString) {
|
|
1065
|
+
this.v1.xxh_update(this.memory.charCodeAt(p32 + 1) << 8 | this.memory.charCodeAt(p32), this.memory.charCodeAt(p32 + 3) << 8 | this.memory.charCodeAt(p32 + 2));
|
|
1066
|
+
p32 += 4;
|
|
1067
|
+
this.v2.xxh_update(this.memory.charCodeAt(p32 + 1) << 8 | this.memory.charCodeAt(p32), this.memory.charCodeAt(p32 + 3) << 8 | this.memory.charCodeAt(p32 + 2));
|
|
1068
|
+
p32 += 4;
|
|
1069
|
+
this.v3.xxh_update(this.memory.charCodeAt(p32 + 1) << 8 | this.memory.charCodeAt(p32), this.memory.charCodeAt(p32 + 3) << 8 | this.memory.charCodeAt(p32 + 2));
|
|
1070
|
+
p32 += 4;
|
|
1071
|
+
this.v4.xxh_update(this.memory.charCodeAt(p32 + 1) << 8 | this.memory.charCodeAt(p32), this.memory.charCodeAt(p32 + 3) << 8 | this.memory.charCodeAt(p32 + 2));
|
|
1072
|
+
} else {
|
|
1073
|
+
this.v1.xxh_update(this.memory[p32 + 1] << 8 | this.memory[p32], this.memory[p32 + 3] << 8 | this.memory[p32 + 2]);
|
|
1074
|
+
p32 += 4;
|
|
1075
|
+
this.v2.xxh_update(this.memory[p32 + 1] << 8 | this.memory[p32], this.memory[p32 + 3] << 8 | this.memory[p32 + 2]);
|
|
1076
|
+
p32 += 4;
|
|
1077
|
+
this.v3.xxh_update(this.memory[p32 + 1] << 8 | this.memory[p32], this.memory[p32 + 3] << 8 | this.memory[p32 + 2]);
|
|
1078
|
+
p32 += 4;
|
|
1079
|
+
this.v4.xxh_update(this.memory[p32 + 1] << 8 | this.memory[p32], this.memory[p32 + 3] << 8 | this.memory[p32 + 2]);
|
|
1080
|
+
}
|
|
1081
|
+
p += 16 - this.memsize;
|
|
1082
|
+
this.memsize = 0;
|
|
1083
|
+
if (isString) this.memory = "";
|
|
1084
|
+
}
|
|
1085
|
+
if (p <= bEnd - 16) {
|
|
1086
|
+
var limit = bEnd - 16;
|
|
1087
|
+
do {
|
|
1088
|
+
if (isString) {
|
|
1089
|
+
this.v1.xxh_update(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2));
|
|
1090
|
+
p += 4;
|
|
1091
|
+
this.v2.xxh_update(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2));
|
|
1092
|
+
p += 4;
|
|
1093
|
+
this.v3.xxh_update(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2));
|
|
1094
|
+
p += 4;
|
|
1095
|
+
this.v4.xxh_update(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2));
|
|
1096
|
+
} else {
|
|
1097
|
+
this.v1.xxh_update(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2]);
|
|
1098
|
+
p += 4;
|
|
1099
|
+
this.v2.xxh_update(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2]);
|
|
1100
|
+
p += 4;
|
|
1101
|
+
this.v3.xxh_update(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2]);
|
|
1102
|
+
p += 4;
|
|
1103
|
+
this.v4.xxh_update(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2]);
|
|
1104
|
+
}
|
|
1105
|
+
p += 4;
|
|
1106
|
+
} while (p <= limit);
|
|
1107
|
+
}
|
|
1108
|
+
if (p < bEnd) {
|
|
1109
|
+
if (isString) this.memory += input.slice(p);
|
|
1110
|
+
else if (isArrayBuffer) this.memory.set(input.subarray(p, bEnd), this.memsize);
|
|
1111
|
+
else input.copy(this.memory, this.memsize, p, bEnd);
|
|
1112
|
+
this.memsize = bEnd - p;
|
|
1113
|
+
}
|
|
1114
|
+
return this;
|
|
1115
|
+
};
|
|
1116
|
+
/**
|
|
1117
|
+
* Finalize the XXH computation. The XXH instance is ready for reuse for the given seed
|
|
1118
|
+
* @method digest
|
|
1119
|
+
* @return {UINT32} xxHash
|
|
1120
|
+
*/
|
|
1121
|
+
XXH.prototype.digest = function() {
|
|
1122
|
+
var input = this.memory;
|
|
1123
|
+
var isString = typeof input == "string";
|
|
1124
|
+
var p = 0;
|
|
1125
|
+
var bEnd = this.memsize;
|
|
1126
|
+
var h32, h;
|
|
1127
|
+
var u = new UINT32();
|
|
1128
|
+
if (this.total_len >= 16) h32 = this.v1.rotl(1).add(this.v2.rotl(7).add(this.v3.rotl(12).add(this.v4.rotl(18))));
|
|
1129
|
+
else h32 = this.seed.clone().add(PRIME32_5);
|
|
1130
|
+
h32.add(u.fromNumber(this.total_len));
|
|
1131
|
+
while (p <= bEnd - 4) {
|
|
1132
|
+
if (isString) u.fromBits(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2));
|
|
1133
|
+
else u.fromBits(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2]);
|
|
1134
|
+
h32.add(u.multiply(PRIME32_3)).rotl(17).multiply(PRIME32_4);
|
|
1135
|
+
p += 4;
|
|
1136
|
+
}
|
|
1137
|
+
while (p < bEnd) {
|
|
1138
|
+
u.fromBits(isString ? input.charCodeAt(p++) : input[p++], 0);
|
|
1139
|
+
h32.add(u.multiply(PRIME32_5)).rotl(11).multiply(PRIME32_1);
|
|
1140
|
+
}
|
|
1141
|
+
h = h32.clone().shiftRight(15);
|
|
1142
|
+
h32.xor(h).multiply(PRIME32_2);
|
|
1143
|
+
h = h32.clone().shiftRight(13);
|
|
1144
|
+
h32.xor(h).multiply(PRIME32_3);
|
|
1145
|
+
h = h32.clone().shiftRight(16);
|
|
1146
|
+
h32.xor(h);
|
|
1147
|
+
this.init(this.seed);
|
|
1148
|
+
return h32;
|
|
1149
|
+
};
|
|
1150
|
+
module.exports = XXH;
|
|
1151
|
+
}));
|
|
1152
|
+
//#endregion
|
|
1153
|
+
//#region node_modules/xxhashjs/lib/xxhash64.js
|
|
1154
|
+
var require_xxhash64 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1155
|
+
/**
|
|
1156
|
+
xxHash64 implementation in pure Javascript
|
|
1157
|
+
|
|
1158
|
+
Copyright (C) 2016, Pierre Curto
|
|
1159
|
+
MIT license
|
|
1160
|
+
*/
|
|
1161
|
+
var UINT64 = require_cuint().UINT64;
|
|
1162
|
+
var PRIME64_1 = UINT64("11400714785074694791");
|
|
1163
|
+
var PRIME64_2 = UINT64("14029467366897019727");
|
|
1164
|
+
var PRIME64_3 = UINT64("1609587929392839161");
|
|
1165
|
+
var PRIME64_4 = UINT64("9650029242287828579");
|
|
1166
|
+
var PRIME64_5 = UINT64("2870177450012600261");
|
|
1167
|
+
/**
|
|
1168
|
+
* Convert string to proper UTF-8 array
|
|
1169
|
+
* @param str Input string
|
|
1170
|
+
* @returns {Uint8Array} UTF8 array is returned as uint8 array
|
|
1171
|
+
*/
|
|
1172
|
+
function toUTF8Array(str) {
|
|
1173
|
+
var utf8 = [];
|
|
1174
|
+
for (var i = 0, n = str.length; i < n; i++) {
|
|
1175
|
+
var charcode = str.charCodeAt(i);
|
|
1176
|
+
if (charcode < 128) utf8.push(charcode);
|
|
1177
|
+
else if (charcode < 2048) utf8.push(192 | charcode >> 6, 128 | charcode & 63);
|
|
1178
|
+
else if (charcode < 55296 || charcode >= 57344) utf8.push(224 | charcode >> 12, 128 | charcode >> 6 & 63, 128 | charcode & 63);
|
|
1179
|
+
else {
|
|
1180
|
+
i++;
|
|
1181
|
+
charcode = 65536 + ((charcode & 1023) << 10 | str.charCodeAt(i) & 1023);
|
|
1182
|
+
utf8.push(240 | charcode >> 18, 128 | charcode >> 12 & 63, 128 | charcode >> 6 & 63, 128 | charcode & 63);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return new Uint8Array(utf8);
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* XXH64 object used as a constructor or a function
|
|
1189
|
+
* @constructor
|
|
1190
|
+
* or
|
|
1191
|
+
* @param {Object|String} input data
|
|
1192
|
+
* @param {Number|UINT64} seed
|
|
1193
|
+
* @return ThisExpression
|
|
1194
|
+
* or
|
|
1195
|
+
* @return {UINT64} xxHash
|
|
1196
|
+
*/
|
|
1197
|
+
function XXH64() {
|
|
1198
|
+
if (arguments.length == 2) return new XXH64(arguments[1]).update(arguments[0]).digest();
|
|
1199
|
+
if (!(this instanceof XXH64)) return new XXH64(arguments[0]);
|
|
1200
|
+
init.call(this, arguments[0]);
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Initialize the XXH64 instance with the given seed
|
|
1204
|
+
* @method init
|
|
1205
|
+
* @param {Number|Object} seed as a number or an unsigned 32 bits integer
|
|
1206
|
+
* @return ThisExpression
|
|
1207
|
+
*/
|
|
1208
|
+
function init(seed) {
|
|
1209
|
+
this.seed = seed instanceof UINT64 ? seed.clone() : UINT64(seed);
|
|
1210
|
+
this.v1 = this.seed.clone().add(PRIME64_1).add(PRIME64_2);
|
|
1211
|
+
this.v2 = this.seed.clone().add(PRIME64_2);
|
|
1212
|
+
this.v3 = this.seed.clone();
|
|
1213
|
+
this.v4 = this.seed.clone().subtract(PRIME64_1);
|
|
1214
|
+
this.total_len = 0;
|
|
1215
|
+
this.memsize = 0;
|
|
1216
|
+
this.memory = null;
|
|
1217
|
+
return this;
|
|
1218
|
+
}
|
|
1219
|
+
XXH64.prototype.init = init;
|
|
1220
|
+
/**
|
|
1221
|
+
* Add data to be computed for the XXH64 hash
|
|
1222
|
+
* @method update
|
|
1223
|
+
* @param {String|Buffer|ArrayBuffer} input as a string or nodejs Buffer or ArrayBuffer
|
|
1224
|
+
* @return ThisExpression
|
|
1225
|
+
*/
|
|
1226
|
+
XXH64.prototype.update = function(input) {
|
|
1227
|
+
var isString = typeof input == "string";
|
|
1228
|
+
var isArrayBuffer;
|
|
1229
|
+
if (isString) {
|
|
1230
|
+
input = toUTF8Array(input);
|
|
1231
|
+
isString = false;
|
|
1232
|
+
isArrayBuffer = true;
|
|
1233
|
+
}
|
|
1234
|
+
if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) {
|
|
1235
|
+
isArrayBuffer = true;
|
|
1236
|
+
input = new Uint8Array(input);
|
|
1237
|
+
}
|
|
1238
|
+
var p = 0;
|
|
1239
|
+
var len = input.length;
|
|
1240
|
+
var bEnd = p + len;
|
|
1241
|
+
if (len == 0) return this;
|
|
1242
|
+
this.total_len += len;
|
|
1243
|
+
if (this.memsize == 0) if (isString) this.memory = "";
|
|
1244
|
+
else if (isArrayBuffer) this.memory = new Uint8Array(32);
|
|
1245
|
+
else this.memory = new Buffer(32);
|
|
1246
|
+
if (this.memsize + len < 32) {
|
|
1247
|
+
if (isString) this.memory += input;
|
|
1248
|
+
else if (isArrayBuffer) this.memory.set(input.subarray(0, len), this.memsize);
|
|
1249
|
+
else input.copy(this.memory, this.memsize, 0, len);
|
|
1250
|
+
this.memsize += len;
|
|
1251
|
+
return this;
|
|
1252
|
+
}
|
|
1253
|
+
if (this.memsize > 0) {
|
|
1254
|
+
if (isString) this.memory += input.slice(0, 32 - this.memsize);
|
|
1255
|
+
else if (isArrayBuffer) this.memory.set(input.subarray(0, 32 - this.memsize), this.memsize);
|
|
1256
|
+
else input.copy(this.memory, this.memsize, 0, 32 - this.memsize);
|
|
1257
|
+
var p64 = 0;
|
|
1258
|
+
if (isString) {
|
|
1259
|
+
var other = UINT64(this.memory.charCodeAt(p64 + 1) << 8 | this.memory.charCodeAt(p64), this.memory.charCodeAt(p64 + 3) << 8 | this.memory.charCodeAt(p64 + 2), this.memory.charCodeAt(p64 + 5) << 8 | this.memory.charCodeAt(p64 + 4), this.memory.charCodeAt(p64 + 7) << 8 | this.memory.charCodeAt(p64 + 6));
|
|
1260
|
+
this.v1.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1261
|
+
p64 += 8;
|
|
1262
|
+
other = UINT64(this.memory.charCodeAt(p64 + 1) << 8 | this.memory.charCodeAt(p64), this.memory.charCodeAt(p64 + 3) << 8 | this.memory.charCodeAt(p64 + 2), this.memory.charCodeAt(p64 + 5) << 8 | this.memory.charCodeAt(p64 + 4), this.memory.charCodeAt(p64 + 7) << 8 | this.memory.charCodeAt(p64 + 6));
|
|
1263
|
+
this.v2.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1264
|
+
p64 += 8;
|
|
1265
|
+
other = UINT64(this.memory.charCodeAt(p64 + 1) << 8 | this.memory.charCodeAt(p64), this.memory.charCodeAt(p64 + 3) << 8 | this.memory.charCodeAt(p64 + 2), this.memory.charCodeAt(p64 + 5) << 8 | this.memory.charCodeAt(p64 + 4), this.memory.charCodeAt(p64 + 7) << 8 | this.memory.charCodeAt(p64 + 6));
|
|
1266
|
+
this.v3.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1267
|
+
p64 += 8;
|
|
1268
|
+
other = UINT64(this.memory.charCodeAt(p64 + 1) << 8 | this.memory.charCodeAt(p64), this.memory.charCodeAt(p64 + 3) << 8 | this.memory.charCodeAt(p64 + 2), this.memory.charCodeAt(p64 + 5) << 8 | this.memory.charCodeAt(p64 + 4), this.memory.charCodeAt(p64 + 7) << 8 | this.memory.charCodeAt(p64 + 6));
|
|
1269
|
+
this.v4.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1270
|
+
} else {
|
|
1271
|
+
var other = UINT64(this.memory[p64 + 1] << 8 | this.memory[p64], this.memory[p64 + 3] << 8 | this.memory[p64 + 2], this.memory[p64 + 5] << 8 | this.memory[p64 + 4], this.memory[p64 + 7] << 8 | this.memory[p64 + 6]);
|
|
1272
|
+
this.v1.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1273
|
+
p64 += 8;
|
|
1274
|
+
other = UINT64(this.memory[p64 + 1] << 8 | this.memory[p64], this.memory[p64 + 3] << 8 | this.memory[p64 + 2], this.memory[p64 + 5] << 8 | this.memory[p64 + 4], this.memory[p64 + 7] << 8 | this.memory[p64 + 6]);
|
|
1275
|
+
this.v2.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1276
|
+
p64 += 8;
|
|
1277
|
+
other = UINT64(this.memory[p64 + 1] << 8 | this.memory[p64], this.memory[p64 + 3] << 8 | this.memory[p64 + 2], this.memory[p64 + 5] << 8 | this.memory[p64 + 4], this.memory[p64 + 7] << 8 | this.memory[p64 + 6]);
|
|
1278
|
+
this.v3.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1279
|
+
p64 += 8;
|
|
1280
|
+
other = UINT64(this.memory[p64 + 1] << 8 | this.memory[p64], this.memory[p64 + 3] << 8 | this.memory[p64 + 2], this.memory[p64 + 5] << 8 | this.memory[p64 + 4], this.memory[p64 + 7] << 8 | this.memory[p64 + 6]);
|
|
1281
|
+
this.v4.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1282
|
+
}
|
|
1283
|
+
p += 32 - this.memsize;
|
|
1284
|
+
this.memsize = 0;
|
|
1285
|
+
if (isString) this.memory = "";
|
|
1286
|
+
}
|
|
1287
|
+
if (p <= bEnd - 32) {
|
|
1288
|
+
var limit = bEnd - 32;
|
|
1289
|
+
do {
|
|
1290
|
+
if (isString) {
|
|
1291
|
+
var other = UINT64(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2), input.charCodeAt(p + 5) << 8 | input.charCodeAt(p + 4), input.charCodeAt(p + 7) << 8 | input.charCodeAt(p + 6));
|
|
1292
|
+
this.v1.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1293
|
+
p += 8;
|
|
1294
|
+
other = UINT64(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2), input.charCodeAt(p + 5) << 8 | input.charCodeAt(p + 4), input.charCodeAt(p + 7) << 8 | input.charCodeAt(p + 6));
|
|
1295
|
+
this.v2.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1296
|
+
p += 8;
|
|
1297
|
+
other = UINT64(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2), input.charCodeAt(p + 5) << 8 | input.charCodeAt(p + 4), input.charCodeAt(p + 7) << 8 | input.charCodeAt(p + 6));
|
|
1298
|
+
this.v3.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1299
|
+
p += 8;
|
|
1300
|
+
other = UINT64(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2), input.charCodeAt(p + 5) << 8 | input.charCodeAt(p + 4), input.charCodeAt(p + 7) << 8 | input.charCodeAt(p + 6));
|
|
1301
|
+
this.v4.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1302
|
+
} else {
|
|
1303
|
+
var other = UINT64(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2], input[p + 5] << 8 | input[p + 4], input[p + 7] << 8 | input[p + 6]);
|
|
1304
|
+
this.v1.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1305
|
+
p += 8;
|
|
1306
|
+
other = UINT64(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2], input[p + 5] << 8 | input[p + 4], input[p + 7] << 8 | input[p + 6]);
|
|
1307
|
+
this.v2.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1308
|
+
p += 8;
|
|
1309
|
+
other = UINT64(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2], input[p + 5] << 8 | input[p + 4], input[p + 7] << 8 | input[p + 6]);
|
|
1310
|
+
this.v3.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1311
|
+
p += 8;
|
|
1312
|
+
other = UINT64(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2], input[p + 5] << 8 | input[p + 4], input[p + 7] << 8 | input[p + 6]);
|
|
1313
|
+
this.v4.add(other.multiply(PRIME64_2)).rotl(31).multiply(PRIME64_1);
|
|
1314
|
+
}
|
|
1315
|
+
p += 8;
|
|
1316
|
+
} while (p <= limit);
|
|
1317
|
+
}
|
|
1318
|
+
if (p < bEnd) {
|
|
1319
|
+
if (isString) this.memory += input.slice(p);
|
|
1320
|
+
else if (isArrayBuffer) this.memory.set(input.subarray(p, bEnd), this.memsize);
|
|
1321
|
+
else input.copy(this.memory, this.memsize, p, bEnd);
|
|
1322
|
+
this.memsize = bEnd - p;
|
|
1323
|
+
}
|
|
1324
|
+
return this;
|
|
1325
|
+
};
|
|
1326
|
+
/**
|
|
1327
|
+
* Finalize the XXH64 computation. The XXH64 instance is ready for reuse for the given seed
|
|
1328
|
+
* @method digest
|
|
1329
|
+
* @return {UINT64} xxHash
|
|
1330
|
+
*/
|
|
1331
|
+
XXH64.prototype.digest = function() {
|
|
1332
|
+
var input = this.memory;
|
|
1333
|
+
var isString = typeof input == "string";
|
|
1334
|
+
var p = 0;
|
|
1335
|
+
var bEnd = this.memsize;
|
|
1336
|
+
var h64, h;
|
|
1337
|
+
var u = new UINT64();
|
|
1338
|
+
if (this.total_len >= 32) {
|
|
1339
|
+
h64 = this.v1.clone().rotl(1);
|
|
1340
|
+
h64.add(this.v2.clone().rotl(7));
|
|
1341
|
+
h64.add(this.v3.clone().rotl(12));
|
|
1342
|
+
h64.add(this.v4.clone().rotl(18));
|
|
1343
|
+
h64.xor(this.v1.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1));
|
|
1344
|
+
h64.multiply(PRIME64_1).add(PRIME64_4);
|
|
1345
|
+
h64.xor(this.v2.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1));
|
|
1346
|
+
h64.multiply(PRIME64_1).add(PRIME64_4);
|
|
1347
|
+
h64.xor(this.v3.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1));
|
|
1348
|
+
h64.multiply(PRIME64_1).add(PRIME64_4);
|
|
1349
|
+
h64.xor(this.v4.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1));
|
|
1350
|
+
h64.multiply(PRIME64_1).add(PRIME64_4);
|
|
1351
|
+
} else h64 = this.seed.clone().add(PRIME64_5);
|
|
1352
|
+
h64.add(u.fromNumber(this.total_len));
|
|
1353
|
+
while (p <= bEnd - 8) {
|
|
1354
|
+
if (isString) u.fromBits(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2), input.charCodeAt(p + 5) << 8 | input.charCodeAt(p + 4), input.charCodeAt(p + 7) << 8 | input.charCodeAt(p + 6));
|
|
1355
|
+
else u.fromBits(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2], input[p + 5] << 8 | input[p + 4], input[p + 7] << 8 | input[p + 6]);
|
|
1356
|
+
u.multiply(PRIME64_2).rotl(31).multiply(PRIME64_1);
|
|
1357
|
+
h64.xor(u).rotl(27).multiply(PRIME64_1).add(PRIME64_4);
|
|
1358
|
+
p += 8;
|
|
1359
|
+
}
|
|
1360
|
+
if (p + 4 <= bEnd) {
|
|
1361
|
+
if (isString) u.fromBits(input.charCodeAt(p + 1) << 8 | input.charCodeAt(p), input.charCodeAt(p + 3) << 8 | input.charCodeAt(p + 2), 0, 0);
|
|
1362
|
+
else u.fromBits(input[p + 1] << 8 | input[p], input[p + 3] << 8 | input[p + 2], 0, 0);
|
|
1363
|
+
h64.xor(u.multiply(PRIME64_1)).rotl(23).multiply(PRIME64_2).add(PRIME64_3);
|
|
1364
|
+
p += 4;
|
|
1365
|
+
}
|
|
1366
|
+
while (p < bEnd) {
|
|
1367
|
+
u.fromBits(isString ? input.charCodeAt(p++) : input[p++], 0, 0, 0);
|
|
1368
|
+
h64.xor(u.multiply(PRIME64_5)).rotl(11).multiply(PRIME64_1);
|
|
1369
|
+
}
|
|
1370
|
+
h = h64.clone().shiftRight(33);
|
|
1371
|
+
h64.xor(h).multiply(PRIME64_2);
|
|
1372
|
+
h = h64.clone().shiftRight(29);
|
|
1373
|
+
h64.xor(h).multiply(PRIME64_3);
|
|
1374
|
+
h = h64.clone().shiftRight(32);
|
|
1375
|
+
h64.xor(h);
|
|
1376
|
+
this.init(this.seed);
|
|
1377
|
+
return h64;
|
|
1378
|
+
};
|
|
1379
|
+
module.exports = XXH64;
|
|
1380
|
+
}));
|
|
1381
|
+
//#endregion
|
|
73
1382
|
//#region src/fhir-utils/fhirHashUtils.ts
|
|
1383
|
+
var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1384
|
+
module.exports = {
|
|
1385
|
+
h32: require_xxhash(),
|
|
1386
|
+
h64: require_xxhash64()
|
|
1387
|
+
};
|
|
1388
|
+
})))(), 1);
|
|
74
1389
|
/**
|
|
75
1390
|
* Normalize string values similar to HAPI FHIR (trim, collapse whitespace, lowercase)
|
|
76
1391
|
*/
|
|
77
1392
|
function normalizeStringParam(input) {
|
|
78
1393
|
return input.trim().replace(/\s+/g, " ").toLowerCase();
|
|
79
1394
|
}
|
|
1395
|
+
function xxhash64Signed(input) {
|
|
1396
|
+
const hashHex = import_lib.default.h64(input, 43981).toString(16).padStart(16, "0");
|
|
1397
|
+
return Buffer.from(hashHex, "hex").readBigInt64BE(0);
|
|
1398
|
+
}
|
|
80
1399
|
/**
|
|
81
1400
|
* Converts first 64 bits of MurmurHash3_x64_128 result into signed BigInt
|
|
82
1401
|
*/
|
|
83
|
-
function murmur64Signed(input) {
|
|
84
|
-
const hex128 = x64.hash128(input);
|
|
85
|
-
return Buffer.from(hex128.slice(0, 16), "hex").readBigInt64LE(0);
|
|
86
|
-
}
|
|
87
1402
|
/**
|
|
88
1403
|
* Compute hash for a normalized string search parameter
|
|
89
1404
|
*/
|
|
90
1405
|
function hashStringParam(input, normalize) {
|
|
91
|
-
if (normalize === true) return
|
|
92
|
-
else return
|
|
1406
|
+
if (normalize === true) return xxhash64Signed(normalizeStringParam(input));
|
|
1407
|
+
else return xxhash64Signed(input);
|
|
93
1408
|
}
|
|
94
1409
|
/**
|
|
95
1410
|
* Compute hash for a token search parameter (system|code)
|
|
96
1411
|
*/
|
|
97
1412
|
function hashTokenParam({ system, code }) {
|
|
98
|
-
return
|
|
1413
|
+
return xxhash64Signed((system ?? "") + "|" + code);
|
|
99
1414
|
}
|
|
100
1415
|
/**
|
|
101
1416
|
* Compute hash for a reference search parameter
|
|
102
1417
|
* Case-sensitive and used as-is
|
|
103
1418
|
*/
|
|
104
1419
|
function hashReferenceParam(reference) {
|
|
105
|
-
return
|
|
1420
|
+
return xxhash64Signed(reference);
|
|
106
1421
|
}
|
|
107
1422
|
/**
|
|
108
1423
|
* Compute hash for a URI parameter (optionally lowercased)
|
|
109
1424
|
*/
|
|
110
1425
|
function hashUriParam(uri, lowercase = false) {
|
|
111
|
-
return
|
|
1426
|
+
return xxhash64Signed(lowercase ? uri.toLowerCase() : uri);
|
|
112
1427
|
}
|
|
113
1428
|
//#endregion
|
|
114
1429
|
//#region src/redisDistributedLock.ts
|
|
@@ -3214,6 +4529,6 @@ var PGFhirAccessLayer = class extends TinyEmitter {
|
|
|
3214
4529
|
};
|
|
3215
4530
|
};
|
|
3216
4531
|
//#endregion
|
|
3217
|
-
export { DBSearchIndex, FHIRDateUtils, PGFhirAccessLayer, ResourceHelper, hashReferenceParam, hashStringParam, hashTokenParam, hashUriParam,
|
|
4532
|
+
export { DBSearchIndex, FHIRDateUtils, PGFhirAccessLayer, ResourceHelper, hashReferenceParam, hashStringParam, hashTokenParam, hashUriParam, normalizeStringParam, xxhash64Signed };
|
|
3218
4533
|
|
|
3219
4534
|
//# sourceMappingURL=index.mjs.map
|