@telperion/js-utils 3.5.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/LICENSE +21 -0
- package/README.md +621 -0
- package/array/arrayize.cjs +22 -0
- package/array/arrayize.d.ts +17 -0
- package/array/arrayize.js +21 -0
- package/array/arrayize.js.map +1 -0
- package/array/async-map.cjs +40 -0
- package/array/async-map.d.ts +34 -0
- package/array/async-map.js +39 -0
- package/array/async-map.js.map +1 -0
- package/array/compact.cjs +34 -0
- package/array/compact.d.ts +28 -0
- package/array/compact.js +33 -0
- package/array/compact.js.map +1 -0
- package/array/difference.cjs +16 -0
- package/array/difference.d.ts +45 -0
- package/array/difference.js +15 -0
- package/array/difference.js.map +1 -0
- package/array/find-by-key.cjs +35 -0
- package/array/find-by-key.d.ts +30 -0
- package/array/find-by-key.js +34 -0
- package/array/find-by-key.js.map +1 -0
- package/array/index.cjs +14 -0
- package/array/index.d.ts +11 -0
- package/array/index.js +13 -0
- package/array/index.js.map +1 -0
- package/array/intersection.cjs +16 -0
- package/array/intersection.d.ts +45 -0
- package/array/intersection.js +15 -0
- package/array/intersection.js.map +1 -0
- package/array/limit.cjs +37 -0
- package/array/limit.d.ts +29 -0
- package/array/limit.js +36 -0
- package/array/limit.js.map +1 -0
- package/array/proto/async-map.cjs +6 -0
- package/array/proto/async-map.d.ts +25 -0
- package/array/proto/async-map.js +6 -0
- package/array/proto/async-map.js.map +1 -0
- package/array/proto/compact.cjs +6 -0
- package/array/proto/compact.d.ts +15 -0
- package/array/proto/compact.js +6 -0
- package/array/proto/compact.js.map +1 -0
- package/array/proto/difference.cjs +6 -0
- package/array/proto/difference.d.ts +27 -0
- package/array/proto/difference.js +6 -0
- package/array/proto/difference.js.map +1 -0
- package/array/proto/find-by-key.cjs +6 -0
- package/array/proto/find-by-key.d.ts +25 -0
- package/array/proto/find-by-key.js +6 -0
- package/array/proto/find-by-key.js.map +1 -0
- package/array/proto/intersection.cjs +6 -0
- package/array/proto/intersection.d.ts +27 -0
- package/array/proto/intersection.js +6 -0
- package/array/proto/intersection.js.map +1 -0
- package/array/proto/limit.cjs +6 -0
- package/array/proto/limit.d.ts +24 -0
- package/array/proto/limit.js +6 -0
- package/array/proto/limit.js.map +1 -0
- package/array/proto/remove.cjs +6 -0
- package/array/proto/remove.d.ts +32 -0
- package/array/proto/remove.js +6 -0
- package/array/proto/remove.js.map +1 -0
- package/array/proto/replace.cjs +6 -0
- package/array/proto/replace.d.ts +72 -0
- package/array/proto/replace.js +6 -0
- package/array/proto/replace.js.map +1 -0
- package/array/proto/uniquify-by-key.cjs +6 -0
- package/array/proto/uniquify-by-key.d.ts +24 -0
- package/array/proto/uniquify-by-key.js +6 -0
- package/array/proto/uniquify-by-key.js.map +1 -0
- package/array/proto/uniquify.cjs +6 -0
- package/array/proto/uniquify.d.ts +23 -0
- package/array/proto/uniquify.js +6 -0
- package/array/proto/uniquify.js.map +1 -0
- package/array/remove.cjs +46 -0
- package/array/remove.d.ts +33 -0
- package/array/remove.js +45 -0
- package/array/remove.js.map +1 -0
- package/array/replace.cjs +69 -0
- package/array/replace.d.ts +139 -0
- package/array/replace.js +68 -0
- package/array/replace.js.map +1 -0
- package/array/static/arrayize.cjs +4 -0
- package/array/static/arrayize.d.ts +6 -0
- package/array/static/arrayize.js +4 -0
- package/array/static/arrayize.js.map +1 -0
- package/array/uniquify-by-key.cjs +41 -0
- package/array/uniquify-by-key.d.ts +29 -0
- package/array/uniquify-by-key.js +40 -0
- package/array/uniquify-by-key.js.map +1 -0
- package/array/uniquify.cjs +32 -0
- package/array/uniquify.d.ts +27 -0
- package/array/uniquify.js +31 -0
- package/array/uniquify.js.map +1 -0
- package/boolean/static/is-falsy.cjs +4 -0
- package/boolean/static/is-falsy.d.ts +23 -0
- package/boolean/static/is-falsy.js +4 -0
- package/boolean/static/is-falsy.js.map +1 -0
- package/boolean/static/is-truthy.cjs +4 -0
- package/boolean/static/is-truthy.d.ts +23 -0
- package/boolean/static/is-truthy.js +4 -0
- package/boolean/static/is-truthy.js.map +1 -0
- package/class/index.cjs +4 -0
- package/class/index.d.ts +1 -0
- package/class/index.js +3 -0
- package/class/index.js.map +1 -0
- package/class/mixin.cjs +60 -0
- package/class/mixin.d.ts +50 -0
- package/class/mixin.js +59 -0
- package/class/mixin.js.map +1 -0
- package/compact.cjs +39 -0
- package/compact.d.ts +2 -0
- package/compact.js +38 -0
- package/compact.js.map +1 -0
- package/function/call.cjs +6 -0
- package/function/call.d.ts +1 -0
- package/function/call.js +5 -0
- package/function/call.js.map +1 -0
- package/function/debounce.cjs +85 -0
- package/function/debounce.d.ts +44 -0
- package/function/debounce.js +82 -0
- package/function/debounce.js.map +1 -0
- package/function/defer.cjs +42 -0
- package/function/defer.d.ts +26 -0
- package/function/defer.js +41 -0
- package/function/defer.js.map +1 -0
- package/function/index.cjs +8 -0
- package/function/index.d.ts +5 -0
- package/function/index.js +7 -0
- package/function/index.js.map +1 -0
- package/function/noop.cjs +23 -0
- package/function/noop.d.ts +20 -0
- package/function/noop.js +22 -0
- package/function/noop.js.map +1 -0
- package/function/of.cjs +44 -0
- package/function/of.d.ts +31 -0
- package/function/of.js +43 -0
- package/function/of.js.map +1 -0
- package/function/proto/debounce.cjs +6 -0
- package/function/proto/debounce.d.ts +30 -0
- package/function/proto/debounce.js +6 -0
- package/function/proto/debounce.js.map +1 -0
- package/function/static/call.cjs +4 -0
- package/function/static/call.d.ts +6 -0
- package/function/static/call.js +4 -0
- package/function/static/call.js.map +1 -0
- package/function/static/defer.cjs +4 -0
- package/function/static/defer.d.ts +23 -0
- package/function/static/defer.js +4 -0
- package/function/static/defer.js.map +1 -0
- package/function/static/noop.cjs +4 -0
- package/function/static/noop.d.ts +18 -0
- package/function/static/noop.js +4 -0
- package/function/static/noop.js.map +1 -0
- package/function/static/of.cjs +4 -0
- package/function/static/of.d.ts +26 -0
- package/function/static/of.js +4 -0
- package/function/static/of.js.map +1 -0
- package/index.cjs +31 -0
- package/index.d.ts +14 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/is-falsy.cjs +33 -0
- package/is-falsy.d.ts +28 -0
- package/is-falsy.js +32 -0
- package/is-falsy.js.map +1 -0
- package/is-truthy.cjs +33 -0
- package/is-truthy.d.ts +28 -0
- package/is-truthy.js +32 -0
- package/is-truthy.js.map +1 -0
- package/limit.cjs +34 -0
- package/limit.d.ts +2 -0
- package/limit.js +33 -0
- package/limit.js.map +1 -0
- package/map/index.cjs +4 -0
- package/map/index.d.ts +1 -0
- package/map/index.js +3 -0
- package/map/index.js.map +1 -0
- package/map/merge.cjs +33 -0
- package/map/merge.d.ts +24 -0
- package/map/merge.js +32 -0
- package/map/merge.js.map +1 -0
- package/math/index.cjs +4 -0
- package/math/index.d.ts +1 -0
- package/math/index.js +3 -0
- package/math/index.js.map +1 -0
- package/math/min-max.cjs +29 -0
- package/math/min-max.d.ts +24 -0
- package/math/min-max.js +28 -0
- package/math/min-max.js.map +1 -0
- package/math/static/min-max.cjs +4 -0
- package/math/static/min-max.d.ts +20 -0
- package/math/static/min-max.js +4 -0
- package/math/static/min-max.js.map +1 -0
- package/object/clone.cjs +157 -0
- package/object/clone.d.ts +161 -0
- package/object/clone.js +156 -0
- package/object/clone.js.map +1 -0
- package/object/compact.cjs +49 -0
- package/object/compact.d.ts +37 -0
- package/object/compact.js +48 -0
- package/object/compact.js.map +1 -0
- package/object/deep-freeze.cjs +16 -0
- package/object/deep-freeze.d.ts +1 -0
- package/object/deep-freeze.js +15 -0
- package/object/deep-freeze.js.map +1 -0
- package/object/deepest.cjs +55 -0
- package/object/deepest.d.ts +47 -0
- package/object/deepest.js +54 -0
- package/object/deepest.js.map +1 -0
- package/object/index.cjs +7 -0
- package/object/index.d.ts +4 -0
- package/object/index.js +6 -0
- package/object/index.js.map +1 -0
- package/object/static/clone.cjs +4 -0
- package/object/static/clone.d.ts +43 -0
- package/object/static/clone.js +4 -0
- package/object/static/clone.js.map +1 -0
- package/object/static/compact.cjs +4 -0
- package/object/static/compact.d.ts +26 -0
- package/object/static/compact.js +4 -0
- package/object/static/compact.js.map +1 -0
- package/object/static/deep-freeze.cjs +4 -0
- package/object/static/deep-freeze.d.ts +6 -0
- package/object/static/deep-freeze.js +4 -0
- package/object/static/deep-freeze.js.map +1 -0
- package/object/static/deepest.cjs +4 -0
- package/object/static/deepest.d.ts +32 -0
- package/object/static/deepest.js +4 -0
- package/object/static/deepest.js.map +1 -0
- package/open-promise.cjs +115 -0
- package/open-promise.d.ts +80 -0
- package/open-promise.js +113 -0
- package/open-promise.js.map +1 -0
- package/package.json +667 -0
- package/promise/chain.cjs +12 -0
- package/promise/chain.d.ts +7 -0
- package/promise/chain.js +11 -0
- package/promise/chain.js.map +1 -0
- package/promise/index.cjs +10 -0
- package/promise/index.d.ts +7 -0
- package/promise/index.js +9 -0
- package/promise/index.js.map +1 -0
- package/promise/never.cjs +41 -0
- package/promise/never.d.ts +34 -0
- package/promise/never.js +39 -0
- package/promise/never.js.map +1 -0
- package/promise/promisify.cjs +12 -0
- package/promise/promisify.d.ts +7 -0
- package/promise/promisify.js +11 -0
- package/promise/promisify.js.map +1 -0
- package/promise/proto/revert.cjs +6 -0
- package/promise/proto/revert.d.ts +29 -0
- package/promise/proto/revert.js +6 -0
- package/promise/proto/revert.js.map +1 -0
- package/promise/proto/try-catch.cjs +7 -0
- package/promise/proto/try-catch.d.ts +30 -0
- package/promise/proto/try-catch.js +7 -0
- package/promise/proto/try-catch.js.map +1 -0
- package/promise/revert.cjs +43 -0
- package/promise/revert.d.ts +38 -0
- package/promise/revert.js +42 -0
- package/promise/revert.js.map +1 -0
- package/promise/static/chain.cjs +4 -0
- package/promise/static/chain.d.ts +10 -0
- package/promise/static/chain.js +4 -0
- package/promise/static/chain.js.map +1 -0
- package/promise/static/never.cjs +5 -0
- package/promise/static/never.d.ts +39 -0
- package/promise/static/never.js +5 -0
- package/promise/static/never.js.map +1 -0
- package/promise/static/timeout.cjs +4 -0
- package/promise/static/timeout.d.ts +21 -0
- package/promise/static/timeout.js +4 -0
- package/promise/static/timeout.js.map +1 -0
- package/promise/static/try-one-by-one.cjs +4 -0
- package/promise/static/try-one-by-one.d.ts +27 -0
- package/promise/static/try-one-by-one.js +4 -0
- package/promise/static/try-one-by-one.js.map +1 -0
- package/promise/timeout.cjs +104 -0
- package/promise/timeout.d.ts +109 -0
- package/promise/timeout.js +103 -0
- package/promise/timeout.js.map +1 -0
- package/promise/try-catch.cjs +12 -0
- package/promise/try-catch.d.ts +45 -0
- package/promise/try-catch.js +11 -0
- package/promise/try-catch.js.map +1 -0
- package/promise/try-one-by-one.cjs +59 -0
- package/promise/try-one-by-one.d.ts +42 -0
- package/promise/try-one-by-one.js +58 -0
- package/promise/try-one-by-one.js.map +1 -0
- package/set/proto/difference.cjs +6 -0
- package/set/proto/difference.d.ts +26 -0
- package/set/proto/difference.js +6 -0
- package/set/proto/difference.js.map +1 -0
- package/set/proto/intersection.cjs +6 -0
- package/set/proto/intersection.d.ts +26 -0
- package/set/proto/intersection.js +6 -0
- package/set/proto/intersection.js.map +1 -0
- package/smart-map.cjs +108 -0
- package/smart-map.d.ts +81 -0
- package/smart-map.js +106 -0
- package/smart-map.js.map +1 -0
- package/string/index.cjs +4 -0
- package/string/index.d.ts +1 -0
- package/string/index.js +3 -0
- package/string/index.js.map +1 -0
- package/string/limit.cjs +35 -0
- package/string/limit.d.ts +29 -0
- package/string/limit.js +34 -0
- package/string/limit.js.map +1 -0
- package/string/proto/limit.cjs +6 -0
- package/string/proto/limit.d.ts +30 -0
- package/string/proto/limit.js +6 -0
- package/string/proto/limit.js.map +1 -0
- package/time/days.cjs +21 -0
- package/time/days.d.ts +15 -0
- package/time/days.js +20 -0
- package/time/days.js.map +1 -0
- package/time/hours.cjs +21 -0
- package/time/hours.d.ts +15 -0
- package/time/hours.js +20 -0
- package/time/hours.js.map +1 -0
- package/time/index.cjs +10 -0
- package/time/index.d.ts +7 -0
- package/time/index.js +9 -0
- package/time/index.js.map +1 -0
- package/time/minutes.cjs +21 -0
- package/time/minutes.d.ts +15 -0
- package/time/minutes.js +20 -0
- package/time/minutes.js.map +1 -0
- package/time/months.cjs +21 -0
- package/time/months.d.ts +15 -0
- package/time/months.js +20 -0
- package/time/months.js.map +1 -0
- package/time/seconds.cjs +20 -0
- package/time/seconds.d.ts +15 -0
- package/time/seconds.js +19 -0
- package/time/seconds.js.map +1 -0
- package/time/weeks.cjs +21 -0
- package/time/weeks.d.ts +15 -0
- package/time/weeks.js +20 -0
- package/time/weeks.js.map +1 -0
- package/time/years.cjs +21 -0
- package/time/years.d.ts +15 -0
- package/time/years.js +20 -0
- package/time/years.js.map +1 -0
- package/unique-id.cjs +24 -0
- package/unique-id.d.ts +21 -0
- package/unique-id.js +23 -0
- package/unique-id.js.map +1 -0
package/time/minutes.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minutes = minutes;
|
|
4
|
+
const seconds_1 = require("@telperion/js-utils/time/seconds");
|
|
5
|
+
/**
|
|
6
|
+
* Converts minutes to milliseconds
|
|
7
|
+
*
|
|
8
|
+
* #### Example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { minutes } from "@telperion/js-utils/time";
|
|
11
|
+
*
|
|
12
|
+
* const delay = minutes(2); // 120000 milliseconds
|
|
13
|
+
* setTimeout(() => console.log('Done!'), delay);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param value - Number of minutes
|
|
17
|
+
* @returns Equivalent value in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
function minutes(value) {
|
|
20
|
+
return (0, seconds_1.seconds)(value) * 60;
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts minutes to milliseconds
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { minutes } from "@telperion/js-utils/time";
|
|
7
|
+
*
|
|
8
|
+
* const delay = minutes(2); // 120000 milliseconds
|
|
9
|
+
* setTimeout(() => console.log('Done!'), delay);
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - Number of minutes
|
|
13
|
+
* @returns Equivalent value in milliseconds
|
|
14
|
+
*/
|
|
15
|
+
export declare function minutes(value: number): number;
|
package/time/minutes.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { seconds } from "@telperion/js-utils/time/seconds";
|
|
2
|
+
/**
|
|
3
|
+
* Converts minutes to milliseconds
|
|
4
|
+
*
|
|
5
|
+
* #### Example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { minutes } from "@telperion/js-utils/time";
|
|
8
|
+
*
|
|
9
|
+
* const delay = minutes(2); // 120000 milliseconds
|
|
10
|
+
* setTimeout(() => console.log('Done!'), delay);
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param value - Number of minutes
|
|
14
|
+
* @returns Equivalent value in milliseconds
|
|
15
|
+
*/
|
|
16
|
+
export function minutes(value) {
|
|
17
|
+
return seconds(value) * 60;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=minutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/time/minutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAC7B,CAAC","file":"minutes.js","sourcesContent":["import { seconds } from \"@telperion/js-utils/time/seconds\";\r\n\r\n/**\r\n * Converts minutes to milliseconds\r\n *\r\n * #### Example\r\n * ```typescript\r\n * import { minutes } from \"@telperion/js-utils/time\";\r\n *\r\n * const delay = minutes(2); // 120000 milliseconds\r\n * setTimeout(() => console.log('Done!'), delay);\r\n * ```\r\n *\r\n * @param value - Number of minutes\r\n * @returns Equivalent value in milliseconds\r\n */\r\nexport function minutes(value: number): number {\r\n return seconds(value) * 60;\r\n}\r\n"]}
|
package/time/months.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.months = months;
|
|
4
|
+
const days_1 = require("@telperion/js-utils/time/days");
|
|
5
|
+
/**
|
|
6
|
+
* Converts months to milliseconds (assumes 30 days per month)
|
|
7
|
+
*
|
|
8
|
+
* #### Example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { months } from "@telperion/js-utils/time";
|
|
11
|
+
*
|
|
12
|
+
* const expiryTime = Date.now() + months(3); // ~3 months from now
|
|
13
|
+
* console.log(new Date(expiryTime));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param value - Number of months
|
|
17
|
+
* @returns Equivalent value in milliseconds (30 days per month)
|
|
18
|
+
*/
|
|
19
|
+
function months(value) {
|
|
20
|
+
return (0, days_1.days)(value) * 30;
|
|
21
|
+
}
|
package/time/months.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts months to milliseconds (assumes 30 days per month)
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { months } from "@telperion/js-utils/time";
|
|
7
|
+
*
|
|
8
|
+
* const expiryTime = Date.now() + months(3); // ~3 months from now
|
|
9
|
+
* console.log(new Date(expiryTime));
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - Number of months
|
|
13
|
+
* @returns Equivalent value in milliseconds (30 days per month)
|
|
14
|
+
*/
|
|
15
|
+
export declare function months(value: number): number;
|
package/time/months.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { days } from "@telperion/js-utils/time/days";
|
|
2
|
+
/**
|
|
3
|
+
* Converts months to milliseconds (assumes 30 days per month)
|
|
4
|
+
*
|
|
5
|
+
* #### Example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { months } from "@telperion/js-utils/time";
|
|
8
|
+
*
|
|
9
|
+
* const expiryTime = Date.now() + months(3); // ~3 months from now
|
|
10
|
+
* console.log(new Date(expiryTime));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param value - Number of months
|
|
14
|
+
* @returns Equivalent value in milliseconds (30 days per month)
|
|
15
|
+
*/
|
|
16
|
+
export function months(value) {
|
|
17
|
+
return days(value) * 30;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=months.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/time/months.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAC1B,CAAC","file":"months.js","sourcesContent":["import { days } from \"@telperion/js-utils/time/days\";\r\n\r\n/**\r\n * Converts months to milliseconds (assumes 30 days per month)\r\n *\r\n * #### Example\r\n * ```typescript\r\n * import { months } from \"@telperion/js-utils/time\";\r\n *\r\n * const expiryTime = Date.now() + months(3); // ~3 months from now\r\n * console.log(new Date(expiryTime));\r\n * ```\r\n *\r\n * @param value - Number of months\r\n * @returns Equivalent value in milliseconds (30 days per month)\r\n */\r\nexport function months(value: number): number {\r\n return days(value) * 30;\r\n}\r\n"]}
|
package/time/seconds.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.seconds = seconds;
|
|
4
|
+
/**
|
|
5
|
+
* Converts seconds to milliseconds
|
|
6
|
+
*
|
|
7
|
+
* #### Example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { seconds } from "@telperion/js-utils/time";
|
|
10
|
+
*
|
|
11
|
+
* const delay = seconds(5); // 5000 milliseconds
|
|
12
|
+
* setTimeout(() => console.log('Done!'), delay);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param value - Number of seconds
|
|
16
|
+
* @returns Equivalent value in milliseconds
|
|
17
|
+
*/
|
|
18
|
+
function seconds(value) {
|
|
19
|
+
return value * 1000;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts seconds to milliseconds
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { seconds } from "@telperion/js-utils/time";
|
|
7
|
+
*
|
|
8
|
+
* const delay = seconds(5); // 5000 milliseconds
|
|
9
|
+
* setTimeout(() => console.log('Done!'), delay);
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - Number of seconds
|
|
13
|
+
* @returns Equivalent value in milliseconds
|
|
14
|
+
*/
|
|
15
|
+
export declare function seconds(value: number): number;
|
package/time/seconds.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts seconds to milliseconds
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { seconds } from "@telperion/js-utils/time";
|
|
7
|
+
*
|
|
8
|
+
* const delay = seconds(5); // 5000 milliseconds
|
|
9
|
+
* setTimeout(() => console.log('Done!'), delay);
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - Number of seconds
|
|
13
|
+
* @returns Equivalent value in milliseconds
|
|
14
|
+
*/
|
|
15
|
+
export function seconds(value) {
|
|
16
|
+
return value * 1000;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=seconds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/time/seconds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,KAAK,GAAG,IAAI,CAAC;AACtB,CAAC","file":"seconds.js","sourcesContent":["/**\r\n * Converts seconds to milliseconds\r\n *\r\n * #### Example\r\n * ```typescript\r\n * import { seconds } from \"@telperion/js-utils/time\";\r\n *\r\n * const delay = seconds(5); // 5000 milliseconds\r\n * setTimeout(() => console.log('Done!'), delay);\r\n * ```\r\n *\r\n * @param value - Number of seconds\r\n * @returns Equivalent value in milliseconds\r\n */\r\nexport function seconds(value: number): number {\r\n return value * 1000;\r\n}\r\n"]}
|
package/time/weeks.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.weeks = weeks;
|
|
4
|
+
const days_1 = require("@telperion/js-utils/time/days");
|
|
5
|
+
/**
|
|
6
|
+
* Converts weeks to milliseconds
|
|
7
|
+
*
|
|
8
|
+
* #### Example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { weeks } from "@telperion/js-utils/time";
|
|
11
|
+
*
|
|
12
|
+
* const expiryTime = Date.now() + weeks(2); // 2 weeks from now
|
|
13
|
+
* console.log(new Date(expiryTime));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param value - Number of weeks
|
|
17
|
+
* @returns Equivalent value in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
function weeks(value) {
|
|
20
|
+
return (0, days_1.days)(value) * 7;
|
|
21
|
+
}
|
package/time/weeks.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts weeks to milliseconds
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { weeks } from "@telperion/js-utils/time";
|
|
7
|
+
*
|
|
8
|
+
* const expiryTime = Date.now() + weeks(2); // 2 weeks from now
|
|
9
|
+
* console.log(new Date(expiryTime));
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - Number of weeks
|
|
13
|
+
* @returns Equivalent value in milliseconds
|
|
14
|
+
*/
|
|
15
|
+
export declare function weeks(value: number): number;
|
package/time/weeks.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { days } from "@telperion/js-utils/time/days";
|
|
2
|
+
/**
|
|
3
|
+
* Converts weeks to milliseconds
|
|
4
|
+
*
|
|
5
|
+
* #### Example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { weeks } from "@telperion/js-utils/time";
|
|
8
|
+
*
|
|
9
|
+
* const expiryTime = Date.now() + weeks(2); // 2 weeks from now
|
|
10
|
+
* console.log(new Date(expiryTime));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param value - Number of weeks
|
|
14
|
+
* @returns Equivalent value in milliseconds
|
|
15
|
+
*/
|
|
16
|
+
export function weeks(value) {
|
|
17
|
+
return days(value) * 7;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=weeks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/time/weeks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC","file":"weeks.js","sourcesContent":["import { days } from \"@telperion/js-utils/time/days\";\r\n\r\n/**\r\n * Converts weeks to milliseconds\r\n *\r\n * #### Example\r\n * ```typescript\r\n * import { weeks } from \"@telperion/js-utils/time\";\r\n *\r\n * const expiryTime = Date.now() + weeks(2); // 2 weeks from now\r\n * console.log(new Date(expiryTime));\r\n * ```\r\n *\r\n * @param value - Number of weeks\r\n * @returns Equivalent value in milliseconds\r\n */\r\nexport function weeks(value: number): number {\r\n return days(value) * 7;\r\n}\r\n"]}
|
package/time/years.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.years = years;
|
|
4
|
+
const days_1 = require("@telperion/js-utils/time/days");
|
|
5
|
+
/**
|
|
6
|
+
* Converts years to milliseconds (assumes 365 days per year)
|
|
7
|
+
*
|
|
8
|
+
* #### Example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { years } from "@telperion/js-utils/time";
|
|
11
|
+
*
|
|
12
|
+
* const expiryTime = Date.now() + years(1); // ~1 year from now
|
|
13
|
+
* console.log(new Date(expiryTime));
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param value - Number of years
|
|
17
|
+
* @returns Equivalent value in milliseconds (365 days per year)
|
|
18
|
+
*/
|
|
19
|
+
function years(value) {
|
|
20
|
+
return (0, days_1.days)(value) * 365;
|
|
21
|
+
}
|
package/time/years.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts years to milliseconds (assumes 365 days per year)
|
|
3
|
+
*
|
|
4
|
+
* #### Example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { years } from "@telperion/js-utils/time";
|
|
7
|
+
*
|
|
8
|
+
* const expiryTime = Date.now() + years(1); // ~1 year from now
|
|
9
|
+
* console.log(new Date(expiryTime));
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @param value - Number of years
|
|
13
|
+
* @returns Equivalent value in milliseconds (365 days per year)
|
|
14
|
+
*/
|
|
15
|
+
export declare function years(value: number): number;
|
package/time/years.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { days } from "@telperion/js-utils/time/days";
|
|
2
|
+
/**
|
|
3
|
+
* Converts years to milliseconds (assumes 365 days per year)
|
|
4
|
+
*
|
|
5
|
+
* #### Example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { years } from "@telperion/js-utils/time";
|
|
8
|
+
*
|
|
9
|
+
* const expiryTime = Date.now() + years(1); // ~1 year from now
|
|
10
|
+
* console.log(new Date(expiryTime));
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param value - Number of years
|
|
14
|
+
* @returns Equivalent value in milliseconds (365 days per year)
|
|
15
|
+
*/
|
|
16
|
+
export function years(value) {
|
|
17
|
+
return days(value) * 365;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=years.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/time/years.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC","file":"years.js","sourcesContent":["import { days } from \"@telperion/js-utils/time/days\";\r\n\r\n/**\r\n * Converts years to milliseconds (assumes 365 days per year)\r\n *\r\n * #### Example\r\n * ```typescript\r\n * import { years } from \"@telperion/js-utils/time\";\r\n *\r\n * const expiryTime = Date.now() + years(1); // ~1 year from now\r\n * console.log(new Date(expiryTime));\r\n * ```\r\n *\r\n * @param value - Number of years\r\n * @returns Equivalent value in milliseconds (365 days per year)\r\n */\r\nexport function years(value: number): number {\r\n return days(value) * 365;\r\n}\r\n"]}
|
package/unique-id.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueId = uniqueId;
|
|
4
|
+
const CACHE = {};
|
|
5
|
+
/**
|
|
6
|
+
* Unique Id Generator
|
|
7
|
+
*
|
|
8
|
+
* @param {string} [prefix]
|
|
9
|
+
*/
|
|
10
|
+
function* uniqueIdGenerator(prefix) {
|
|
11
|
+
let counter = 0;
|
|
12
|
+
while (true) {
|
|
13
|
+
yield prefix ? `${prefix}-${counter++}` : counter++;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function uniqueId(prefix) {
|
|
17
|
+
if (!prefix || typeof prefix !== 'string') {
|
|
18
|
+
prefix = undefined;
|
|
19
|
+
}
|
|
20
|
+
if (!(prefix in CACHE)) {
|
|
21
|
+
CACHE[prefix] = uniqueIdGenerator(prefix);
|
|
22
|
+
}
|
|
23
|
+
return CACHE[prefix].next().value;
|
|
24
|
+
}
|
package/unique-id.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #### Generates a unique id
|
|
3
|
+
*
|
|
4
|
+
* Starts a new counter for every unique prefix and if a prefix is given, returns the id by prefixing it, otherwise returns the id as number
|
|
5
|
+
* * * *
|
|
6
|
+
* Example usage:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { uniqueId } from "@telperion/js-utils";
|
|
9
|
+
*
|
|
10
|
+
* uniqueId(); // 0
|
|
11
|
+
* uniqueId(); // 1
|
|
12
|
+
* uniqueId("some-str"); // "some-str-0";
|
|
13
|
+
* uniqueId("some-str"); // "some-str-1";
|
|
14
|
+
* uniqueId(); // 3
|
|
15
|
+
* ```
|
|
16
|
+
* * * *
|
|
17
|
+
* @param prefix prefix to prepend into the unique id
|
|
18
|
+
* @returns A unique id
|
|
19
|
+
*/
|
|
20
|
+
export declare function uniqueId(): number;
|
|
21
|
+
export declare function uniqueId(prefix: string): string;
|
package/unique-id.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const CACHE = {};
|
|
2
|
+
/**
|
|
3
|
+
* Unique Id Generator
|
|
4
|
+
*
|
|
5
|
+
* @param {string} [prefix]
|
|
6
|
+
*/
|
|
7
|
+
function* uniqueIdGenerator(prefix) {
|
|
8
|
+
let counter = 0;
|
|
9
|
+
while (true) {
|
|
10
|
+
yield prefix ? `${prefix}-${counter++}` : counter++;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function uniqueId(prefix) {
|
|
14
|
+
if (!prefix || typeof prefix !== 'string') {
|
|
15
|
+
prefix = undefined;
|
|
16
|
+
}
|
|
17
|
+
if (!(prefix in CACHE)) {
|
|
18
|
+
CACHE[prefix] = uniqueIdGenerator(prefix);
|
|
19
|
+
}
|
|
20
|
+
return CACHE[prefix].next().value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=unique-id.js.map
|
package/unique-id.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/js-utils/src/unique-id.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAA8C,EAAE,CAAC;AAE5D;;;;GAIG;AACH,QAAQ,CAAC,CAAC,iBAAiB,CAAC,MAAe;IACzC,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACtD,CAAC;AACH,CAAC;AAuBD,MAAM,UAAU,QAAQ,CAAC,MAAe;IACtC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,GAAG,SAAU,CAAC;IACtB,CAAC;IAED,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;AACpC,CAAC","file":"unique-id.js","sourcesContent":["const CACHE: Record<string, Iterator<string | number>> = {};\n\n/**\n * Unique Id Generator\n *\n * @param {string} [prefix]\n */\nfunction* uniqueIdGenerator(prefix?: string) {\n let counter = 0;\n\n while (true) {\n yield prefix ? `${prefix}-${counter++}` : counter++;\n }\n}\n\n/**\n * #### Generates a unique id\n *\n * Starts a new counter for every unique prefix and if a prefix is given, returns the id by prefixing it, otherwise returns the id as number\n * * * *\n * Example usage:\n * ```typescript\n * import { uniqueId } from \"@telperion/js-utils\";\n *\n * uniqueId(); // 0\n * uniqueId(); // 1\n * uniqueId(\"some-str\"); // \"some-str-0\";\n * uniqueId(\"some-str\"); // \"some-str-1\";\n * uniqueId(); // 3\n * ```\n * * * *\n * @param prefix prefix to prepend into the unique id\n * @returns A unique id\n */\nexport function uniqueId(): number;\nexport function uniqueId(prefix: string): string;\nexport function uniqueId(prefix?: string): string | number {\n if (!prefix || typeof prefix !== 'string') {\n prefix = undefined!;\n }\n\n if (!(prefix in CACHE)) {\n CACHE[prefix] = uniqueIdGenerator(prefix);\n }\n\n return CACHE[prefix].next().value;\n}\n"]}
|