@augment-vir/common 14.4.0 → 15.0.0
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/cjs/augments/pixel.js +16 -0
- package/dist/cjs/augments/time.js +35 -0
- package/dist/cjs/index.js +2 -2
- package/dist/esm/augments/pixel.js +11 -0
- package/dist/esm/augments/time.js +31 -0
- package/dist/esm/index.js +2 -2
- package/dist/types/augments/pixel.d.ts +3 -0
- package/dist/types/augments/time.d.ts +14 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removePx = exports.addPx = void 0;
|
|
4
|
+
function addPx(input) {
|
|
5
|
+
if (String(input).endsWith('px')) {
|
|
6
|
+
return String(input);
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
return `${input}px`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.addPx = addPx;
|
|
13
|
+
function removePx(input) {
|
|
14
|
+
return Number(input.replace(/px$/, ''));
|
|
15
|
+
}
|
|
16
|
+
exports.removePx = removePx;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.measureCallbackDuration = exports.timeCallback = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
6
|
+
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
7
|
+
* purely synchronous).
|
|
8
|
+
*/
|
|
9
|
+
function timeCallback(callback) {
|
|
10
|
+
const startTime = Date.now();
|
|
11
|
+
const result = callback();
|
|
12
|
+
if (result instanceof Promise) {
|
|
13
|
+
return new Promise(async (resolve, reject) => {
|
|
14
|
+
try {
|
|
15
|
+
await result;
|
|
16
|
+
const endTime = Date.now();
|
|
17
|
+
resolve(endTime - startTime);
|
|
18
|
+
}
|
|
19
|
+
catch (caught) {
|
|
20
|
+
reject(caught);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const endTime = Date.now();
|
|
25
|
+
return (endTime - startTime);
|
|
26
|
+
}
|
|
27
|
+
exports.timeCallback = timeCallback;
|
|
28
|
+
/**
|
|
29
|
+
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
30
|
+
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
31
|
+
* purely synchronous).
|
|
32
|
+
*
|
|
33
|
+
* Alias of timeCallback.
|
|
34
|
+
*/
|
|
35
|
+
exports.measureCallbackDuration = timeCallback;
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,8 +19,6 @@ __exportStar(require("./augments/array"), exports);
|
|
|
19
19
|
__exportStar(require("./augments/async"), exports);
|
|
20
20
|
__exportStar(require("./augments/common-number"), exports);
|
|
21
21
|
__exportStar(require("./augments/common-string"), exports);
|
|
22
|
-
__exportStar(require("./augments/date/date"), exports);
|
|
23
|
-
__exportStar(require("./augments/date/relative-date"), exports);
|
|
24
22
|
__exportStar(require("./augments/environment"), exports);
|
|
25
23
|
__exportStar(require("./augments/error"), exports);
|
|
26
24
|
__exportStar(require("./augments/function"), exports);
|
|
@@ -38,11 +36,13 @@ __exportStar(require("./augments/object/object"), exports);
|
|
|
38
36
|
__exportStar(require("./augments/object/object-entries"), exports);
|
|
39
37
|
__exportStar(require("./augments/object/pick-deep"), exports);
|
|
40
38
|
__exportStar(require("./augments/object/typed-has-property"), exports);
|
|
39
|
+
__exportStar(require("./augments/pixel"), exports);
|
|
41
40
|
__exportStar(require("./augments/promise"), exports);
|
|
42
41
|
__exportStar(require("./augments/regexp"), exports);
|
|
43
42
|
__exportStar(require("./augments/runtime-type-of"), exports);
|
|
44
43
|
__exportStar(require("./augments/string/url"), exports);
|
|
45
44
|
__exportStar(require("./augments/string/uuid"), exports);
|
|
45
|
+
__exportStar(require("./augments/time"), exports);
|
|
46
46
|
__exportStar(require("./augments/truncate-number"), exports);
|
|
47
47
|
__exportStar(require("./augments/tuple"), exports);
|
|
48
48
|
__exportStar(require("./augments/type"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
3
|
+
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
4
|
+
* purely synchronous).
|
|
5
|
+
*/
|
|
6
|
+
export function timeCallback(callback) {
|
|
7
|
+
const startTime = Date.now();
|
|
8
|
+
const result = callback();
|
|
9
|
+
if (result instanceof Promise) {
|
|
10
|
+
return new Promise(async (resolve, reject) => {
|
|
11
|
+
try {
|
|
12
|
+
await result;
|
|
13
|
+
const endTime = Date.now();
|
|
14
|
+
resolve(endTime - startTime);
|
|
15
|
+
}
|
|
16
|
+
catch (caught) {
|
|
17
|
+
reject(caught);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const endTime = Date.now();
|
|
22
|
+
return (endTime - startTime);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
26
|
+
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
27
|
+
* purely synchronous).
|
|
28
|
+
*
|
|
29
|
+
* Alias of timeCallback.
|
|
30
|
+
*/
|
|
31
|
+
export const measureCallbackDuration = timeCallback;
|
package/dist/esm/index.js
CHANGED
|
@@ -3,8 +3,6 @@ export * from './augments/array';
|
|
|
3
3
|
export * from './augments/async';
|
|
4
4
|
export * from './augments/common-number';
|
|
5
5
|
export * from './augments/common-string';
|
|
6
|
-
export * from './augments/date/date';
|
|
7
|
-
export * from './augments/date/relative-date';
|
|
8
6
|
export * from './augments/environment';
|
|
9
7
|
export * from './augments/error';
|
|
10
8
|
export * from './augments/function';
|
|
@@ -22,11 +20,13 @@ export * from './augments/object/object';
|
|
|
22
20
|
export * from './augments/object/object-entries';
|
|
23
21
|
export * from './augments/object/pick-deep';
|
|
24
22
|
export * from './augments/object/typed-has-property';
|
|
23
|
+
export * from './augments/pixel';
|
|
25
24
|
export * from './augments/promise';
|
|
26
25
|
export * from './augments/regexp';
|
|
27
26
|
export * from './augments/runtime-type-of';
|
|
28
27
|
export * from './augments/string/url';
|
|
29
28
|
export * from './augments/string/uuid';
|
|
29
|
+
export * from './augments/time';
|
|
30
30
|
export * from './augments/truncate-number';
|
|
31
31
|
export * from './augments/tuple';
|
|
32
32
|
export * from './augments/type';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
3
|
+
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
4
|
+
* purely synchronous).
|
|
5
|
+
*/
|
|
6
|
+
export declare function timeCallback<T>(callback: () => T): T extends Promise<any> ? Promise<number> : number;
|
|
7
|
+
/**
|
|
8
|
+
* Measures how long (in milliseconds) the given callback takes to run to completion. Automatically
|
|
9
|
+
* switches to async mode and awaits callbacks if they return a promise (otherwise this function is
|
|
10
|
+
* purely synchronous).
|
|
11
|
+
*
|
|
12
|
+
* Alias of timeCallback.
|
|
13
|
+
*/
|
|
14
|
+
export declare const measureCallbackDuration: typeof timeCallback;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export * from './augments/array';
|
|
|
3
3
|
export * from './augments/async';
|
|
4
4
|
export * from './augments/common-number';
|
|
5
5
|
export * from './augments/common-string';
|
|
6
|
-
export * from './augments/date/date';
|
|
7
|
-
export * from './augments/date/relative-date';
|
|
8
6
|
export * from './augments/environment';
|
|
9
7
|
export * from './augments/error';
|
|
10
8
|
export * from './augments/function';
|
|
@@ -22,11 +20,13 @@ export * from './augments/object/object';
|
|
|
22
20
|
export * from './augments/object/object-entries';
|
|
23
21
|
export * from './augments/object/pick-deep';
|
|
24
22
|
export * from './augments/object/typed-has-property';
|
|
23
|
+
export * from './augments/pixel';
|
|
25
24
|
export * from './augments/promise';
|
|
26
25
|
export * from './augments/regexp';
|
|
27
26
|
export * from './augments/runtime-type-of';
|
|
28
27
|
export * from './augments/string/url';
|
|
29
28
|
export * from './augments/string/uuid';
|
|
29
|
+
export * from './augments/time';
|
|
30
30
|
export * from './augments/truncate-number';
|
|
31
31
|
export * from './augments/tuple';
|
|
32
32
|
export * from './augments/type';
|