@chevrotain/utils 10.5.0 → 11.0.1
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/lib/src/api.d.ts +3 -3
- package/lib/src/api.js +3 -10
- package/lib/src/print.js +4 -9
- package/lib/src/timer.js +5 -9
- package/lib/src/to-fast-properties.js +5 -8
- package/package.json +11 -7
- package/lib/src/api.js.map +0 -1
- package/lib/src/print.js.map +0 -1
- package/lib/src/timer.js.map +0 -1
- package/lib/src/to-fast-properties.js.map +0 -1
- package/src/api.ts +0 -3
- package/src/print.ts +0 -14
- package/src/timer.ts +0 -7
- package/src/to-fast-properties.ts +0 -26
package/lib/src/api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { PRINT_WARNING, PRINT_ERROR } from "./print";
|
|
2
|
-
export { timer } from "./timer";
|
|
3
|
-
export { toFastProperties } from "./to-fast-properties";
|
|
1
|
+
export { PRINT_WARNING, PRINT_ERROR } from "./print.js";
|
|
2
|
+
export { timer } from "./timer.js";
|
|
3
|
+
export { toFastProperties } from "./to-fast-properties.js";
|
package/lib/src/api.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var print_1 = require("./print");
|
|
5
|
-
Object.defineProperty(exports, "PRINT_WARNING", { enumerable: true, get: function () { return print_1.PRINT_WARNING; } });
|
|
6
|
-
Object.defineProperty(exports, "PRINT_ERROR", { enumerable: true, get: function () { return print_1.PRINT_ERROR; } });
|
|
7
|
-
var timer_1 = require("./timer");
|
|
8
|
-
Object.defineProperty(exports, "timer", { enumerable: true, get: function () { return timer_1.timer; } });
|
|
9
|
-
var to_fast_properties_1 = require("./to-fast-properties");
|
|
10
|
-
Object.defineProperty(exports, "toFastProperties", { enumerable: true, get: function () { return to_fast_properties_1.toFastProperties; } });
|
|
1
|
+
export { PRINT_WARNING, PRINT_ERROR } from "./print.js";
|
|
2
|
+
export { timer } from "./timer.js";
|
|
3
|
+
export { toFastProperties } from "./to-fast-properties.js";
|
|
11
4
|
//# sourceMappingURL=api.js.map
|
package/lib/src/print.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PRINT_WARNING = exports.PRINT_ERROR = void 0;
|
|
4
|
-
function PRINT_ERROR(msg) {
|
|
1
|
+
export function PRINT_ERROR(msg) {
|
|
5
2
|
/* istanbul ignore else - can't override global.console in node.js */
|
|
6
3
|
if (console && console.error) {
|
|
7
|
-
console.error(
|
|
4
|
+
console.error(`Error: ${msg}`);
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
function PRINT_WARNING(msg) {
|
|
7
|
+
export function PRINT_WARNING(msg) {
|
|
12
8
|
/* istanbul ignore else - can't override global.console in node.js*/
|
|
13
9
|
if (console && console.warn) {
|
|
14
10
|
// TODO: modify docs accordingly
|
|
15
|
-
console.warn(
|
|
11
|
+
console.warn(`Warning: ${msg}`);
|
|
16
12
|
}
|
|
17
13
|
}
|
|
18
|
-
exports.PRINT_WARNING = PRINT_WARNING;
|
|
19
14
|
//# sourceMappingURL=print.js.map
|
package/lib/src/timer.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var val = func();
|
|
7
|
-
var end = new Date().getTime();
|
|
8
|
-
var total = end - start;
|
|
1
|
+
export function timer(func) {
|
|
2
|
+
const start = new Date().getTime();
|
|
3
|
+
const val = func();
|
|
4
|
+
const end = new Date().getTime();
|
|
5
|
+
const total = end - start;
|
|
9
6
|
return { time: total, value: val };
|
|
10
7
|
}
|
|
11
|
-
exports.timer = timer;
|
|
12
8
|
//# sourceMappingURL=timer.js.map
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toFastProperties = void 0;
|
|
4
1
|
// based on: https://github.com/petkaantonov/bluebird/blob/b97c0d2d487e8c5076e8bd897e0dcd4622d31846/src/util.js#L201-L216
|
|
5
|
-
function toFastProperties(toBecomeFast) {
|
|
2
|
+
export function toFastProperties(toBecomeFast) {
|
|
6
3
|
function FakeConstructor() { }
|
|
7
|
-
// If our object is used as a constructor it would receive
|
|
4
|
+
// If our object is used as a constructor, it would receive
|
|
8
5
|
FakeConstructor.prototype = toBecomeFast;
|
|
9
|
-
|
|
6
|
+
const fakeInstance = new FakeConstructor();
|
|
10
7
|
function fakeAccess() {
|
|
11
8
|
return typeof fakeInstance.bar;
|
|
12
9
|
}
|
|
@@ -19,9 +16,9 @@ function toFastProperties(toBecomeFast) {
|
|
|
19
16
|
if (1)
|
|
20
17
|
return toBecomeFast;
|
|
21
18
|
// Eval prevents optimization of this method (even though this is dead code)
|
|
19
|
+
// - https://esbuild.github.io/content-types/#direct-eval
|
|
22
20
|
/* istanbul ignore next */
|
|
23
21
|
// tslint:disable-next-line
|
|
24
|
-
eval(toBecomeFast);
|
|
22
|
+
(0, eval)(toBecomeFast);
|
|
25
23
|
}
|
|
26
|
-
exports.toFastProperties = toFastProperties;
|
|
27
24
|
//# sourceMappingURL=to-fast-properties.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chevrotain/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "common utilities",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"bugs": {
|
|
@@ -10,13 +10,17 @@
|
|
|
10
10
|
"author": {
|
|
11
11
|
"name": "Shahar Soel"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"type": "module",
|
|
14
|
+
"types": "./lib/src/api.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./lib/src/api.js",
|
|
18
|
+
"types": "./lib/src/api.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
15
21
|
"files": [
|
|
16
|
-
"src/**/*.ts",
|
|
17
22
|
"lib/src/**/*.js",
|
|
18
23
|
"lib/src/**/*.d.ts",
|
|
19
|
-
"lib/src/**/*.js.map",
|
|
20
24
|
"README.md",
|
|
21
25
|
"LICENSE.TXT"
|
|
22
26
|
],
|
|
@@ -33,10 +37,10 @@
|
|
|
33
37
|
"clean": "shx rm -rf lib coverage",
|
|
34
38
|
"compile:watch": "tsc -w",
|
|
35
39
|
"compile": "tsc",
|
|
36
|
-
"coverage": "
|
|
40
|
+
"coverage": "c8 mocha --enable-source-maps"
|
|
37
41
|
},
|
|
38
42
|
"publishConfig": {
|
|
39
43
|
"access": "public"
|
|
40
44
|
},
|
|
41
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "12069a985026730a11a16a9b5d371c9ac9b96430"
|
|
42
46
|
}
|
package/lib/src/api.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;AAAA,iCAAoD;AAA3C,sGAAA,aAAa,OAAA;AAAE,oGAAA,WAAW,OAAA;AACnC,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,2DAAuD;AAA9C,sHAAA,gBAAgB,OAAA"}
|
package/lib/src/print.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"print.js","sourceRoot":"","sources":["../../src/print.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAAC,GAAW;IACrC,qEAAqE;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE;QAC5B,OAAO,CAAC,KAAK,CAAC,iBAAU,GAAG,CAAE,CAAC,CAAA;KAC/B;AACH,CAAC;AALD,kCAKC;AAED,SAAgB,aAAa,CAAC,GAAW;IACvC,oEAAoE;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE;QAC3B,gCAAgC;QAChC,OAAO,CAAC,IAAI,CAAC,mBAAY,GAAG,CAAE,CAAC,CAAA;KAChC;AACH,CAAC;AAND,sCAMC"}
|
package/lib/src/timer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timer.js","sourceRoot":"","sources":["../../src/timer.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAI,IAAa;IACpC,IAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAClC,IAAM,GAAG,GAAG,IAAI,EAAE,CAAA;IAClB,IAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;IAChC,IAAM,KAAK,GAAG,GAAG,GAAG,KAAK,CAAA;IACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;AACpC,CAAC;AAND,sBAMC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to-fast-properties.js","sourceRoot":"","sources":["../../src/to-fast-properties.ts"],"names":[],"mappings":";;;AAAA,yHAAyH;AACzH,SAAgB,gBAAgB,CAAC,YAAiB;IAChD,SAAS,eAAe,KAAI,CAAC;IAE7B,0DAA0D;IAC1D,eAAe,CAAC,SAAS,GAAG,YAAY,CAAA;IACxC,IAAM,YAAY,GAAG,IAAK,eAAuB,EAAE,CAAA;IAEnD,SAAS,UAAU;QACjB,OAAO,OAAO,YAAY,CAAC,GAAG,CAAA;IAChC,CAAC;IAED,kEAAkE;IAClE,qBAAqB;IACrB,UAAU,EAAE,CAAA;IACZ,UAAU,EAAE,CAAA;IAEZ,uEAAuE;IACvE,iCAAiC;IACjC,IAAI,CAAC;QAAE,OAAO,YAAY,CAAA;IAE1B,4EAA4E;IAC5E,0BAA0B;IAC1B,2BAA2B;IAC3B,IAAI,CAAC,YAAY,CAAC,CAAA;AACpB,CAAC;AAxBD,4CAwBC"}
|
package/src/api.ts
DELETED
package/src/print.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function PRINT_ERROR(msg: string) {
|
|
2
|
-
/* istanbul ignore else - can't override global.console in node.js */
|
|
3
|
-
if (console && console.error) {
|
|
4
|
-
console.error(`Error: ${msg}`)
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function PRINT_WARNING(msg: string) {
|
|
9
|
-
/* istanbul ignore else - can't override global.console in node.js*/
|
|
10
|
-
if (console && console.warn) {
|
|
11
|
-
// TODO: modify docs accordingly
|
|
12
|
-
console.warn(`Warning: ${msg}`)
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/timer.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// based on: https://github.com/petkaantonov/bluebird/blob/b97c0d2d487e8c5076e8bd897e0dcd4622d31846/src/util.js#L201-L216
|
|
2
|
-
export function toFastProperties(toBecomeFast: any) {
|
|
3
|
-
function FakeConstructor() {}
|
|
4
|
-
|
|
5
|
-
// If our object is used as a constructor it would receive
|
|
6
|
-
FakeConstructor.prototype = toBecomeFast
|
|
7
|
-
const fakeInstance = new (FakeConstructor as any)()
|
|
8
|
-
|
|
9
|
-
function fakeAccess() {
|
|
10
|
-
return typeof fakeInstance.bar
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// help V8 understand this is a "real" prototype by actually using
|
|
14
|
-
// the fake instance.
|
|
15
|
-
fakeAccess()
|
|
16
|
-
fakeAccess()
|
|
17
|
-
|
|
18
|
-
// Always true condition to suppress the Firefox warning of unreachable
|
|
19
|
-
// code after a return statement.
|
|
20
|
-
if (1) return toBecomeFast
|
|
21
|
-
|
|
22
|
-
// Eval prevents optimization of this method (even though this is dead code)
|
|
23
|
-
/* istanbul ignore next */
|
|
24
|
-
// tslint:disable-next-line
|
|
25
|
-
eval(toBecomeFast)
|
|
26
|
-
}
|