@powfix/core-js 0.11.4 → 0.11.6

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.
@@ -0,0 +1,4 @@
1
+ export declare class ObjectIdUtils {
2
+ static toUuid(objectId: string, pad?: 'start' | 'end'): string;
3
+ static fromUuid(uuid: string, pad?: 'start' | 'end'): string;
4
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ObjectIdUtils = void 0;
4
+ const UuidUtils_1 = require("./UuidUtils");
5
+ class ObjectIdUtils {
6
+ static toUuid(objectId, pad = 'start') {
7
+ const result = Buffer.alloc(16);
8
+ Buffer.from(objectId, 'hex').copy(result, pad === 'start' ? 4 : 0);
9
+ return UuidUtils_1.UuidUtils.toString(result);
10
+ }
11
+ static fromUuid(uuid, pad) {
12
+ const buffer = UuidUtils_1.UuidUtils.toBuffer(uuid);
13
+ const isPadEnd = buffer.subarray(buffer.length - 4).every(byte => byte === 0);
14
+ if (isPadEnd || pad === 'end') {
15
+ return buffer.subarray(0, buffer.length - 4).toString('hex');
16
+ }
17
+ const isPadStart = buffer.subarray(0, 4).every(byte => byte === 0);
18
+ if (!isPadStart) {
19
+ console.warn('buffer is not pad start and pad end');
20
+ }
21
+ return buffer.subarray(4).toString('hex');
22
+ }
23
+ }
24
+ exports.ObjectIdUtils = ObjectIdUtils;
@@ -7,7 +7,7 @@ export declare class UuidUtils {
7
7
  * @param binary UUID
8
8
  * @returns {string|null} When binary not exists return null
9
9
  */
10
- static toString(binary?: Buffer): string | null;
10
+ static toString(binary: Buffer): string;
11
11
  /** (UUID: string) to (UUID: Buffer) */
12
12
  static toBuffer(uuid: string): Buffer;
13
13
  static isValidUUID(uuid: string): boolean;
@@ -24,18 +24,15 @@ class UuidUtils {
24
24
  return uuid;
25
25
  }
26
26
  }
27
- /**
28
- * (UUID: Buffer) to (UUID: string)
29
- * @param binary UUID
30
- * @returns {string|null} When binary not exists return null
31
- */
32
27
  static toString(binary) {
33
28
  if (!binary)
34
29
  return null;
35
30
  return UuidUtils.format(binaryToString(binary));
36
31
  }
37
- /** (UUID: string) to (UUID: Buffer) */
38
32
  static toBuffer(uuid) {
33
+ if (!uuid) {
34
+ return null;
35
+ }
39
36
  return Buffer.from(uuid.replace(/-/g, ''), 'hex');
40
37
  }
41
38
  static isValidUUID(uuid) {
@@ -1,11 +1,13 @@
1
1
  export * from './global';
2
2
  export * from './StringUtils';
3
- export * from './NumberUtils';
4
3
  export * from './UuidUtils';
5
4
  export * from './ArrayUtils';
6
5
  export * from './BooleanUtils';
7
6
  export * from './CoordinateUtils';
8
7
  export * from './DateUtils';
8
+ export * from './NumberUtils';
9
+ export * from './ObjectIdUtils';
10
+ export * from './Point3Utils';
9
11
  export * from './RandomUtils';
10
12
  export * from './Validator';
11
13
  export * from './JuminNumberUtils';
@@ -16,12 +16,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./global"), exports);
18
18
  __exportStar(require("./StringUtils"), exports);
19
- __exportStar(require("./NumberUtils"), exports);
20
19
  __exportStar(require("./UuidUtils"), exports);
21
20
  __exportStar(require("./ArrayUtils"), exports);
22
21
  __exportStar(require("./BooleanUtils"), exports);
23
22
  __exportStar(require("./CoordinateUtils"), exports);
24
23
  __exportStar(require("./DateUtils"), exports);
24
+ __exportStar(require("./NumberUtils"), exports);
25
+ __exportStar(require("./ObjectIdUtils"), exports);
26
+ __exportStar(require("./Point3Utils"), exports);
25
27
  __exportStar(require("./RandomUtils"), exports);
26
28
  __exportStar(require("./Validator"), exports);
27
29
  __exportStar(require("./JuminNumberUtils"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.11.4",
3
+ "version": "0.11.6",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,
@@ -37,6 +37,7 @@
37
37
  "@types/uuid": "9.0.7",
38
38
  "axios": "1.7.9",
39
39
  "moment": "^2.30.1",
40
+ "ts-node": "^10.9.2",
40
41
  "typescript": "5.1.6"
41
42
  },
42
43
  "peerDependencies": {