@fluid-experimental/property-common 0.49.0 → 0.50.0-41540
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/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +4 -0
- package/dist/constants.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/chronometer.d.ts +55 -0
- package/lib/chronometer.d.ts.map +1 -0
- package/lib/chronometer.js +185 -0
- package/lib/chronometer.js.map +1 -0
- package/lib/consoleUtils.d.ts +16 -0
- package/lib/consoleUtils.d.ts.map +1 -0
- package/lib/consoleUtils.js +20 -0
- package/lib/consoleUtils.js.map +1 -0
- package/lib/constants.d.ts +1219 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +1274 -0
- package/lib/constants.js.map +1 -0
- package/lib/datastructures/collection.d.ts +203 -0
- package/lib/datastructures/collection.d.ts.map +1 -0
- package/lib/datastructures/collection.js +377 -0
- package/lib/datastructures/collection.js.map +1 -0
- package/lib/datastructures/dataArray.d.ts +275 -0
- package/lib/datastructures/dataArray.d.ts.map +1 -0
- package/lib/datastructures/dataArray.js +497 -0
- package/lib/datastructures/dataArray.js.map +1 -0
- package/lib/datastructures/index.d.ts +9 -0
- package/lib/datastructures/index.d.ts.map +1 -0
- package/lib/datastructures/index.js +9 -0
- package/lib/datastructures/index.js.map +1 -0
- package/lib/datastructures/integer64.d.ts +47 -0
- package/lib/datastructures/integer64.d.ts.map +1 -0
- package/lib/datastructures/integer64.js +140 -0
- package/lib/datastructures/integer64.js.map +1 -0
- package/lib/datastructures/sortedCollection.d.ts +77 -0
- package/lib/datastructures/sortedCollection.d.ts.map +1 -0
- package/lib/datastructures/sortedCollection.js +140 -0
- package/lib/datastructures/sortedCollection.js.map +1 -0
- package/lib/deferredPromise.d.ts +28 -0
- package/lib/deferredPromise.d.ts.map +1 -0
- package/lib/deferredPromise.js +43 -0
- package/lib/deferredPromise.js.map +1 -0
- package/lib/deterministicRandomGenerator.d.ts +39 -0
- package/lib/deterministicRandomGenerator.d.ts.map +1 -0
- package/lib/deterministicRandomGenerator.js +83 -0
- package/lib/deterministicRandomGenerator.js.map +1 -0
- package/lib/error_objects/flaggedError.d.ts +29 -0
- package/lib/error_objects/flaggedError.d.ts.map +1 -0
- package/lib/error_objects/flaggedError.js +45 -0
- package/lib/error_objects/flaggedError.js.map +1 -0
- package/lib/error_objects/httpError.d.ts +31 -0
- package/lib/error_objects/httpError.d.ts.map +1 -0
- package/lib/error_objects/httpError.js +58 -0
- package/lib/error_objects/httpError.js.map +1 -0
- package/lib/error_objects/httpErrorNoStack.d.ts +25 -0
- package/lib/error_objects/httpErrorNoStack.d.ts.map +1 -0
- package/lib/error_objects/httpErrorNoStack.js +29 -0
- package/lib/error_objects/httpErrorNoStack.js.map +1 -0
- package/lib/error_objects/index.d.ts +9 -0
- package/lib/error_objects/index.d.ts.map +1 -0
- package/lib/error_objects/index.js +9 -0
- package/lib/error_objects/index.js.map +1 -0
- package/lib/error_objects/operationError.d.ts +32 -0
- package/lib/error_objects/operationError.d.ts.map +1 -0
- package/lib/error_objects/operationError.js +73 -0
- package/lib/error_objects/operationError.js.map +1 -0
- package/lib/guidUtils.d.ts +16 -0
- package/lib/guidUtils.d.ts.map +1 -0
- package/lib/guidUtils.js +297 -0
- package/lib/guidUtils.js.map +1 -0
- package/lib/hashCalculator.d.ts +6 -0
- package/lib/hashCalculator.d.ts.map +1 -0
- package/lib/hashCalculator.js +14 -0
- package/lib/hashCalculator.js.map +1 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -0
- package/lib/index.js.map +1 -0
- package/lib/joinPaths.d.ts +19 -0
- package/lib/joinPaths.d.ts.map +1 -0
- package/lib/joinPaths.js +28 -0
- package/lib/joinPaths.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/package.json +22 -2
- package/platform-dependent/package.json +1 -1
- package/src/constants.ts +5 -0
- package/src/packageVersion.ts +1 -1
- package/dist/test/chronometer.spec.js +0 -90
- package/dist/test/chronometer.spec.js.map +0 -1
- package/dist/test/datastructures/collection.spec.js +0 -401
- package/dist/test/datastructures/collection.spec.js.map +0 -1
- package/dist/test/datastructures/dataArray.spec.js +0 -79
- package/dist/test/datastructures/dataArray.spec.js.map +0 -1
- package/dist/test/datastructures/sortedCollection.spec.js +0 -106
- package/dist/test/datastructures/sortedCollection.spec.js.map +0 -1
- package/dist/test/deterministicRandomGenerator.spec.js +0 -18
- package/dist/test/deterministicRandomGenerator.spec.js.map +0 -1
- package/dist/test/error_objects/flaggedError.spec.js +0 -23
- package/dist/test/error_objects/flaggedError.spec.js.map +0 -1
- package/dist/test/error_objects/httpError.spec.js +0 -61
- package/dist/test/error_objects/httpError.spec.js.map +0 -1
- package/dist/test/error_objects/httpErrorNoStack.spec.js +0 -55
- package/dist/test/error_objects/httpErrorNoStack.spec.js.map +0 -1
- package/dist/test/error_objects/operationError.spec.js +0 -132
- package/dist/test/error_objects/operationError.spec.js.map +0 -1
- package/dist/test/guidUtils.spec.js +0 -184
- package/dist/test/guidUtils.spec.js.map +0 -1
- package/dist/test/strings/joinPaths.spec.js +0 -18
- package/dist/test/strings/joinPaths.spec.js.map +0 -1
- package/dist/test/tsconfig.tsbuildinfo +0 -2278
- package/nyc/mocha-junit-report.xml +0 -175
- package/src/test/chronometer.spec.ts +0 -99
- package/src/test/datastructures/collection.spec.ts +0 -567
- package/src/test/datastructures/dataArray.spec.ts +0 -81
- package/src/test/datastructures/sortedCollection.spec.ts +0 -128
- package/src/test/deterministicRandomGenerator.spec.ts +0 -18
- package/src/test/error_objects/flaggedError.spec.ts +0 -22
- package/src/test/error_objects/httpError.spec.ts +0 -68
- package/src/test/error_objects/httpErrorNoStack.spec.ts +0 -64
- package/src/test/error_objects/operationError.spec.ts +0 -152
- package/src/test/guidUtils.spec.ts +0 -213
- package/src/test/strings/joinPaths.spec.ts +0 -17
- package/src/test/tsconfig.json +0 -21
- package/tsconfig.esnext.tsbuildinfo +0 -824
- package/tsconfig.tsbuildinfo +0 -823
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* All the chronometer implementations (hrtime, window.performance, and date:
|
|
7
|
+
*/
|
|
8
|
+
const implementations = {
|
|
9
|
+
// Node implementation uses hrtime
|
|
10
|
+
node: {
|
|
11
|
+
name: "hrtime",
|
|
12
|
+
_startTime: 0,
|
|
13
|
+
_stopTime: undefined,
|
|
14
|
+
stop: () => { },
|
|
15
|
+
_start() {
|
|
16
|
+
this._startTime = process.hrtime();
|
|
17
|
+
},
|
|
18
|
+
_stop() {
|
|
19
|
+
this._stopTime = process.hrtime(this._startTime);
|
|
20
|
+
},
|
|
21
|
+
_elapsedSec() {
|
|
22
|
+
if (this._stopTime === undefined) {
|
|
23
|
+
this.stop();
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
26
|
+
return this._stopTime[0] + this._stopTime[1] / 1000000000;
|
|
27
|
+
},
|
|
28
|
+
_elapsedMilliSec() {
|
|
29
|
+
if (this._stopTime === undefined) {
|
|
30
|
+
this.stop();
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
33
|
+
return this._stopTime[0] * 1000 + this._stopTime[1] / 1000000;
|
|
34
|
+
},
|
|
35
|
+
_elapsedMicroSec() {
|
|
36
|
+
if (this._stopTime === undefined) {
|
|
37
|
+
this.stop();
|
|
38
|
+
}
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
40
|
+
return this._stopTime[0] * 1000000 + this._stopTime[1] / 1000;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
// Browser implementation uses window.performance (if available):
|
|
44
|
+
performance: {
|
|
45
|
+
name: "window.performance",
|
|
46
|
+
_startTime: 0,
|
|
47
|
+
_stopTime: 0,
|
|
48
|
+
stop: () => { },
|
|
49
|
+
elapsedMilliSec: () => 0,
|
|
50
|
+
_start() {
|
|
51
|
+
this._startTime = window.performance.now();
|
|
52
|
+
},
|
|
53
|
+
_stop() {
|
|
54
|
+
this._stopTime = window.performance.now();
|
|
55
|
+
},
|
|
56
|
+
_elapsedSec() {
|
|
57
|
+
if (!this._stopTime) {
|
|
58
|
+
this.stop();
|
|
59
|
+
}
|
|
60
|
+
return this.elapsedMilliSec() / 1000;
|
|
61
|
+
},
|
|
62
|
+
_elapsedMilliSec() {
|
|
63
|
+
if (!this._stopTime) {
|
|
64
|
+
this.stop();
|
|
65
|
+
}
|
|
66
|
+
return this._stopTime - this._startTime;
|
|
67
|
+
},
|
|
68
|
+
_elapsedMicroSec() {
|
|
69
|
+
if (!this._stopTime) {
|
|
70
|
+
this.stop();
|
|
71
|
+
}
|
|
72
|
+
return this.elapsedMilliSec() * 1000;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
// Fallback is Date implementation if none of the above is supported:
|
|
76
|
+
date: {
|
|
77
|
+
name: "date",
|
|
78
|
+
_startTime: new Date(),
|
|
79
|
+
_stopTime: undefined,
|
|
80
|
+
stop: () => { },
|
|
81
|
+
elapsedMilliSec: () => 0,
|
|
82
|
+
_start() {
|
|
83
|
+
this._startTime = new Date();
|
|
84
|
+
},
|
|
85
|
+
_stop() {
|
|
86
|
+
this._stopTime = new Date();
|
|
87
|
+
},
|
|
88
|
+
_elapsedSec() {
|
|
89
|
+
if (!this._stopTime) {
|
|
90
|
+
this.stop();
|
|
91
|
+
}
|
|
92
|
+
return this.elapsedMilliSec() / 1000;
|
|
93
|
+
},
|
|
94
|
+
_elapsedMilliSec() {
|
|
95
|
+
if (!this._stopTime) {
|
|
96
|
+
this.stop();
|
|
97
|
+
}
|
|
98
|
+
return this._stopTime.getTime() - this._startTime.getTime();
|
|
99
|
+
},
|
|
100
|
+
_elapsedMicroSec() {
|
|
101
|
+
if (!this._stopTime) {
|
|
102
|
+
this.stop();
|
|
103
|
+
}
|
|
104
|
+
return this.elapsedMilliSec() * 1000;
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
let impl;
|
|
109
|
+
if (typeof process !== "undefined" && typeof process.hrtime !== "undefined") {
|
|
110
|
+
impl = implementations.node;
|
|
111
|
+
}
|
|
112
|
+
else if (typeof window !== "undefined" &&
|
|
113
|
+
typeof window.performance !== "undefined" &&
|
|
114
|
+
typeof window.performance.now !== "undefined") {
|
|
115
|
+
impl = implementations.performance;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
impl = implementations.date;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Creates and starts a new Chronometer.
|
|
122
|
+
*/
|
|
123
|
+
export class Chronometer {
|
|
124
|
+
constructor() {
|
|
125
|
+
this.start();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sets the chronometer start time.
|
|
129
|
+
*/
|
|
130
|
+
start() {
|
|
131
|
+
return impl._start.call(this);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Stops the chronometer. Stopped chronometers can be reused by calling {@link Chronometer.start} again.
|
|
135
|
+
*
|
|
136
|
+
* @returns The chronometer instance, so that callers can do this:
|
|
137
|
+
* let elapsedMS = chrono.stop().elapsedMS();
|
|
138
|
+
*/
|
|
139
|
+
stop() {
|
|
140
|
+
impl._stop.call(this);
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* @returns How many microseconds have elapsed between the last call to {@link Chronometer.start}
|
|
145
|
+
* (or the chronometer creation), and {@link Chronometer.stop}. Implementations that are not precise
|
|
146
|
+
* enough may return "elapsedMilliSec() * 1000". Measuring elapsed time causes the chronometer
|
|
147
|
+
* to be stopped if required (if the chrono is not stopped when this method is called).
|
|
148
|
+
*/
|
|
149
|
+
elapsedMicroSec() {
|
|
150
|
+
return impl._elapsedMicroSec.call(this);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @returns How many milliseconds have elapsed between the last call to {@link Chronometer.start}
|
|
154
|
+
* (or the chronometer creation), and {@link Chronometer.stop}. Measuring elapsed time causes the
|
|
155
|
+
* chronometer to be stopped if required (if the chrono is not stopped when this method is
|
|
156
|
+
* called).
|
|
157
|
+
*/
|
|
158
|
+
elapsedMilliSec() {
|
|
159
|
+
return impl._elapsedMilliSec.call(this);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @returns How many seconds have elapsed between the last call to {@link Chronometer.start}
|
|
163
|
+
* (or the chronometer creation), and {@link Chronometer.stop}. Measuring elapsed time causes the
|
|
164
|
+
* chronometer to be stopped if required (if the chrono is not stopped when this method is
|
|
165
|
+
* called).
|
|
166
|
+
*/
|
|
167
|
+
elapsedSec() {
|
|
168
|
+
return impl._elapsedSec.call(this);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A utility function to measure promise execution time.
|
|
172
|
+
* @param promiseFn - A function that returns a promise whose execution time is to be
|
|
173
|
+
* measured.
|
|
174
|
+
* @returns A Promise that resolves with an object with properties:
|
|
175
|
+
* - chrono A stopped chronometer instance from which to get the elapsed time,
|
|
176
|
+
* - result The resolved result of the promise returned by promiseFn
|
|
177
|
+
*/
|
|
178
|
+
static async timePromise(promiseFn) {
|
|
179
|
+
const chrono = new Chronometer();
|
|
180
|
+
const result = await promiseFn();
|
|
181
|
+
chrono.stop();
|
|
182
|
+
return { chrono, result };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=chronometer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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ACH,eAAe;QACX,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,eAAe;QACX,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,UAAU;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,KAAK,CAAC,WAAW,CAAI,SAA2B;QACnD,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * @fileoverview A chronometer implementation backed by a high resolution timer. Implementation\n * falls back to milliseconds precision when high resolution timers are not supported.\n */\n\ndeclare let process: any;\n\n/**\n * All the chronometer implementations (hrtime, window.performance, and date:\n */\nconst implementations = {\n // Node implementation uses hrtime\n node: {\n name: \"hrtime\",\n _startTime: 0,\n _stopTime: undefined as any[] | undefined,\n stop: () => { },\n\n _start() {\n this._startTime = process.hrtime();\n },\n _stop() {\n this._stopTime = process.hrtime(this._startTime);\n },\n _elapsedSec(): number {\n if (this._stopTime === undefined) {\n this.stop();\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return (this._stopTime![0] as number) + (this._stopTime![1] as number) / 1000000000;\n },\n _elapsedMilliSec(): number {\n if (this._stopTime === undefined) {\n this.stop();\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._stopTime![0] * 1000 + this._stopTime![1] / 1000000;\n },\n _elapsedMicroSec(): number {\n if (this._stopTime === undefined) {\n this.stop();\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._stopTime![0] * 1000000 + this._stopTime![1] / 1000;\n },\n },\n // Browser implementation uses window.performance (if available):\n performance: {\n name: \"window.performance\",\n _startTime: 0,\n _stopTime: 0,\n\n stop: () => { },\n elapsedMilliSec: () => 0,\n\n _start() {\n this._startTime = window.performance.now();\n },\n _stop() {\n this._stopTime = window.performance.now();\n },\n _elapsedSec(): number {\n if (!this._stopTime) {\n this.stop();\n }\n return this.elapsedMilliSec() / 1000;\n },\n _elapsedMilliSec(): number {\n if (!this._stopTime) {\n this.stop();\n }\n return this._stopTime - this._startTime;\n },\n _elapsedMicroSec(): number {\n if (!this._stopTime) {\n this.stop();\n }\n return this.elapsedMilliSec() * 1000;\n },\n },\n // Fallback is Date implementation if none of the above is supported:\n date: {\n name: \"date\",\n _startTime: new Date(),\n _stopTime: undefined as Date | undefined,\n stop: () => { },\n elapsedMilliSec: () => 0,\n\n _start() {\n this._startTime = new Date();\n },\n _stop() {\n this._stopTime = new Date();\n },\n _elapsedSec(): number {\n if (!this._stopTime) {\n this.stop();\n }\n return this.elapsedMilliSec() / 1000;\n },\n _elapsedMilliSec(): number {\n if (!this._stopTime) {\n this.stop();\n }\n return (this._stopTime as Date).getTime() - this._startTime.getTime();\n },\n _elapsedMicroSec(): number {\n if (!this._stopTime) {\n this.stop();\n }\n return this.elapsedMilliSec() * 1000;\n },\n },\n};\n\nlet impl: typeof implementations.date | typeof implementations.node | typeof implementations.performance;\nif (typeof process !== \"undefined\" && typeof process.hrtime !== \"undefined\") {\n impl = implementations.node;\n} else if (\n typeof window !== \"undefined\" &&\n typeof window.performance !== \"undefined\" &&\n typeof window.performance.now !== \"undefined\"\n) {\n impl = implementations.performance;\n} else {\n impl = implementations.date;\n}\n\n/**\n * Creates and starts a new Chronometer.\n */\n\nexport class Chronometer {\n constructor() {\n this.start();\n }\n\n /**\n * Sets the chronometer start time.\n */\n start() {\n return impl._start.call(this);\n }\n\n /**\n * Stops the chronometer. Stopped chronometers can be reused by calling {@link Chronometer.start} again.\n *\n * @returns The chronometer instance, so that callers can do this:\n * let elapsedMS = chrono.stop().elapsedMS();\n */\n stop(): Chronometer {\n impl._stop.call(this);\n return this;\n }\n\n /**\n * @returns How many microseconds have elapsed between the last call to {@link Chronometer.start}\n * (or the chronometer creation), and {@link Chronometer.stop}. Implementations that are not precise\n * enough may return \"elapsedMilliSec() * 1000\". Measuring elapsed time causes the chronometer\n * to be stopped if required (if the chrono is not stopped when this method is called).\n */\n elapsedMicroSec(): number {\n return impl._elapsedMicroSec.call(this);\n }\n\n /**\n * @returns How many milliseconds have elapsed between the last call to {@link Chronometer.start}\n * (or the chronometer creation), and {@link Chronometer.stop}. Measuring elapsed time causes the\n * chronometer to be stopped if required (if the chrono is not stopped when this method is\n * called).\n */\n elapsedMilliSec(): number {\n return impl._elapsedMilliSec.call(this);\n }\n\n /**\n * @returns How many seconds have elapsed between the last call to {@link Chronometer.start}\n * (or the chronometer creation), and {@link Chronometer.stop}. Measuring elapsed time causes the\n * chronometer to be stopped if required (if the chrono is not stopped when this method is\n * called).\n */\n elapsedSec(): number {\n return impl._elapsedSec.call(this);\n }\n\n /**\n * A utility function to measure promise execution time.\n * @param promiseFn - A function that returns a promise whose execution time is to be\n * measured.\n * @returns A Promise that resolves with an object with properties:\n * - chrono A stopped chronometer instance from which to get the elapsed time,\n * - result The resolved result of the promise returned by promiseFn\n */\n static async timePromise<T>(promiseFn: () => Promise<T>): Promise<{ chrono: Chronometer, result: T }> {\n const chrono = new Chronometer();\n const result = await promiseFn();\n chrono.stop();\n return { chrono, result };\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Used to replace console.assert to make sure that it always throws an error, both in the browser and in Node
|
|
7
|
+
*/
|
|
8
|
+
export declare class ConsoleUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Throws an error if the in_condition is false
|
|
11
|
+
* @param in_condition - the condition we are testing: a boolean expression.
|
|
12
|
+
* @param in_message - the error message that will be thrown if the condition is false.
|
|
13
|
+
*/
|
|
14
|
+
static assert(condition: any, message: string | number): asserts condition;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=consoleUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleUtils.d.ts","sourceRoot":"","sources":["../src/consoleUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,YAAY;IACrB;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,SAAS;CAK7E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Used to replace console.assert to make sure that it always throws an error, both in the browser and in Node
|
|
7
|
+
*/
|
|
8
|
+
export class ConsoleUtils {
|
|
9
|
+
/**
|
|
10
|
+
* Throws an error if the in_condition is false
|
|
11
|
+
* @param in_condition - the condition we are testing: a boolean expression.
|
|
12
|
+
* @param in_message - the error message that will be thrown if the condition is false.
|
|
13
|
+
*/
|
|
14
|
+
static assert(condition, message) {
|
|
15
|
+
if (!condition) {
|
|
16
|
+
throw new Error(typeof message === "number" ? `0x${message.toString(16).padStart(3, "0")}` : message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=consoleUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleUtils.js","sourceRoot":"","sources":["../src/consoleUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,OAAO,YAAY;IACrB;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,SAAc,EAAE,OAAwB;QAClD,IAAI,CAAE,SAAqB,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACzG;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Used to replace console.assert to make sure that it always throws an error, both in the browser and in Node\n */\nexport class ConsoleUtils { // eslint-disable-line @typescript-eslint/no-extraneous-class\n /**\n * Throws an error if the in_condition is false\n * @param in_condition - the condition we are testing: a boolean expression.\n * @param in_message - the error message that will be thrown if the condition is false.\n */\n static assert(condition: any, message: string | number): asserts condition {\n if (!(condition as boolean)) {\n throw new Error(typeof message === \"number\" ? `0x${message.toString(16).padStart(3, \"0\")}` : message);\n }\n }\n}\n"]}
|