@fluid-experimental/property-common 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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/.eslintrc.js +9 -11
- package/.mocharc.json +6 -6
- package/README.md +1 -0
- package/api-extractor.json +2 -2
- package/dist/chronometer.d.ts.map +1 -1
- package/dist/chronometer.js.map +1 -1
- package/dist/consoleUtils.d.ts.map +1 -1
- package/dist/consoleUtils.js +4 -1
- package/dist/consoleUtils.js.map +1 -1
- package/dist/constants.d.ts +6 -6
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +16 -26
- package/dist/constants.js.map +1 -1
- package/dist/datastructures/collection.d.ts.map +1 -1
- package/dist/datastructures/collection.js +5 -4
- package/dist/datastructures/collection.js.map +1 -1
- package/dist/datastructures/dataArray.d.ts.map +1 -1
- package/dist/datastructures/dataArray.js +18 -9
- package/dist/datastructures/dataArray.js.map +1 -1
- package/dist/datastructures/integer64.d.ts.map +1 -1
- package/dist/datastructures/integer64.js +1 -1
- package/dist/datastructures/integer64.js.map +1 -1
- package/dist/datastructures/sortedCollection.d.ts.map +1 -1
- package/dist/datastructures/sortedCollection.js +3 -1
- package/dist/datastructures/sortedCollection.js.map +1 -1
- package/dist/deferredPromise.d.ts +1 -1
- package/dist/deferredPromise.d.ts.map +1 -1
- package/dist/deferredPromise.js +9 -3
- package/dist/deferredPromise.js.map +1 -1
- package/dist/deterministicRandomGenerator.d.ts.map +1 -1
- package/dist/deterministicRandomGenerator.js +6 -6
- package/dist/deterministicRandomGenerator.js.map +1 -1
- package/dist/error_objects/flaggedError.d.ts.map +1 -1
- package/dist/error_objects/flaggedError.js.map +1 -1
- package/dist/error_objects/httpError.d.ts.map +1 -1
- package/dist/error_objects/httpError.js +9 -9
- package/dist/error_objects/httpError.js.map +1 -1
- package/dist/error_objects/httpErrorNoStack.d.ts.map +1 -1
- package/dist/error_objects/httpErrorNoStack.js.map +1 -1
- package/dist/error_objects/operationError.d.ts +7 -7
- package/dist/error_objects/operationError.d.ts.map +1 -1
- package/dist/error_objects/operationError.js +7 -7
- package/dist/error_objects/operationError.js.map +1 -1
- package/dist/guidUtils.d.ts.map +1 -1
- package/dist/guidUtils.js +10 -9
- package/dist/guidUtils.js.map +1 -1
- package/dist/hashCalculator.d.ts.map +1 -1
- package/dist/hashCalculator.js.map +1 -1
- package/dist/joinPaths.d.ts.map +1 -1
- package/dist/joinPaths.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/chronometer.d.ts.map +1 -1
- package/lib/chronometer.js.map +1 -1
- package/lib/consoleUtils.d.ts.map +1 -1
- package/lib/consoleUtils.js +4 -1
- package/lib/consoleUtils.js.map +1 -1
- package/lib/constants.d.ts +6 -6
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +16 -26
- package/lib/constants.js.map +1 -1
- package/lib/datastructures/collection.d.ts.map +1 -1
- package/lib/datastructures/collection.js +5 -4
- package/lib/datastructures/collection.js.map +1 -1
- package/lib/datastructures/dataArray.d.ts.map +1 -1
- package/lib/datastructures/dataArray.js +18 -9
- package/lib/datastructures/dataArray.js.map +1 -1
- package/lib/datastructures/integer64.d.ts.map +1 -1
- package/lib/datastructures/integer64.js +1 -1
- package/lib/datastructures/integer64.js.map +1 -1
- package/lib/datastructures/sortedCollection.d.ts.map +1 -1
- package/lib/datastructures/sortedCollection.js +3 -1
- package/lib/datastructures/sortedCollection.js.map +1 -1
- package/lib/deferredPromise.d.ts +1 -1
- package/lib/deferredPromise.d.ts.map +1 -1
- package/lib/deferredPromise.js +9 -3
- package/lib/deferredPromise.js.map +1 -1
- package/lib/deterministicRandomGenerator.d.ts.map +1 -1
- package/lib/deterministicRandomGenerator.js +6 -6
- package/lib/deterministicRandomGenerator.js.map +1 -1
- package/lib/error_objects/flaggedError.d.ts.map +1 -1
- package/lib/error_objects/flaggedError.js.map +1 -1
- package/lib/error_objects/httpError.d.ts.map +1 -1
- package/lib/error_objects/httpError.js +9 -9
- package/lib/error_objects/httpError.js.map +1 -1
- package/lib/error_objects/httpErrorNoStack.d.ts.map +1 -1
- package/lib/error_objects/httpErrorNoStack.js.map +1 -1
- package/lib/error_objects/operationError.d.ts +7 -7
- package/lib/error_objects/operationError.d.ts.map +1 -1
- package/lib/error_objects/operationError.js +7 -7
- package/lib/error_objects/operationError.js.map +1 -1
- package/lib/guidUtils.d.ts.map +1 -1
- package/lib/guidUtils.js +10 -9
- package/lib/guidUtils.js.map +1 -1
- package/lib/hashCalculator.d.ts.map +1 -1
- package/lib/hashCalculator.js.map +1 -1
- package/lib/joinPaths.d.ts.map +1 -1
- package/lib/joinPaths.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +42 -40
- package/platform-dependent/README.md +1 -0
- package/platform-dependent/browser.js +5 -5
- package/platform-dependent/package.json +14 -14
- package/platform-dependent/server.js +5 -5
- package/prettier.config.cjs +1 -1
- package/src/chronometer.ts +174 -169
- package/src/consoleUtils.ts +16 -11
- package/src/constants.ts +1683 -1640
- package/src/datastructures/collection.ts +417 -416
- package/src/datastructures/dataArray.ts +516 -492
- package/src/datastructures/integer64.ts +102 -99
- package/src/datastructures/sortedCollection.ts +155 -145
- package/src/deferredPromise.ts +43 -42
- package/src/deterministicRandomGenerator.ts +59 -59
- package/src/error_objects/flaggedError.ts +29 -29
- package/src/error_objects/httpError.ts +45 -42
- package/src/error_objects/httpErrorNoStack.ts +17 -17
- package/src/error_objects/operationError.ts +62 -62
- package/src/guidUtils.ts +182 -171
- package/src/hashCalculator.ts +5 -2
- package/src/joinPaths.ts +15 -9
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
package/src/guidUtils.ts
CHANGED
|
@@ -21,74 +21,74 @@ const UINT_32HASH_PRIME = 16777619;
|
|
|
21
21
|
* Page 357, algorithm name: Ranlim32
|
|
22
22
|
*/
|
|
23
23
|
const guidRNG = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
24
|
+
u: 0,
|
|
25
|
+
v: 0,
|
|
26
|
+
w1: 0,
|
|
27
|
+
w2: 0,
|
|
28
|
+
isInitialized: false,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Initialize RNG.
|
|
32
|
+
* This function need to be called once, before the first GUID gets created.
|
|
33
|
+
*
|
|
34
|
+
* @param in_seed - Optional 32-bit seed for GUID RNG.
|
|
35
|
+
* If no seed is given, a combination of system's local time and `Math.random()` is used.
|
|
36
|
+
* @param in_enforceReInitialization - Optionally enforce re-initialization with another seed.
|
|
37
|
+
*
|
|
38
|
+
* @returns The seed used to initialize the RNG;
|
|
39
|
+
* If re-initialization is not enforced, a zero indicates that the RNG was not re-seeded.
|
|
40
|
+
*
|
|
41
|
+
* @alias property-common.initializeGUIDGenerator
|
|
42
|
+
*/
|
|
43
|
+
initialize(in_seed?: number, in_enforceReInitialization: boolean = false): number {
|
|
44
|
+
// Quit if the RNG has already been initialized and we do not
|
|
45
|
+
// want to enforce a re-initialization with a new seed
|
|
46
|
+
if (this.isInitialized && !in_enforceReInitialization) {
|
|
47
|
+
return 0;
|
|
48
|
+
} else {
|
|
49
|
+
this.isInitialized = true;
|
|
50
|
+
|
|
51
|
+
if (in_seed === undefined) {
|
|
52
|
+
const randomValues = generateRandomUInt32Array(4);
|
|
53
|
+
this.u = randomValues[0];
|
|
54
|
+
this.v = randomValues[1];
|
|
55
|
+
this.w1 = randomValues[2];
|
|
56
|
+
this.w2 = randomValues[3];
|
|
57
|
+
} else {
|
|
58
|
+
this.v = 224461437;
|
|
59
|
+
this.w1 = 521288629;
|
|
60
|
+
this.w2 = 362436069;
|
|
61
|
+
|
|
62
|
+
this.u = in_seed ^ this.v;
|
|
63
|
+
this.genRandUInt32();
|
|
64
|
+
this.v = this.u;
|
|
65
|
+
this.genRandUInt32();
|
|
66
|
+
}
|
|
67
|
+
return -1;
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @returns 32-bit random number based on the RNGs internal state
|
|
73
|
+
*/
|
|
74
|
+
genRandUInt32(): number {
|
|
75
|
+
this.u = multiply_uint32(this.u, 2891336453) + 1640531513;
|
|
76
|
+
this.v ^= this.v >>> 13;
|
|
77
|
+
this.v ^= this.v << 17;
|
|
78
|
+
this.v = ((this.v >>> 5) ^ this.v) >>> 0;
|
|
79
|
+
|
|
80
|
+
this.w1 = multiply_uint32(33378, this.w1 & 0xffff) + (this.w1 >>> 16);
|
|
81
|
+
this.w2 = multiply_uint32(57225, this.w2 & 0xffff) + (this.w2 >>> 16);
|
|
82
|
+
|
|
83
|
+
let x = this.u ^ (this.u << 9);
|
|
84
|
+
x ^= x >>> 17;
|
|
85
|
+
x ^= x << 6;
|
|
86
|
+
|
|
87
|
+
let y = this.w1 ^ (this.w1 << 17);
|
|
88
|
+
y ^= y >>> 15;
|
|
89
|
+
y ^= y << 5;
|
|
90
|
+
return (((x >>> 0) + this.v) ^ ((y >>> 0) + this.w2)) >>> 0;
|
|
91
|
+
},
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -108,13 +108,13 @@ const isBase64 = (GUID: string): boolean => GUID.length === 22;
|
|
|
108
108
|
* @returns - result of unsigned integer multiplication
|
|
109
109
|
*/
|
|
110
110
|
function multiply_uint32(a: number, b: number): number {
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
let n = a;
|
|
112
|
+
let m = b;
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
n >>>= 0;
|
|
115
|
+
m >>>= 0;
|
|
116
|
+
const nlo = n & 0xffff;
|
|
117
|
+
return ((((n - nlo) * m) >>> 0) + nlo * m) >>> 0;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -124,7 +124,8 @@ function multiply_uint32(a: number, b: number): number {
|
|
|
124
124
|
*
|
|
125
125
|
* @returns Url-friendly base64 encoding.
|
|
126
126
|
*/
|
|
127
|
-
const toUrlBase64 = (base64: string): string =>
|
|
127
|
+
const toUrlBase64 = (base64: string): string =>
|
|
128
|
+
base64.replace(/\+/g, "-").replace(/\//g, "_").split("=")[0];
|
|
128
129
|
|
|
129
130
|
/**
|
|
130
131
|
* Helper function to recover padding of base64 encoding
|
|
@@ -133,11 +134,11 @@ const toUrlBase64 = (base64: string): string => base64.replace(/\+/g, "-").repla
|
|
|
133
134
|
*
|
|
134
135
|
* @returns Padded base64 encoding.
|
|
135
136
|
*/
|
|
136
|
-
const toPaddedBase64 = function(x: string): string {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
const toPaddedBase64 = function (x: string): string {
|
|
138
|
+
let base64 = x;
|
|
139
|
+
const padLength = 4 - (base64.length % 4);
|
|
140
|
+
base64 += "=".repeat(padLength);
|
|
141
|
+
return base64;
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -148,23 +149,28 @@ const toPaddedBase64 = function(x: string): string {
|
|
|
148
149
|
*
|
|
149
150
|
* @returns The GUID
|
|
150
151
|
*/
|
|
151
|
-
const uint32x4ToGUID = function(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
const uint32x4ToGUID = function (
|
|
153
|
+
in_guidArray: Uint32Array | Int32Array | number[],
|
|
154
|
+
base64: boolean = false,
|
|
155
|
+
): string {
|
|
156
|
+
if (base64) {
|
|
157
|
+
const intArray = new Uint32Array(in_guidArray);
|
|
158
|
+
const byteArray = new Uint8Array(intArray.buffer);
|
|
159
|
+
const base64guid = base64js.fromByteArray(byteArray);
|
|
160
|
+
// return url-friendly base64
|
|
161
|
+
return toUrlBase64(base64guid);
|
|
162
|
+
} else {
|
|
163
|
+
// Convert to hexadecimal string
|
|
164
|
+
let str = "";
|
|
165
|
+
for (let i = 0; i < 4; i++) {
|
|
166
|
+
const hex = in_guidArray[i].toString(16);
|
|
167
|
+
str += "0".repeat(8 - hex.length) + hex;
|
|
168
|
+
}
|
|
169
|
+
return `${str.substr(0, 8)}-${str.substr(8, 4)}-${str.substr(12, 4)}-${str.substr(
|
|
170
|
+
16,
|
|
171
|
+
4,
|
|
172
|
+
)}-${str.substr(20, 12)}`;
|
|
173
|
+
}
|
|
168
174
|
};
|
|
169
175
|
|
|
170
176
|
/**
|
|
@@ -176,19 +182,22 @@ const uint32x4ToGUID = function(in_guidArray: Uint32Array | Int32Array | number[
|
|
|
176
182
|
* @returns Four 32-bit values
|
|
177
183
|
*
|
|
178
184
|
*/
|
|
179
|
-
const guidToUint32x4 = function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
185
|
+
const guidToUint32x4 = function (
|
|
186
|
+
in_guid: string,
|
|
187
|
+
result: Uint32Array = new Uint32Array(4),
|
|
188
|
+
): Uint32Array {
|
|
189
|
+
if (isBase64(in_guid)) {
|
|
190
|
+
const GUID = toPaddedBase64(in_guid);
|
|
191
|
+
const bytes = base64js.toByteArray(GUID);
|
|
192
|
+
const intArray = new Uint32Array(bytes.buffer);
|
|
193
|
+
result.set(intArray);
|
|
194
|
+
} else {
|
|
195
|
+
result[0] = parseInt(`0x${in_guid.substr(0, 8)}`, 16);
|
|
196
|
+
result[1] = parseInt(`0x${in_guid.substr(9, 4)}${in_guid.substr(14, 4)}`, 16);
|
|
197
|
+
result[2] = parseInt(`0x${in_guid.substr(19, 4)}${in_guid.substr(24, 4)}`, 16);
|
|
198
|
+
result[3] = parseInt(`0x${in_guid.substr(28, 8)}`, 16);
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
192
201
|
};
|
|
193
202
|
|
|
194
203
|
/**
|
|
@@ -220,23 +229,23 @@ const base16ToBase64 = (in_guid: string) => uint32x4ToGUID(guidToUint32x4(in_gui
|
|
|
220
229
|
*
|
|
221
230
|
* @returns The GUID
|
|
222
231
|
*/
|
|
223
|
-
const generateGUID = function(base64 = false): string {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
const generateGUID = function (base64 = false): string {
|
|
233
|
+
const rnds = new Uint32Array(4);
|
|
234
|
+
|
|
235
|
+
// Random numbers for GUID (4x32 bit)
|
|
236
|
+
rnds[0] = guidRNG.genRandUInt32();
|
|
237
|
+
rnds[1] = guidRNG.genRandUInt32();
|
|
238
|
+
rnds[2] = guidRNG.genRandUInt32();
|
|
239
|
+
rnds[3] = guidRNG.genRandUInt32();
|
|
240
|
+
return uint32x4ToGUID(rnds, base64);
|
|
232
241
|
};
|
|
233
242
|
|
|
234
243
|
// The last character is checked this way because last 4 bits of 22nd character are ignored
|
|
235
244
|
// by decoder, e.g. "+Q" and "+Z" result in the same decoding.
|
|
236
245
|
// The only characters with last 4 bits set to 0 are A, Q, g, w.
|
|
237
|
-
const reBase64 =
|
|
246
|
+
const reBase64 = /^[\w-]{21}[AQgw]$/;
|
|
238
247
|
// eslint-disable-next-line unicorn/no-unsafe-regex
|
|
239
|
-
const reBase16 =
|
|
248
|
+
const reBase16 = /^[\dA-Fa-f]{8}(?:-[\dA-Fa-f]{4}){3}-[\dA-Fa-f]{12}$/;
|
|
240
249
|
|
|
241
250
|
/**
|
|
242
251
|
* Routine used to check whether the given string is a valid GUID
|
|
@@ -254,42 +263,42 @@ const isGUID = (in_guid: string) => reBase16.test(in_guid) || reBase64.test(in_g
|
|
|
254
263
|
* @param in_array2 - Second array
|
|
255
264
|
* @returns New combined hash
|
|
256
265
|
*/
|
|
257
|
-
const hashCombine4xUint32 = function(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
266
|
+
const hashCombine4xUint32 = function (
|
|
267
|
+
in_array1: Uint32Array,
|
|
268
|
+
in_array2: Uint32Array,
|
|
269
|
+
io_result?: Uint32Array,
|
|
261
270
|
): Uint32Array {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
271
|
+
let accumulated = io_result;
|
|
272
|
+
if (accumulated === undefined) {
|
|
273
|
+
accumulated = new Uint32Array(in_array2);
|
|
274
|
+
} else {
|
|
275
|
+
accumulated[0] = in_array2[0];
|
|
276
|
+
accumulated[1] = in_array2[1];
|
|
277
|
+
accumulated[2] = in_array2[2];
|
|
278
|
+
accumulated[3] = in_array2[3];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
accumulated[0] += 0x9e3779b9;
|
|
282
|
+
accumulated[1] += 0x638f227;
|
|
283
|
+
accumulated[2] += 0x1aff2bad;
|
|
284
|
+
accumulated[3] += 0x3a8f05c5;
|
|
285
|
+
|
|
286
|
+
accumulated[0] += in_array1[3] << 6;
|
|
287
|
+
accumulated[1] += in_array1[0] << 6;
|
|
288
|
+
accumulated[2] += in_array1[1] << 6;
|
|
289
|
+
accumulated[3] += in_array1[2] << 6;
|
|
290
|
+
|
|
291
|
+
accumulated[0] += in_array1[2] >> 2;
|
|
292
|
+
accumulated[1] += in_array1[3] >> 2;
|
|
293
|
+
accumulated[2] += in_array1[0] >> 2;
|
|
294
|
+
accumulated[3] += in_array1[1] >> 2;
|
|
295
|
+
|
|
296
|
+
accumulated[0] = ((accumulated[0] ^ in_array1[1]) * UINT_32HASH_PRIME) >>> 0;
|
|
297
|
+
accumulated[1] = ((accumulated[1] ^ in_array1[2]) * UINT_32HASH_PRIME) >>> 0;
|
|
298
|
+
accumulated[2] = ((accumulated[2] ^ in_array1[3]) * UINT_32HASH_PRIME) >>> 0;
|
|
299
|
+
accumulated[3] = ((accumulated[3] ^ in_array1[0]) * UINT_32HASH_PRIME) >>> 0;
|
|
300
|
+
|
|
301
|
+
return accumulated;
|
|
293
302
|
};
|
|
294
303
|
|
|
295
304
|
/**
|
|
@@ -303,26 +312,28 @@ const hashCombine4xUint32 = function(
|
|
|
303
312
|
* @param base64 - Use base64 encoding instead of standart GUIDs
|
|
304
313
|
* @returns Combined GUID
|
|
305
314
|
*/
|
|
306
|
-
const combineGuids = function(in_guid1: string, in_guid2: string, base64 = false): string {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
315
|
+
const combineGuids = function (in_guid1: string, in_guid2: string, base64 = false): string {
|
|
316
|
+
const firstArray = guidToUint32x4(in_guid1);
|
|
317
|
+
const secondArray = guidToUint32x4(in_guid2);
|
|
318
|
+
const combined = hashCombine4xUint32(firstArray, secondArray);
|
|
319
|
+
return uint32x4ToGUID(combined, base64);
|
|
311
320
|
};
|
|
312
321
|
|
|
313
322
|
// Make sure the RNG is initialized
|
|
314
323
|
guidRNG.initialize();
|
|
315
324
|
|
|
316
|
-
const initializeGUIDGenerator = (...args) => {
|
|
325
|
+
const initializeGUIDGenerator = (...args) => {
|
|
326
|
+
guidRNG.initialize(...args);
|
|
327
|
+
};
|
|
317
328
|
|
|
318
329
|
export const GuidUtils = {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
330
|
+
uint32x4ToGUID,
|
|
331
|
+
guidToUint32x4,
|
|
332
|
+
base64Tobase16,
|
|
333
|
+
base16ToBase64,
|
|
334
|
+
initializeGUIDGenerator,
|
|
335
|
+
generateGUID,
|
|
336
|
+
isGUID,
|
|
337
|
+
combineGuids,
|
|
338
|
+
hashCombine4xUint32,
|
|
328
339
|
};
|
package/src/hashCalculator.ts
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
import murmurHash3 from "murmurhash3js";
|
|
12
12
|
|
|
13
13
|
export function calculateHash(key, seed = 0) {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const str = murmurHash3.x86.hash128(key, seed);
|
|
15
|
+
return `${str.substr(0, 8)}-${str.substr(8, 4)}-${str.substr(12, 4)}-${str.substr(
|
|
16
|
+
16,
|
|
17
|
+
4,
|
|
18
|
+
)}-${str.substr(20, 12)}`;
|
|
16
19
|
}
|
package/src/joinPaths.ts
CHANGED
|
@@ -17,14 +17,20 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @returns The joined path
|
|
19
19
|
*/
|
|
20
|
-
export function joinPaths(
|
|
21
|
-
|
|
20
|
+
export function joinPaths(
|
|
21
|
+
in_string1: string = "",
|
|
22
|
+
in_string2: string = "",
|
|
23
|
+
in_separator: string = "/",
|
|
24
|
+
): string {
|
|
25
|
+
let separator = in_separator;
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (
|
|
28
|
+
!in_string1 ||
|
|
29
|
+
!in_string2 ||
|
|
30
|
+
in_string1.substr(-in_separator.length) === in_separator ||
|
|
31
|
+
in_string2.substr(0, in_separator.length) === in_separator
|
|
32
|
+
) {
|
|
33
|
+
separator = "";
|
|
34
|
+
}
|
|
35
|
+
return in_string1 + separator + in_string2;
|
|
30
36
|
}
|
package/src/packageVersion.ts
CHANGED
package/tsconfig.esnext.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
},
|
|
7
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"exclude": [
|
|
12
|
-
"src/test/**/*"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"composite": true,
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*"],
|
|
9
|
+
"exclude": ["src/test/**/*"],
|
|
10
|
+
}
|