@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
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
"name": "@fluid-internal/platform-dependent",
|
|
3
|
+
"version": "2.0.0-dev.4.1.0.148229",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Helper package that separates code for browser and server.",
|
|
6
|
+
"homepage": "https://fluidframework.com",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/microsoft/FluidFramework.git",
|
|
10
|
+
"directory": "experimental/PropertyDDS/packages/property-common/platform-dependent"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "Microsoft and contributors",
|
|
14
|
+
"main": "server.js",
|
|
15
|
+
"browser": "browser.js"
|
|
16
16
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
const crypto = require(
|
|
5
|
+
const crypto = require("crypto");
|
|
6
6
|
/**
|
|
7
7
|
* Create an array with random uint32 values
|
|
8
8
|
*
|
|
@@ -10,11 +10,11 @@ const crypto = require('crypto');
|
|
|
10
10
|
* @return {number[]} - an array with random values
|
|
11
11
|
*/
|
|
12
12
|
function generateRandomUInt32Array(length) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const buffer = Buffer.alloc(length * 4);
|
|
14
|
+
crypto.randomFillSync(buffer);
|
|
15
|
+
return Array.from({ length }, (_, i) => buffer.readUIntBE(i * 4, 4));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
module.exports = {
|
|
19
|
-
|
|
19
|
+
generateRandomUInt32Array,
|
|
20
20
|
};
|
package/prettier.config.cjs
CHANGED
package/src/chronometer.ts
CHANGED
|
@@ -14,195 +14,200 @@ declare let process: any;
|
|
|
14
14
|
* All the chronometer implementations (hrtime, window.performance, and date:
|
|
15
15
|
*/
|
|
16
16
|
const implementations = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
// Node implementation uses hrtime
|
|
18
|
+
node: {
|
|
19
|
+
name: "hrtime",
|
|
20
|
+
_startTime: 0,
|
|
21
|
+
_stopTime: undefined as any[] | undefined,
|
|
22
|
+
stop: () => {},
|
|
23
23
|
|
|
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
|
-
|
|
24
|
+
_start() {
|
|
25
|
+
this._startTime = process.hrtime();
|
|
26
|
+
},
|
|
27
|
+
_stop() {
|
|
28
|
+
this._stopTime = process.hrtime(this._startTime);
|
|
29
|
+
},
|
|
30
|
+
_elapsedSec(): number {
|
|
31
|
+
if (this._stopTime === undefined) {
|
|
32
|
+
this.stop();
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
35
|
+
return (this._stopTime![0] as number) + (this._stopTime![1] as number) / 1000000000;
|
|
36
|
+
},
|
|
37
|
+
_elapsedMilliSec(): number {
|
|
38
|
+
if (this._stopTime === undefined) {
|
|
39
|
+
this.stop();
|
|
40
|
+
}
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
42
|
+
return this._stopTime![0] * 1000 + this._stopTime![1] / 1000000;
|
|
43
|
+
},
|
|
44
|
+
_elapsedMicroSec(): number {
|
|
45
|
+
if (this._stopTime === undefined) {
|
|
46
|
+
this.stop();
|
|
47
|
+
}
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
|
+
return this._stopTime![0] * 1000000 + this._stopTime![1] / 1000;
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
// Browser implementation uses window.performance (if available):
|
|
53
|
+
performance: {
|
|
54
|
+
name: "window.performance",
|
|
55
|
+
_startTime: 0,
|
|
56
|
+
_stopTime: 0,
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
stop: () => {},
|
|
59
|
+
elapsedMilliSec: () => 0,
|
|
60
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
|
-
|
|
92
|
-
|
|
61
|
+
_start() {
|
|
62
|
+
this._startTime = window.performance.now();
|
|
63
|
+
},
|
|
64
|
+
_stop() {
|
|
65
|
+
this._stopTime = window.performance.now();
|
|
66
|
+
},
|
|
67
|
+
_elapsedSec(): number {
|
|
68
|
+
if (!this._stopTime) {
|
|
69
|
+
this.stop();
|
|
70
|
+
}
|
|
71
|
+
return this.elapsedMilliSec() / 1000;
|
|
72
|
+
},
|
|
73
|
+
_elapsedMilliSec(): number {
|
|
74
|
+
if (!this._stopTime) {
|
|
75
|
+
this.stop();
|
|
76
|
+
}
|
|
77
|
+
return this._stopTime - this._startTime;
|
|
78
|
+
},
|
|
79
|
+
_elapsedMicroSec(): number {
|
|
80
|
+
if (!this._stopTime) {
|
|
81
|
+
this.stop();
|
|
82
|
+
}
|
|
83
|
+
return this.elapsedMilliSec() * 1000;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
// Fallback is Date implementation if none of the above is supported:
|
|
87
|
+
date: {
|
|
88
|
+
name: "date",
|
|
89
|
+
_startTime: new Date(),
|
|
90
|
+
_stopTime: undefined as Date | undefined,
|
|
91
|
+
stop: () => {},
|
|
92
|
+
elapsedMilliSec: () => 0,
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
94
|
+
_start() {
|
|
95
|
+
this._startTime = new Date();
|
|
96
|
+
},
|
|
97
|
+
_stop() {
|
|
98
|
+
this._stopTime = new Date();
|
|
99
|
+
},
|
|
100
|
+
_elapsedSec(): number {
|
|
101
|
+
if (!this._stopTime) {
|
|
102
|
+
this.stop();
|
|
103
|
+
}
|
|
104
|
+
return this.elapsedMilliSec() / 1000;
|
|
105
|
+
},
|
|
106
|
+
_elapsedMilliSec(): number {
|
|
107
|
+
if (!this._stopTime) {
|
|
108
|
+
this.stop();
|
|
109
|
+
}
|
|
110
|
+
return (this._stopTime as Date).getTime() - this._startTime.getTime();
|
|
111
|
+
},
|
|
112
|
+
_elapsedMicroSec(): number {
|
|
113
|
+
if (!this._stopTime) {
|
|
114
|
+
this.stop();
|
|
115
|
+
}
|
|
116
|
+
return this.elapsedMilliSec() * 1000;
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
let impl:
|
|
121
|
+
let impl:
|
|
122
|
+
| typeof implementations.date
|
|
123
|
+
| typeof implementations.node
|
|
124
|
+
| typeof implementations.performance;
|
|
122
125
|
if (typeof process !== "undefined" && typeof process.hrtime !== "undefined") {
|
|
123
|
-
|
|
126
|
+
impl = implementations.node;
|
|
124
127
|
} else if (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
typeof window !== "undefined" &&
|
|
129
|
+
typeof window.performance !== "undefined" &&
|
|
130
|
+
typeof window.performance.now !== "undefined"
|
|
128
131
|
) {
|
|
129
|
-
|
|
132
|
+
impl = implementations.performance;
|
|
130
133
|
} else {
|
|
131
|
-
|
|
134
|
+
impl = implementations.date;
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
/**
|
|
135
138
|
* Creates and starts a new Chronometer.
|
|
136
139
|
*/
|
|
137
140
|
export class Chronometer {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
constructor() {
|
|
142
|
+
this.start();
|
|
143
|
+
}
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Sets the chronometer start time.
|
|
147
|
+
*/
|
|
148
|
+
start() {
|
|
149
|
+
return impl._start.call(this);
|
|
150
|
+
}
|
|
148
151
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Stops the chronometer. Stopped chronometers can be reused by calling {@link Chronometer.start} again.
|
|
154
|
+
*
|
|
155
|
+
* @returns The chronometer instance, so that callers can do this:
|
|
156
|
+
*
|
|
157
|
+
* ```javascript
|
|
158
|
+
* let elapsedMS = chrono.stop().elapsedMS();
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
stop(): Chronometer {
|
|
162
|
+
impl._stop.call(this);
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
162
165
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
166
|
+
/**
|
|
167
|
+
* @returns How many microseconds have elapsed between the last call to {@link Chronometer.start}
|
|
168
|
+
* (or the chronometer creation), and {@link Chronometer.stop}. Implementations that are not precise
|
|
169
|
+
* enough may return "elapsedMilliSec() * 1000". Measuring elapsed time causes the chronometer
|
|
170
|
+
* to be stopped if required (if the chrono is not stopped when this method is called).
|
|
171
|
+
*/
|
|
172
|
+
elapsedMicroSec(): number {
|
|
173
|
+
return impl._elapsedMicroSec.call(this);
|
|
174
|
+
}
|
|
172
175
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
176
|
+
/**
|
|
177
|
+
* @returns How many milliseconds have elapsed between the last call to {@link Chronometer.start}
|
|
178
|
+
* (or the chronometer creation), and {@link Chronometer.stop}. Measuring elapsed time causes the
|
|
179
|
+
* chronometer to be stopped if required (if the chrono is not stopped when this method is
|
|
180
|
+
* called).
|
|
181
|
+
*/
|
|
182
|
+
elapsedMilliSec(): number {
|
|
183
|
+
return impl._elapsedMilliSec.call(this);
|
|
184
|
+
}
|
|
182
185
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
/**
|
|
187
|
+
* @returns How many seconds have elapsed between the last call to {@link Chronometer.start}
|
|
188
|
+
* (or the chronometer creation), and {@link Chronometer.stop}. Measuring elapsed time causes the
|
|
189
|
+
* chronometer to be stopped if required (if the chrono is not stopped when this method is
|
|
190
|
+
* called).
|
|
191
|
+
*/
|
|
192
|
+
elapsedSec(): number {
|
|
193
|
+
return impl._elapsedSec.call(this);
|
|
194
|
+
}
|
|
192
195
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
/**
|
|
197
|
+
* A utility function to measure promise execution time.
|
|
198
|
+
* @param promiseFn - A function that returns a promise whose execution time is to be measured.
|
|
199
|
+
* @returns A Promise that resolves with an object with properties:
|
|
200
|
+
*
|
|
201
|
+
* - `chrono`: A stopped chronometer instance from which to get the elapsed time,
|
|
202
|
+
*
|
|
203
|
+
* - `result`: The resolved result of the promise returned by promiseFn
|
|
204
|
+
*/
|
|
205
|
+
static async timePromise<T>(
|
|
206
|
+
promiseFn: () => Promise<T>,
|
|
207
|
+
): Promise<{ chrono: Chronometer; result: T }> {
|
|
208
|
+
const chrono = new Chronometer();
|
|
209
|
+
const result = await promiseFn();
|
|
210
|
+
chrono.stop();
|
|
211
|
+
return { chrono, result };
|
|
212
|
+
}
|
|
208
213
|
}
|
package/src/consoleUtils.ts
CHANGED
|
@@ -6,15 +6,20 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Used to replace console.assert to make sure that it always throws an error, both in the browser and in Node
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
10
|
+
export class ConsoleUtils {
|
|
11
|
+
/**
|
|
12
|
+
* Throws an error if the in_condition is false
|
|
13
|
+
* @param in_condition - The condition we are testing: a boolean expression.
|
|
14
|
+
* @param in_message - The error message that will be thrown if the condition is false.
|
|
15
|
+
*/
|
|
16
|
+
static assert(condition: any, message: string | number): asserts condition {
|
|
17
|
+
if (!(condition as boolean)) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
typeof message === "number"
|
|
20
|
+
? `0x${message.toString(16).padStart(3, "0")}`
|
|
21
|
+
: message,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
20
25
|
}
|