@nakanoaas/uuid58 0.0.1 → 0.0.3
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 -7
- package/esm/decode.d.ts +2 -2
- package/esm/decode.js +2 -2
- package/esm/encode.d.ts +4 -4
- package/esm/encode.js +4 -4
- package/esm/index.d.ts +3 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +3 -3
- package/esm/uuid58.js +2 -2
- package/package.json +1 -1
- package/script/decode.d.ts +2 -2
- package/script/decode.js +3 -3
- package/script/encode.d.ts +4 -4
- package/script/encode.js +5 -5
- package/script/index.d.ts +3 -3
- package/script/index.d.ts.map +1 -1
- package/script/index.js +17 -7
- package/script/uuid58.js +1 -1
package/README.md
CHANGED
|
@@ -48,18 +48,18 @@ pnpm add @nakanoaas/uuid58
|
|
|
48
48
|
## Usage
|
|
49
49
|
|
|
50
50
|
```typescript
|
|
51
|
-
import {
|
|
51
|
+
import { uuid58, uuid58Decode, uuid58Encode } from "@nakanoaas/uuid58";
|
|
52
52
|
|
|
53
53
|
// Generate a new Base58-encoded UUID
|
|
54
54
|
const id = uuid58();
|
|
55
55
|
// => "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
56
56
|
|
|
57
57
|
// Convert existing UUID to Base58
|
|
58
|
-
const encoded =
|
|
58
|
+
const encoded = uuid58Encode("f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf");
|
|
59
59
|
// => "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
60
60
|
|
|
61
61
|
// Convert Base58 back to UUID
|
|
62
|
-
const decoded =
|
|
62
|
+
const decoded = uuid58Decode("XDY9dmBbcMBXqcRvYw8xJ2");
|
|
63
63
|
// => "f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -73,12 +73,12 @@ Generates a new Base58-encoded UUID.
|
|
|
73
73
|
function uuid58(): string;
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
### `
|
|
76
|
+
### `uuid58Encode(uuid: string)`
|
|
77
77
|
|
|
78
78
|
Converts a standard UUID string to a Base58-encoded format.
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
|
-
function
|
|
81
|
+
function uuid58Encode(uuid: string): string;
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
- **Parameters:**
|
|
@@ -86,12 +86,12 @@ function encodeUuid58(uuid: string): string;
|
|
|
86
86
|
- **Returns:** A Base58-encoded string
|
|
87
87
|
- **Throws:** `InvalidUuidError` if the input is not a valid UUID
|
|
88
88
|
|
|
89
|
-
### `
|
|
89
|
+
### `uuid58Decode(encoded: string)`
|
|
90
90
|
|
|
91
91
|
Converts a Base58-encoded string back to a standard UUID format.
|
|
92
92
|
|
|
93
93
|
```typescript
|
|
94
|
-
function
|
|
94
|
+
function uuid58Decode(encoded: string): string;
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
- **Parameters:**
|
package/esm/decode.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export declare class InvalidBase58Error extends Error {
|
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
17
|
-
* const uuid =
|
|
17
|
+
* const uuid = uuid58Decode("XDY9dmBbcMBXqcRvYw8xJ2"); // returns "f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function uuid58Decode(base58: string): string;
|
|
21
21
|
//# sourceMappingURL=decode.d.ts.map
|
package/esm/decode.js
CHANGED
|
@@ -27,10 +27,10 @@ _a = InvalidBase58Error;
|
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
29
|
* ```typescript
|
|
30
|
-
* const uuid =
|
|
30
|
+
* const uuid = uuid58Decode("XDY9dmBbcMBXqcRvYw8xJ2"); // returns "f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
export function
|
|
33
|
+
export function uuid58Decode(base58) {
|
|
34
34
|
if (!/^[1-9A-HJ-NP-Za-km-z]+$/.test(base58)) {
|
|
35
35
|
throw new InvalidBase58Error(base58);
|
|
36
36
|
}
|
package/esm/encode.d.ts
CHANGED
|
@@ -17,12 +17,12 @@ export declare class InvalidUuidError extends Error {
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* // With hyphens
|
|
20
|
-
* const base58 =
|
|
20
|
+
* const base58 = uuid58Encode("f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
21
21
|
* // Without hyphens
|
|
22
|
-
* const base58 =
|
|
22
|
+
* const base58 = uuid58Encode("f4b247fd1f8745d4aa061c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
23
23
|
* // Uppercase UUID is also accepted
|
|
24
|
-
* const base58 =
|
|
24
|
+
* const base58 = uuid58Encode("F4B247FD-1F87-45D4-AA06-1C6FC0A8DFAF"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function uuid58Encode(uuid: string): string;
|
|
28
28
|
//# sourceMappingURL=encode.d.ts.map
|
package/esm/encode.js
CHANGED
|
@@ -25,14 +25,14 @@ _a = InvalidUuidError;
|
|
|
25
25
|
* @example
|
|
26
26
|
* ```typescript
|
|
27
27
|
* // With hyphens
|
|
28
|
-
* const base58 =
|
|
28
|
+
* const base58 = uuid58Encode("f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
29
29
|
* // Without hyphens
|
|
30
|
-
* const base58 =
|
|
30
|
+
* const base58 = uuid58Encode("f4b247fd1f8745d4aa061c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
31
31
|
* // Uppercase UUID is also accepted
|
|
32
|
-
* const base58 =
|
|
32
|
+
* const base58 = uuid58Encode("F4B247FD-1F87-45D4-AA06-1C6FC0A8DFAF"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
export function
|
|
35
|
+
export function uuid58Encode(uuid) {
|
|
36
36
|
const hex = uuid.replace(/-/g, "").toLowerCase();
|
|
37
37
|
if (!/^[0-9a-f]{32}$/.test(hex)) {
|
|
38
38
|
throw new InvalidUuidError(uuid);
|
package/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from "./decode.js";
|
|
2
|
+
export * from "./encode.js";
|
|
3
|
+
export * from "./uuid58.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from "./decode.js";
|
|
2
|
+
export * from "./encode.js";
|
|
3
|
+
export * from "./uuid58.js";
|
package/esm/uuid58.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uuid58Encode } from "./encode.js";
|
|
2
2
|
/**
|
|
3
3
|
* Generates a new Base58-encoded UUID.
|
|
4
4
|
*
|
|
@@ -13,5 +13,5 @@ import { encodeUuid58 } from "./encode.js";
|
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
export function uuid58() {
|
|
16
|
-
return
|
|
16
|
+
return uuid58Encode(crypto.randomUUID());
|
|
17
17
|
}
|
package/package.json
CHANGED
package/script/decode.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export declare class InvalidBase58Error extends Error {
|
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```typescript
|
|
17
|
-
* const uuid =
|
|
17
|
+
* const uuid = uuid58Decode("XDY9dmBbcMBXqcRvYw8xJ2"); // returns "f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function uuid58Decode(base58: string): string;
|
|
21
21
|
//# sourceMappingURL=decode.d.ts.map
|
package/script/decode.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.InvalidBase58Error = void 0;
|
|
5
|
-
exports.
|
|
5
|
+
exports.uuid58Decode = uuid58Decode;
|
|
6
6
|
const alphabet_js_1 = require("./alphabet.js");
|
|
7
7
|
// Fast lookup map from alphabet characters to their indices
|
|
8
8
|
const BASE58_MAP = {};
|
|
@@ -32,10 +32,10 @@ _a = InvalidBase58Error;
|
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```typescript
|
|
35
|
-
* const uuid =
|
|
35
|
+
* const uuid = uuid58Decode("XDY9dmBbcMBXqcRvYw8xJ2"); // returns "f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
function
|
|
38
|
+
function uuid58Decode(base58) {
|
|
39
39
|
if (!/^[1-9A-HJ-NP-Za-km-z]+$/.test(base58)) {
|
|
40
40
|
throw new InvalidBase58Error(base58);
|
|
41
41
|
}
|
package/script/encode.d.ts
CHANGED
|
@@ -17,12 +17,12 @@ export declare class InvalidUuidError extends Error {
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* // With hyphens
|
|
20
|
-
* const base58 =
|
|
20
|
+
* const base58 = uuid58Encode("f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
21
21
|
* // Without hyphens
|
|
22
|
-
* const base58 =
|
|
22
|
+
* const base58 = uuid58Encode("f4b247fd1f8745d4aa061c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
23
23
|
* // Uppercase UUID is also accepted
|
|
24
|
-
* const base58 =
|
|
24
|
+
* const base58 = uuid58Encode("F4B247FD-1F87-45D4-AA06-1C6FC0A8DFAF"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function uuid58Encode(uuid: string): string;
|
|
28
28
|
//# sourceMappingURL=encode.d.ts.map
|
package/script/encode.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
var _a;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.InvalidUuidError = void 0;
|
|
5
|
-
exports.
|
|
5
|
+
exports.uuid58Encode = uuid58Encode;
|
|
6
6
|
const alphabet_js_1 = require("./alphabet.js");
|
|
7
7
|
/**
|
|
8
8
|
* Error thrown when an invalid UUID string is provided for encoding.
|
|
@@ -30,14 +30,14 @@ _a = InvalidUuidError;
|
|
|
30
30
|
* @example
|
|
31
31
|
* ```typescript
|
|
32
32
|
* // With hyphens
|
|
33
|
-
* const base58 =
|
|
33
|
+
* const base58 = uuid58Encode("f4b247fd-1f87-45d4-aa06-1c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
34
34
|
* // Without hyphens
|
|
35
|
-
* const base58 =
|
|
35
|
+
* const base58 = uuid58Encode("f4b247fd1f8745d4aa061c6fc0a8dfaf"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
36
36
|
* // Uppercase UUID is also accepted
|
|
37
|
-
* const base58 =
|
|
37
|
+
* const base58 = uuid58Encode("F4B247FD-1F87-45D4-AA06-1C6FC0A8DFAF"); // returns "XDY9dmBbcMBXqcRvYw8xJ2"
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
function
|
|
40
|
+
function uuid58Encode(uuid) {
|
|
41
41
|
const hex = uuid.replace(/-/g, "").toLowerCase();
|
|
42
42
|
if (!/^[0-9a-f]{32}$/.test(hex)) {
|
|
43
43
|
throw new InvalidUuidError(uuid);
|
package/script/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from "./decode.js";
|
|
2
|
+
export * from "./encode.js";
|
|
3
|
+
export * from "./uuid58.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/script/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
|
package/script/index.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var decode_js_1 = require("./decode.js");
|
|
7
|
-
Object.defineProperty(exports, "decodeUuid58", { enumerable: true, get: function () { return decode_js_1.decodeUuid58; } });
|
|
8
|
-
var uuid58_js_1 = require("./uuid58.js");
|
|
9
|
-
Object.defineProperty(exports, "uuid58", { enumerable: true, get: function () { return uuid58_js_1.uuid58; } });
|
|
17
|
+
__exportStar(require("./decode.js"), exports);
|
|
18
|
+
__exportStar(require("./encode.js"), exports);
|
|
19
|
+
__exportStar(require("./uuid58.js"), exports);
|
package/script/uuid58.js
CHANGED