@softsky/utils 2.4.0 → 2.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/README.md +7 -1
- package/dist/control.d.ts +6 -2
- package/dist/control.js +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,7 +107,13 @@ ${\textsf{\color{ForestGreen}const}}$ SEC_MS - Milliseconds in a second
|
|
|
107
107
|
## Control
|
|
108
108
|
Utils related to code execution flow.
|
|
109
109
|
|
|
110
|
-
${\textsf{\color{ForestGreen}const}}$
|
|
110
|
+
${\textsf{\color{ForestGreen}const}}$ generateNumberId - Get unique number id
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
${\textsf{\color{CornflowerBlue}function}}$ UUID - Get universally unique string id
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
${\textsf{\color{CornflowerBlue}function}}$ extractUUIDDate - Extract exact date of uuid generation
|
|
111
117
|
|
|
112
118
|
---
|
|
113
119
|
${\textsf{\color{CornflowerBlue}function}}$ createCashedFunction - Creates cached function. All arguments/results are cached.
|
package/dist/control.d.ts
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
* Utils related to code execution flow.
|
|
3
3
|
*/
|
|
4
4
|
import { AwaitedObject, JSONSerializable } from './types';
|
|
5
|
-
/** Get unique id */
|
|
6
|
-
export declare const
|
|
5
|
+
/** Get unique number id */
|
|
6
|
+
export declare const generateNumberId: () => number;
|
|
7
|
+
/** Get universally unique string id */
|
|
8
|
+
export declare function UUID(): string;
|
|
9
|
+
/** Extract exact date of uuid generation */
|
|
10
|
+
export declare function extractUUIDDate(uuid: string): Date;
|
|
7
11
|
/**
|
|
8
12
|
* Creates cached function. All arguments/results are cached.
|
|
9
13
|
* Returns [
|
package/dist/control.js
CHANGED
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
* Utils related to code execution flow.
|
|
3
3
|
*/
|
|
4
4
|
let _uuid = Date.now() * 1000;
|
|
5
|
-
/** Get unique id */
|
|
6
|
-
export const
|
|
5
|
+
/** Get unique number id */
|
|
6
|
+
export const generateNumberId = () => _uuid++;
|
|
7
|
+
const SESSION_ID = ((Math.random() * 2_147_483_648) | 0).toString(16);
|
|
8
|
+
let stringIdInc = 0;
|
|
9
|
+
/** Get universally unique string id */
|
|
10
|
+
export function UUID() {
|
|
11
|
+
return `${Date.now().toString(36).padStart(11, '0')}${(++stringIdInc).toString(36).padStart(3, '0')}${SESSION_ID}`;
|
|
12
|
+
}
|
|
13
|
+
/** Extract exact date of uuid generation */
|
|
14
|
+
export function extractUUIDDate(uuid) {
|
|
15
|
+
return new Date(Number.parseInt(uuid.slice(0, 11), 36));
|
|
16
|
+
}
|
|
7
17
|
/**
|
|
8
18
|
* Creates cached function. All arguments/results are cached.
|
|
9
19
|
* Returns [
|