@dgpholdings/greatoak-shared 1.1.82 → 1.1.83
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/utils/planCode.util.js +21 -2
- package/package.json +2 -2
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generatePlanCode = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; // Crockford's Base32
|
|
5
|
+
const encodeTime = (now, len) => {
|
|
6
|
+
let str = "";
|
|
7
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
8
|
+
const mod = now % 32;
|
|
9
|
+
str = ENCODING[mod] + str;
|
|
10
|
+
now = Math.floor(now / 32);
|
|
11
|
+
}
|
|
12
|
+
return str;
|
|
13
|
+
};
|
|
14
|
+
const encodeRandom = (len) => {
|
|
15
|
+
let str = "";
|
|
16
|
+
for (let i = 0; i < len; i++) {
|
|
17
|
+
str += ENCODING[Math.floor(Math.random() * 32)];
|
|
18
|
+
}
|
|
19
|
+
return str;
|
|
20
|
+
};
|
|
21
|
+
const generatePlanCode = () => {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
return encodeTime(now, 6) + encodeRandom(3); // 9 characters total
|
|
24
|
+
};
|
|
6
25
|
exports.generatePlanCode = generatePlanCode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dgpholdings/greatoak-shared",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.83",
|
|
4
4
|
"description": "Shared TypeScript types and utilities for @dgpholdings projects",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"typescript": "^5.8.2"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
24
|
+
"react-native-uuid": "^2.0.3"
|
|
25
25
|
}
|
|
26
26
|
}
|