@nakanoaas/uuid58 1.0.4 → 1.1.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 +56 -0
- package/esm/alphabet.d.ts +39 -2
- package/esm/alphabet.d.ts.map +1 -1
- package/esm/alphabet.js +39 -3
- package/esm/decode.js +4 -4
- package/esm/encode.js +4 -4
- package/esm/{uuid58.d.ts → generate.d.ts} +1 -1
- package/esm/generate.d.ts.map +1 -0
- package/esm/{uuid58.js → generate.js} +4 -4
- package/esm/index.d.ts +2 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -1
- package/package.json +3 -2
- package/script/alphabet.d.ts +39 -2
- package/script/alphabet.d.ts.map +1 -1
- package/script/alphabet.js +40 -4
- package/script/decode.js +3 -3
- package/script/encode.js +3 -3
- package/script/{uuid58.d.ts → generate.d.ts} +1 -1
- package/script/generate.d.ts.map +1 -0
- package/script/{uuid58.js → generate.js} +3 -3
- package/script/index.d.ts +2 -1
- package/script/index.d.ts.map +1 -1
- package/script/index.js +5 -1
- package/esm/uuid58.d.ts.map +0 -1
- package/script/uuid58.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -165,6 +165,62 @@ function uuid58DecodeSafe(uuid58: string): string | Uuid58DecodeError;
|
|
|
165
165
|
`Uuid58DecodeError` if the input is not a valid 22-character Base58 string
|
|
166
166
|
- **Note:** This function does not throw; it returns the error object instead.
|
|
167
167
|
|
|
168
|
+
### Error Classes
|
|
169
|
+
|
|
170
|
+
#### `Uuid58EncodeError`
|
|
171
|
+
|
|
172
|
+
Error thrown when an invalid UUID string is provided for encoding. This includes
|
|
173
|
+
strings that don't match the standard UUID format (32 hexadecimal characters
|
|
174
|
+
with optional hyphens).
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
class Uuid58EncodeError extends Error;
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### `Uuid58DecodeError`
|
|
181
|
+
|
|
182
|
+
Error thrown when an invalid Base58 string is provided for decoding. This
|
|
183
|
+
includes strings containing characters not in the Base58 alphabet or strings
|
|
184
|
+
that are not exactly 22 characters long.
|
|
185
|
+
|
|
186
|
+
```typescript
|
|
187
|
+
class Uuid58DecodeError extends Error;
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Alphabet and Utilities
|
|
191
|
+
|
|
192
|
+
#### `UUID58_ALPHABET`
|
|
193
|
+
|
|
194
|
+
Character set for Base58 encoding (Bitcoin compatible). This alphabet excludes
|
|
195
|
+
characters that can be easily confused: `0` (zero) and `O` (capital O), `I`
|
|
196
|
+
(capital i) and `l` (lowercase L). The alphabet consists of 58 characters:
|
|
197
|
+
digits 1-9 and letters A-Z, a-z (excluding the ambiguous characters mentioned
|
|
198
|
+
above).
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
const UUID58_ALPHABET: string; // "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### `UUID58_REGEX`
|
|
205
|
+
|
|
206
|
+
Regular expression pattern for validating UUID58 strings. This regex ensures
|
|
207
|
+
that a string contains exactly 22 characters and uses only characters from the
|
|
208
|
+
Base58 alphabet.
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
const UUID58_REGEX: RegExp; // /^[1-9A-HJ-NP-Za-km-z]{22}$/
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Example:**
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
import { UUID58_REGEX } from "@nakanoaas/uuid58";
|
|
218
|
+
|
|
219
|
+
const isValid = UUID58_REGEX.test("XDY9dmBbcMBXqcRvYw8xJ2"); // true
|
|
220
|
+
const isValid = UUID58_REGEX.test("invalid"); // false
|
|
221
|
+
const isValid = UUID58_REGEX.test("123"); // false (too short)
|
|
222
|
+
```
|
|
223
|
+
|
|
168
224
|
## Why uuid58?
|
|
169
225
|
|
|
170
226
|
Standard UUIDs are 36 characters long (including hyphens), which can be
|
package/esm/alphabet.d.ts
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Character set for Base58 encoding (Bitcoin compatible).
|
|
3
|
+
*
|
|
4
|
+
* This alphabet excludes characters that can be easily confused:
|
|
5
|
+
* - `0` (zero) and `O` (capital O)
|
|
6
|
+
* - `I` (capital i) and `l` (lowercase L)
|
|
7
|
+
*
|
|
8
|
+
* The alphabet consists of 58 characters: digits 1-9 and letters A-Z, a-z
|
|
9
|
+
* (excluding the ambiguous characters mentioned above).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const char = UUID58_ALPHABET[0]; // "1"
|
|
14
|
+
* const char = UUID58_ALPHABET[9]; // "A"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const UUID58_ALPHABET: string;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* The length of the Base58 alphabet as BigInt for encoding/decoding operations.
|
|
21
|
+
* This is exported for internal use but not part of the public API.
|
|
22
|
+
*/
|
|
23
|
+
export declare const UUID58_LENGTH: bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Regular expression pattern for validating UUID58 strings.
|
|
26
|
+
*
|
|
27
|
+
* This regex ensures that a string:
|
|
28
|
+
* - Contains exactly 22 characters
|
|
29
|
+
* - Uses only characters from the Base58 alphabet
|
|
30
|
+
* - Does not start with leading zeros (represented as "1" in Base58)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const isValid = UUID58_REGEX.test("XDY9dmBbcMBXqcRvYw8xJ2"); // true
|
|
35
|
+
* const isValid = UUID58_REGEX.test("invalid"); // false
|
|
36
|
+
* const isValid = UUID58_REGEX.test("123"); // false (too short)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const UUID58_REGEX: RegExp;
|
|
3
40
|
//# sourceMappingURL=alphabet.d.ts.map
|
package/esm/alphabet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alphabet.d.ts","sourceRoot":"","sources":["../src/alphabet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alphabet.d.ts","sourceRoot":"","sources":["../src/alphabet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,EAAE,MACgC,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAuC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,MAAsC,CAAC"}
|
package/esm/alphabet.js
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Character set for Base58 encoding (Bitcoin compatible).
|
|
3
|
+
*
|
|
4
|
+
* This alphabet excludes characters that can be easily confused:
|
|
5
|
+
* - `0` (zero) and `O` (capital O)
|
|
6
|
+
* - `I` (capital i) and `l` (lowercase L)
|
|
7
|
+
*
|
|
8
|
+
* The alphabet consists of 58 characters: digits 1-9 and letters A-Z, a-z
|
|
9
|
+
* (excluding the ambiguous characters mentioned above).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const char = UUID58_ALPHABET[0]; // "1"
|
|
14
|
+
* const char = UUID58_ALPHABET[9]; // "A"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const UUID58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* The length of the Base58 alphabet as BigInt for encoding/decoding operations.
|
|
21
|
+
* This is exported for internal use but not part of the public API.
|
|
22
|
+
*/
|
|
23
|
+
export const UUID58_LENGTH = BigInt(UUID58_ALPHABET.length);
|
|
24
|
+
/**
|
|
25
|
+
* Regular expression pattern for validating UUID58 strings.
|
|
26
|
+
*
|
|
27
|
+
* This regex ensures that a string:
|
|
28
|
+
* - Contains exactly 22 characters
|
|
29
|
+
* - Uses only characters from the Base58 alphabet
|
|
30
|
+
* - Does not start with leading zeros (represented as "1" in Base58)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const isValid = UUID58_REGEX.test("XDY9dmBbcMBXqcRvYw8xJ2"); // true
|
|
35
|
+
* const isValid = UUID58_REGEX.test("invalid"); // false
|
|
36
|
+
* const isValid = UUID58_REGEX.test("123"); // false (too short)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const UUID58_REGEX = /^[1-9A-HJ-NP-Za-km-z]{22}$/u;
|
package/esm/decode.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var _a;
|
|
2
|
-
import {
|
|
2
|
+
import { UUID58_ALPHABET, UUID58_LENGTH } from "./alphabet.js";
|
|
3
3
|
// Fast lookup map from alphabet characters to their indices
|
|
4
4
|
const BASE58_MAP = {};
|
|
5
|
-
for (let i = 0; i <
|
|
6
|
-
BASE58_MAP[
|
|
5
|
+
for (let i = 0; i < UUID58_ALPHABET.length; i++) {
|
|
6
|
+
BASE58_MAP[UUID58_ALPHABET[i]] = BigInt(i);
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Error thrown when an invalid Base58 string is provided for decoding.
|
|
@@ -41,7 +41,7 @@ export function uuid58DecodeSafe(uuid58) {
|
|
|
41
41
|
if (index === undefined) {
|
|
42
42
|
return new Uuid58DecodeError(`Invalid Base58 character '${char}' found in input: ${uuid58}`);
|
|
43
43
|
}
|
|
44
|
-
num = num *
|
|
44
|
+
num = num * UUID58_LENGTH + index;
|
|
45
45
|
}
|
|
46
46
|
const hex = num.toString(16).padStart(32, "0");
|
|
47
47
|
if (hex.length !== 32) {
|
package/esm/encode.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _a;
|
|
2
|
-
import {
|
|
2
|
+
import { UUID58_ALPHABET, UUID58_LENGTH } from "./alphabet.js";
|
|
3
3
|
/**
|
|
4
4
|
* Error thrown when an invalid UUID string is provided for encoding.
|
|
5
5
|
* This includes strings that don't match the standard UUID format (32 hexadecimal characters with optional hyphens).
|
|
@@ -45,10 +45,10 @@ export function uuid58EncodeSafe(uuid) {
|
|
|
45
45
|
}
|
|
46
46
|
let encoded = "";
|
|
47
47
|
do {
|
|
48
|
-
encoded =
|
|
49
|
-
num /=
|
|
48
|
+
encoded = UUID58_ALPHABET[Number(num % UUID58_LENGTH)] + encoded;
|
|
49
|
+
num /= UUID58_LENGTH;
|
|
50
50
|
} while (num > 0n);
|
|
51
|
-
return encoded.padStart(22,
|
|
51
|
+
return encoded.padStart(22, UUID58_ALPHABET[0]);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Converts a standard UUID string to a 22-character Base58-encoded format.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAe/B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UUID58_ALPHABET, UUID58_LENGTH } from "./alphabet.js";
|
|
2
2
|
/**
|
|
3
3
|
* Generates a new Base58-encoded UUID (always 22 characters).
|
|
4
4
|
*
|
|
@@ -19,8 +19,8 @@ export function uuid58() {
|
|
|
19
19
|
let num = bytes[0] << 64n | bytes[1];
|
|
20
20
|
let encoded = "";
|
|
21
21
|
do {
|
|
22
|
-
encoded =
|
|
23
|
-
num /=
|
|
22
|
+
encoded = UUID58_ALPHABET[Number(num % UUID58_LENGTH)] + encoded;
|
|
23
|
+
num /= UUID58_LENGTH;
|
|
24
24
|
} while (num > 0n);
|
|
25
|
-
return encoded.padStart(22,
|
|
25
|
+
return encoded.padStart(22, UUID58_ALPHABET[0]);
|
|
26
26
|
}
|
package/esm/index.d.ts
CHANGED
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nakanoaas/uuid58",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A tiny, zero-dependency library for generating and converting UUIDs to Base58-encoded strings.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git://github.com/nakanoasaservice/uuid58.git"
|
|
7
|
+
"url": "git+https://github.com/nakanoasaservice/uuid58.git"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"bugs": {
|
|
@@ -20,5 +20,6 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {},
|
|
22
22
|
"sideEffects": false,
|
|
23
|
+
"type": "module",
|
|
23
24
|
"_generatedBy": "dnt@dev"
|
|
24
25
|
}
|
package/script/alphabet.d.ts
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Character set for Base58 encoding (Bitcoin compatible).
|
|
3
|
+
*
|
|
4
|
+
* This alphabet excludes characters that can be easily confused:
|
|
5
|
+
* - `0` (zero) and `O` (capital O)
|
|
6
|
+
* - `I` (capital i) and `l` (lowercase L)
|
|
7
|
+
*
|
|
8
|
+
* The alphabet consists of 58 characters: digits 1-9 and letters A-Z, a-z
|
|
9
|
+
* (excluding the ambiguous characters mentioned above).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const char = UUID58_ALPHABET[0]; // "1"
|
|
14
|
+
* const char = UUID58_ALPHABET[9]; // "A"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const UUID58_ALPHABET: string;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* The length of the Base58 alphabet as BigInt for encoding/decoding operations.
|
|
21
|
+
* This is exported for internal use but not part of the public API.
|
|
22
|
+
*/
|
|
23
|
+
export declare const UUID58_LENGTH: bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Regular expression pattern for validating UUID58 strings.
|
|
26
|
+
*
|
|
27
|
+
* This regex ensures that a string:
|
|
28
|
+
* - Contains exactly 22 characters
|
|
29
|
+
* - Uses only characters from the Base58 alphabet
|
|
30
|
+
* - Does not start with leading zeros (represented as "1" in Base58)
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const isValid = UUID58_REGEX.test("XDY9dmBbcMBXqcRvYw8xJ2"); // true
|
|
35
|
+
* const isValid = UUID58_REGEX.test("invalid"); // false
|
|
36
|
+
* const isValid = UUID58_REGEX.test("123"); // false (too short)
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare const UUID58_REGEX: RegExp;
|
|
3
40
|
//# sourceMappingURL=alphabet.d.ts.map
|
package/script/alphabet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alphabet.d.ts","sourceRoot":"","sources":["../src/alphabet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"alphabet.d.ts","sourceRoot":"","sources":["../src/alphabet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,EAAE,MACgC,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAuC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,EAAE,MAAsC,CAAC"}
|
package/script/alphabet.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.UUID58_REGEX = exports.UUID58_LENGTH = exports.UUID58_ALPHABET = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Character set for Base58 encoding (Bitcoin compatible).
|
|
6
|
+
*
|
|
7
|
+
* This alphabet excludes characters that can be easily confused:
|
|
8
|
+
* - `0` (zero) and `O` (capital O)
|
|
9
|
+
* - `I` (capital i) and `l` (lowercase L)
|
|
10
|
+
*
|
|
11
|
+
* The alphabet consists of 58 characters: digits 1-9 and letters A-Z, a-z
|
|
12
|
+
* (excluding the ambiguous characters mentioned above).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const char = UUID58_ALPHABET[0]; // "1"
|
|
17
|
+
* const char = UUID58_ALPHABET[9]; // "A"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
exports.UUID58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
21
|
+
/**
|
|
22
|
+
* @internal
|
|
23
|
+
* The length of the Base58 alphabet as BigInt for encoding/decoding operations.
|
|
24
|
+
* This is exported for internal use but not part of the public API.
|
|
25
|
+
*/
|
|
26
|
+
exports.UUID58_LENGTH = BigInt(exports.UUID58_ALPHABET.length);
|
|
27
|
+
/**
|
|
28
|
+
* Regular expression pattern for validating UUID58 strings.
|
|
29
|
+
*
|
|
30
|
+
* This regex ensures that a string:
|
|
31
|
+
* - Contains exactly 22 characters
|
|
32
|
+
* - Uses only characters from the Base58 alphabet
|
|
33
|
+
* - Does not start with leading zeros (represented as "1" in Base58)
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const isValid = UUID58_REGEX.test("XDY9dmBbcMBXqcRvYw8xJ2"); // true
|
|
38
|
+
* const isValid = UUID58_REGEX.test("invalid"); // false
|
|
39
|
+
* const isValid = UUID58_REGEX.test("123"); // false (too short)
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
exports.UUID58_REGEX = /^[1-9A-HJ-NP-Za-km-z]{22}$/u;
|
package/script/decode.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.uuid58Decode = uuid58Decode;
|
|
|
7
7
|
const alphabet_js_1 = require("./alphabet.js");
|
|
8
8
|
// Fast lookup map from alphabet characters to their indices
|
|
9
9
|
const BASE58_MAP = {};
|
|
10
|
-
for (let i = 0; i < alphabet_js_1.
|
|
11
|
-
BASE58_MAP[alphabet_js_1.
|
|
10
|
+
for (let i = 0; i < alphabet_js_1.UUID58_ALPHABET.length; i++) {
|
|
11
|
+
BASE58_MAP[alphabet_js_1.UUID58_ALPHABET[i]] = BigInt(i);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Error thrown when an invalid Base58 string is provided for decoding.
|
|
@@ -47,7 +47,7 @@ function uuid58DecodeSafe(uuid58) {
|
|
|
47
47
|
if (index === undefined) {
|
|
48
48
|
return new Uuid58DecodeError(`Invalid Base58 character '${char}' found in input: ${uuid58}`);
|
|
49
49
|
}
|
|
50
|
-
num = num * alphabet_js_1.
|
|
50
|
+
num = num * alphabet_js_1.UUID58_LENGTH + index;
|
|
51
51
|
}
|
|
52
52
|
const hex = num.toString(16).padStart(32, "0");
|
|
53
53
|
if (hex.length !== 32) {
|
package/script/encode.js
CHANGED
|
@@ -51,10 +51,10 @@ function uuid58EncodeSafe(uuid) {
|
|
|
51
51
|
}
|
|
52
52
|
let encoded = "";
|
|
53
53
|
do {
|
|
54
|
-
encoded = alphabet_js_1.
|
|
55
|
-
num /= alphabet_js_1.
|
|
54
|
+
encoded = alphabet_js_1.UUID58_ALPHABET[Number(num % alphabet_js_1.UUID58_LENGTH)] + encoded;
|
|
55
|
+
num /= alphabet_js_1.UUID58_LENGTH;
|
|
56
56
|
} while (num > 0n);
|
|
57
|
-
return encoded.padStart(22, alphabet_js_1.
|
|
57
|
+
return encoded.padStart(22, alphabet_js_1.UUID58_ALPHABET[0]);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Converts a standard UUID string to a 22-character Base58-encoded format.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAe/B"}
|
|
@@ -22,8 +22,8 @@ function uuid58() {
|
|
|
22
22
|
let num = bytes[0] << 64n | bytes[1];
|
|
23
23
|
let encoded = "";
|
|
24
24
|
do {
|
|
25
|
-
encoded = alphabet_js_1.
|
|
26
|
-
num /= alphabet_js_1.
|
|
25
|
+
encoded = alphabet_js_1.UUID58_ALPHABET[Number(num % alphabet_js_1.UUID58_LENGTH)] + encoded;
|
|
26
|
+
num /= alphabet_js_1.UUID58_LENGTH;
|
|
27
27
|
} while (num > 0n);
|
|
28
|
-
return encoded.padStart(22, alphabet_js_1.
|
|
28
|
+
return encoded.padStart(22, alphabet_js_1.UUID58_ALPHABET[0]);
|
|
29
29
|
}
|
package/script/index.d.ts
CHANGED
package/script/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/script/index.js
CHANGED
|
@@ -14,6 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.UUID58_REGEX = exports.UUID58_ALPHABET = void 0;
|
|
18
|
+
var alphabet_js_1 = require("./alphabet.js");
|
|
19
|
+
Object.defineProperty(exports, "UUID58_ALPHABET", { enumerable: true, get: function () { return alphabet_js_1.UUID58_ALPHABET; } });
|
|
20
|
+
Object.defineProperty(exports, "UUID58_REGEX", { enumerable: true, get: function () { return alphabet_js_1.UUID58_REGEX; } });
|
|
17
21
|
__exportStar(require("./decode.js"), exports);
|
|
18
22
|
__exportStar(require("./encode.js"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./generate.js"), exports);
|
package/esm/uuid58.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid58.d.ts","sourceRoot":"","sources":["../src/uuid58.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAe/B"}
|
package/script/uuid58.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid58.d.ts","sourceRoot":"","sources":["../src/uuid58.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAe/B"}
|