oak-domain 5.0.7 → 5.0.8
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/utils/uuid.d.ts +2 -0
- package/lib/utils/uuid.js +15 -1
- package/package.json +1 -1
package/lib/utils/uuid.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export declare function generateNewId(): string;
|
|
|
15
15
|
* @param: input: 输入的数据数组,应保证唯一性
|
|
16
16
|
*/
|
|
17
17
|
export declare function formUuid(...input: string[]): string;
|
|
18
|
+
export declare function compressTo32(uuid: string): string;
|
|
19
|
+
export declare function decompressFrom32(compressed: string): string;
|
package/lib/utils/uuid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formUuid = exports.generateNewId = exports.setGenerateIdOption = exports.produceIds = exports.generateNewIdAsync = exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = exports.sequentialUuid = void 0;
|
|
3
|
+
exports.decompressFrom32 = exports.compressTo32 = exports.formUuid = exports.generateNewId = exports.setGenerateIdOption = exports.produceIds = exports.generateNewIdAsync = exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = exports.sequentialUuid = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const random_1 = require("./random/random");
|
|
6
6
|
let _nodeId;
|
|
@@ -216,3 +216,17 @@ function formUuid(...input) {
|
|
|
216
216
|
return unsafeStringify(b);
|
|
217
217
|
}
|
|
218
218
|
exports.formUuid = formUuid;
|
|
219
|
+
function compressTo32(uuid) {
|
|
220
|
+
return uuid.replace(/-/g, '');
|
|
221
|
+
}
|
|
222
|
+
exports.compressTo32 = compressTo32;
|
|
223
|
+
function decompressFrom32(compressed) {
|
|
224
|
+
return [
|
|
225
|
+
compressed.slice(0, 8),
|
|
226
|
+
compressed.slice(8, 12),
|
|
227
|
+
compressed.slice(12, 16),
|
|
228
|
+
compressed.slice(16, 20),
|
|
229
|
+
compressed.slice(20)
|
|
230
|
+
].join('-');
|
|
231
|
+
}
|
|
232
|
+
exports.decompressFrom32 = decompressFrom32;
|