@kakilangit/id-generator 0.2.0 → 0.3.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 +10 -10
- package/id_generator.d.ts +26 -26
- package/id_generator.js +42 -42
- package/id_generator_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,23 +23,23 @@ npm install @kakilangit/id-generator
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
```javascript
|
|
26
|
-
import init, { generate_ids, decode_id,
|
|
26
|
+
import init, { generate_ids, decode_id, IdFormat, IdCase } from '@kakilangit/id-generator';
|
|
27
27
|
|
|
28
28
|
// Initialize the WASM module
|
|
29
29
|
await init();
|
|
30
30
|
|
|
31
31
|
// Generate 5 UUID v4 IDs in lowercase
|
|
32
|
-
const uuids = generate_ids(
|
|
32
|
+
const uuids = generate_ids(IdFormat.UuidV4, 5, IdCase.Lower);
|
|
33
33
|
console.log(uuids); // ["a1b2c3d4-...", "e5f6g7h8-...", ...]
|
|
34
34
|
|
|
35
35
|
// Generate time-based UUID v7
|
|
36
|
-
const uuid7s = generate_ids(
|
|
36
|
+
const uuid7s = generate_ids(IdFormat.UuidV7, 1, IdCase.Lower);
|
|
37
37
|
|
|
38
38
|
// Generate NULIDs (nanosecond precision)
|
|
39
|
-
const nulids = generate_ids(
|
|
39
|
+
const nulids = generate_ids(IdFormat.Nulid, 3, IdCase.Upper);
|
|
40
40
|
|
|
41
41
|
// Generate NanoIDs (URL-safe, 21 characters by default)
|
|
42
|
-
const nanoids = generate_ids(
|
|
42
|
+
const nanoids = generate_ids(IdFormat.NanoId, 5, IdCase.Lower);
|
|
43
43
|
|
|
44
44
|
// Decode an ID to get metadata
|
|
45
45
|
const decoded = decode_id("01hny0qzcw8a5v8z...");
|
|
@@ -57,9 +57,9 @@ console.log(decoded.bytes); // Byte representation (colon-separated)
|
|
|
57
57
|
#### `generate_ids(format, count, case)`
|
|
58
58
|
Generates multiple IDs of the specified format.
|
|
59
59
|
|
|
60
|
-
- `format` (
|
|
60
|
+
- `format` (IdFormat): The ID format to generate
|
|
61
61
|
- `count` (number): Number of IDs to generate (1-10000)
|
|
62
|
-
- `case` (
|
|
62
|
+
- `case` (IdCase): Case format for alphabetic characters (ignored for NanoID)
|
|
63
63
|
|
|
64
64
|
Returns: `string[]` - Array of generated IDs
|
|
65
65
|
|
|
@@ -68,7 +68,7 @@ Decodes an ID string and returns its metadata.
|
|
|
68
68
|
|
|
69
69
|
- `id` (string): The ID to decode
|
|
70
70
|
|
|
71
|
-
Returns `
|
|
71
|
+
Returns `DecodedId`:
|
|
72
72
|
- `original`: The original ID string
|
|
73
73
|
- `format`: Detected format name ("UUID v1", "UUID v4", "UUID v6", "UUID v7", "UUID v8", "NULID")
|
|
74
74
|
- `time`: RFC 3339 formatted time string (if time-based: UUID v1, v6, v7, NULID)
|
|
@@ -82,7 +82,7 @@ Returns all available ID format names.
|
|
|
82
82
|
|
|
83
83
|
### Enums
|
|
84
84
|
|
|
85
|
-
#### `
|
|
85
|
+
#### `IdFormat`
|
|
86
86
|
- `UuidV1 = 0` - UUID version 1 (time-based with MAC address)
|
|
87
87
|
- `UuidV4 = 1` - UUID version 4 (random)
|
|
88
88
|
- `UuidV6 = 2` - UUID version 6 (time-ordered for database locality)
|
|
@@ -91,7 +91,7 @@ Returns all available ID format names.
|
|
|
91
91
|
- `Nulid = 5` - NULID (nanosecond-precision ULID)
|
|
92
92
|
- `NanoId = 6` - NanoID (URL-friendly, cryptographically secure)
|
|
93
93
|
|
|
94
|
-
#### `
|
|
94
|
+
#### `IdCase`
|
|
95
95
|
- `Lower = 0` - Lowercase output
|
|
96
96
|
- `Upper = 1` - Uppercase output
|
|
97
97
|
|
package/id_generator.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* Decoded ID result for JavaScript.
|
|
6
6
|
*/
|
|
7
|
-
export class
|
|
7
|
+
export class DecodedId {
|
|
8
8
|
private constructor();
|
|
9
9
|
free(): void;
|
|
10
10
|
[Symbol.dispose](): void;
|
|
@@ -39,17 +39,17 @@ export class JsDecodedId {
|
|
|
39
39
|
/**
|
|
40
40
|
* Timestamp (if applicable).
|
|
41
41
|
*/
|
|
42
|
-
get timestamp():
|
|
42
|
+
get timestamp(): Timestamp | undefined;
|
|
43
43
|
/**
|
|
44
44
|
* Timestamp (if applicable).
|
|
45
45
|
*/
|
|
46
|
-
set timestamp(value:
|
|
46
|
+
set timestamp(value: Timestamp | null | undefined);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Case format options for JavaScript.
|
|
51
51
|
*/
|
|
52
|
-
export enum
|
|
52
|
+
export enum IdCase {
|
|
53
53
|
/**
|
|
54
54
|
* Lowercase output.
|
|
55
55
|
*/
|
|
@@ -63,7 +63,7 @@ export enum JsIdCase {
|
|
|
63
63
|
/**
|
|
64
64
|
* ID format options for JavaScript.
|
|
65
65
|
*/
|
|
66
|
-
export enum
|
|
66
|
+
export enum IdFormat {
|
|
67
67
|
/**
|
|
68
68
|
* UUID version 1 (time-based with MAC address).
|
|
69
69
|
*/
|
|
@@ -97,7 +97,7 @@ export enum JsIdFormat {
|
|
|
97
97
|
/**
|
|
98
98
|
* Timestamp precision for JavaScript.
|
|
99
99
|
*/
|
|
100
|
-
export class
|
|
100
|
+
export class Timestamp {
|
|
101
101
|
private constructor();
|
|
102
102
|
free(): void;
|
|
103
103
|
[Symbol.dispose](): void;
|
|
@@ -118,7 +118,7 @@ export class JsTimestamp {
|
|
|
118
118
|
*
|
|
119
119
|
* Returns an error string if the ID format is not recognized.
|
|
120
120
|
*/
|
|
121
|
-
export function decode_id(id: string):
|
|
121
|
+
export function decode_id(id: string): DecodedId;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
124
|
* Generates IDs based on the specified format, count, and case.
|
|
@@ -129,7 +129,7 @@ export function decode_id(id: string): JsDecodedId;
|
|
|
129
129
|
*
|
|
130
130
|
* Returns an error string if generation fails (e.g., invalid count).
|
|
131
131
|
*/
|
|
132
|
-
export function generate_ids(format:
|
|
132
|
+
export function generate_ids(format: IdFormat, count: number, _case: IdCase): string[];
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Returns all available ID format names.
|
|
@@ -140,27 +140,27 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
140
140
|
|
|
141
141
|
export interface InitOutput {
|
|
142
142
|
readonly memory: WebAssembly.Memory;
|
|
143
|
-
readonly
|
|
144
|
-
readonly
|
|
145
|
-
readonly
|
|
146
|
-
readonly
|
|
147
|
-
readonly
|
|
148
|
-
readonly
|
|
149
|
-
readonly
|
|
150
|
-
readonly
|
|
151
|
-
readonly
|
|
152
|
-
readonly
|
|
153
|
-
readonly
|
|
154
|
-
readonly
|
|
155
|
-
readonly
|
|
156
|
-
readonly
|
|
143
|
+
readonly __wbg_decodedid_free: (a: number, b: number) => void;
|
|
144
|
+
readonly __wbg_get_decodedid_bytes: (a: number, b: number) => void;
|
|
145
|
+
readonly __wbg_get_decodedid_format: (a: number, b: number) => void;
|
|
146
|
+
readonly __wbg_get_decodedid_original: (a: number, b: number) => void;
|
|
147
|
+
readonly __wbg_get_decodedid_randomness: (a: number, b: number) => void;
|
|
148
|
+
readonly __wbg_get_decodedid_time: (a: number, b: number) => void;
|
|
149
|
+
readonly __wbg_get_decodedid_timestamp: (a: number) => number;
|
|
150
|
+
readonly __wbg_set_decodedid_bytes: (a: number, b: number, c: number) => void;
|
|
151
|
+
readonly __wbg_set_decodedid_format: (a: number, b: number, c: number) => void;
|
|
152
|
+
readonly __wbg_set_decodedid_original: (a: number, b: number, c: number) => void;
|
|
153
|
+
readonly __wbg_set_decodedid_randomness: (a: number, b: number, c: number) => void;
|
|
154
|
+
readonly __wbg_set_decodedid_time: (a: number, b: number, c: number) => void;
|
|
155
|
+
readonly __wbg_set_decodedid_timestamp: (a: number, b: number) => void;
|
|
156
|
+
readonly __wbg_timestamp_free: (a: number, b: number) => void;
|
|
157
157
|
readonly decode_id: (a: number, b: number, c: number) => void;
|
|
158
158
|
readonly generate_ids: (a: number, b: number, c: number, d: number) => void;
|
|
159
159
|
readonly get_available_formats: (a: number) => void;
|
|
160
|
-
readonly
|
|
161
|
-
readonly
|
|
162
|
-
readonly
|
|
163
|
-
readonly
|
|
160
|
+
readonly __wbg_set_timestamp_value: (a: number, b: number, c: number) => void;
|
|
161
|
+
readonly __wbg_set_timestamp_precision: (a: number, b: number, c: number) => void;
|
|
162
|
+
readonly __wbg_get_timestamp_value: (a: number, b: number) => void;
|
|
163
|
+
readonly __wbg_get_timestamp_precision: (a: number, b: number) => void;
|
|
164
164
|
readonly __wbindgen_export: (a: number) => void;
|
|
165
165
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
166
166
|
readonly __wbindgen_export2: (a: number, b: number) => number;
|
package/id_generator.js
CHANGED
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Decoded ID result for JavaScript.
|
|
5
5
|
*/
|
|
6
|
-
export class
|
|
6
|
+
export class DecodedId {
|
|
7
7
|
static __wrap(ptr) {
|
|
8
8
|
ptr = ptr >>> 0;
|
|
9
|
-
const obj = Object.create(
|
|
9
|
+
const obj = Object.create(DecodedId.prototype);
|
|
10
10
|
obj.__wbg_ptr = ptr;
|
|
11
|
-
|
|
11
|
+
DecodedIdFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
12
12
|
return obj;
|
|
13
13
|
}
|
|
14
14
|
__destroy_into_raw() {
|
|
15
15
|
const ptr = this.__wbg_ptr;
|
|
16
16
|
this.__wbg_ptr = 0;
|
|
17
|
-
|
|
17
|
+
DecodedIdFinalization.unregister(this);
|
|
18
18
|
return ptr;
|
|
19
19
|
}
|
|
20
20
|
free() {
|
|
21
21
|
const ptr = this.__destroy_into_raw();
|
|
22
|
-
wasm.
|
|
22
|
+
wasm.__wbg_decodedid_free(ptr, 0);
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Full ID as bytes (as comma-separated string for JS).
|
|
@@ -30,7 +30,7 @@ export class JsDecodedId {
|
|
|
30
30
|
let deferred1_1;
|
|
31
31
|
try {
|
|
32
32
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
33
|
-
wasm.
|
|
33
|
+
wasm.__wbg_get_decodedid_bytes(retptr, this.__wbg_ptr);
|
|
34
34
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
35
35
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
36
36
|
deferred1_0 = r0;
|
|
@@ -50,7 +50,7 @@ export class JsDecodedId {
|
|
|
50
50
|
let deferred1_1;
|
|
51
51
|
try {
|
|
52
52
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
53
|
-
wasm.
|
|
53
|
+
wasm.__wbg_get_decodedid_format(retptr, this.__wbg_ptr);
|
|
54
54
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
55
55
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
56
56
|
deferred1_0 = r0;
|
|
@@ -70,7 +70,7 @@ export class JsDecodedId {
|
|
|
70
70
|
let deferred1_1;
|
|
71
71
|
try {
|
|
72
72
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
73
|
-
wasm.
|
|
73
|
+
wasm.__wbg_get_decodedid_original(retptr, this.__wbg_ptr);
|
|
74
74
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
75
75
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
76
76
|
deferred1_0 = r0;
|
|
@@ -88,7 +88,7 @@ export class JsDecodedId {
|
|
|
88
88
|
get randomness() {
|
|
89
89
|
try {
|
|
90
90
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
91
|
-
wasm.
|
|
91
|
+
wasm.__wbg_get_decodedid_randomness(retptr, this.__wbg_ptr);
|
|
92
92
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
93
93
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
94
94
|
let v1;
|
|
@@ -108,7 +108,7 @@ export class JsDecodedId {
|
|
|
108
108
|
get time() {
|
|
109
109
|
try {
|
|
110
110
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
111
|
-
wasm.
|
|
111
|
+
wasm.__wbg_get_decodedid_time(retptr, this.__wbg_ptr);
|
|
112
112
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
113
113
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
114
114
|
let v1;
|
|
@@ -123,11 +123,11 @@ export class JsDecodedId {
|
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Timestamp (if applicable).
|
|
126
|
-
* @returns {
|
|
126
|
+
* @returns {Timestamp | undefined}
|
|
127
127
|
*/
|
|
128
128
|
get timestamp() {
|
|
129
|
-
const ret = wasm.
|
|
130
|
-
return ret === 0 ? undefined :
|
|
129
|
+
const ret = wasm.__wbg_get_decodedid_timestamp(this.__wbg_ptr);
|
|
130
|
+
return ret === 0 ? undefined : Timestamp.__wrap(ret);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* Full ID as bytes (as comma-separated string for JS).
|
|
@@ -136,7 +136,7 @@ export class JsDecodedId {
|
|
|
136
136
|
set bytes(arg0) {
|
|
137
137
|
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
138
138
|
const len0 = WASM_VECTOR_LEN;
|
|
139
|
-
wasm.
|
|
139
|
+
wasm.__wbg_set_decodedid_bytes(this.__wbg_ptr, ptr0, len0);
|
|
140
140
|
}
|
|
141
141
|
/**
|
|
142
142
|
* The detected format name.
|
|
@@ -145,7 +145,7 @@ export class JsDecodedId {
|
|
|
145
145
|
set format(arg0) {
|
|
146
146
|
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
147
147
|
const len0 = WASM_VECTOR_LEN;
|
|
148
|
-
wasm.
|
|
148
|
+
wasm.__wbg_set_decodedid_format(this.__wbg_ptr, ptr0, len0);
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* The original ID string.
|
|
@@ -154,7 +154,7 @@ export class JsDecodedId {
|
|
|
154
154
|
set original(arg0) {
|
|
155
155
|
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
156
156
|
const len0 = WASM_VECTOR_LEN;
|
|
157
|
-
wasm.
|
|
157
|
+
wasm.__wbg_set_decodedid_original(this.__wbg_ptr, ptr0, len0);
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Random component as string (decimal).
|
|
@@ -163,7 +163,7 @@ export class JsDecodedId {
|
|
|
163
163
|
set randomness(arg0) {
|
|
164
164
|
var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
165
165
|
var len0 = WASM_VECTOR_LEN;
|
|
166
|
-
wasm.
|
|
166
|
+
wasm.__wbg_set_decodedid_randomness(this.__wbg_ptr, ptr0, len0);
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* RFC 3339 formatted time string with timezone (if applicable).
|
|
@@ -172,28 +172,28 @@ export class JsDecodedId {
|
|
|
172
172
|
set time(arg0) {
|
|
173
173
|
var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
174
174
|
var len0 = WASM_VECTOR_LEN;
|
|
175
|
-
wasm.
|
|
175
|
+
wasm.__wbg_set_decodedid_time(this.__wbg_ptr, ptr0, len0);
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Timestamp (if applicable).
|
|
179
|
-
* @param {
|
|
179
|
+
* @param {Timestamp | null} [arg0]
|
|
180
180
|
*/
|
|
181
181
|
set timestamp(arg0) {
|
|
182
182
|
let ptr0 = 0;
|
|
183
183
|
if (!isLikeNone(arg0)) {
|
|
184
|
-
_assertClass(arg0,
|
|
184
|
+
_assertClass(arg0, Timestamp);
|
|
185
185
|
ptr0 = arg0.__destroy_into_raw();
|
|
186
186
|
}
|
|
187
|
-
wasm.
|
|
187
|
+
wasm.__wbg_set_decodedid_timestamp(this.__wbg_ptr, ptr0);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
if (Symbol.dispose)
|
|
190
|
+
if (Symbol.dispose) DecodedId.prototype[Symbol.dispose] = DecodedId.prototype.free;
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* Case format options for JavaScript.
|
|
194
194
|
* @enum {0 | 1}
|
|
195
195
|
*/
|
|
196
|
-
export const
|
|
196
|
+
export const IdCase = Object.freeze({
|
|
197
197
|
/**
|
|
198
198
|
* Lowercase output.
|
|
199
199
|
*/
|
|
@@ -208,7 +208,7 @@ export const JsIdCase = Object.freeze({
|
|
|
208
208
|
* ID format options for JavaScript.
|
|
209
209
|
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6}
|
|
210
210
|
*/
|
|
211
|
-
export const
|
|
211
|
+
export const IdFormat = Object.freeze({
|
|
212
212
|
/**
|
|
213
213
|
* UUID version 1 (time-based with MAC address).
|
|
214
214
|
*/
|
|
@@ -242,23 +242,23 @@ export const JsIdFormat = Object.freeze({
|
|
|
242
242
|
/**
|
|
243
243
|
* Timestamp precision for JavaScript.
|
|
244
244
|
*/
|
|
245
|
-
export class
|
|
245
|
+
export class Timestamp {
|
|
246
246
|
static __wrap(ptr) {
|
|
247
247
|
ptr = ptr >>> 0;
|
|
248
|
-
const obj = Object.create(
|
|
248
|
+
const obj = Object.create(Timestamp.prototype);
|
|
249
249
|
obj.__wbg_ptr = ptr;
|
|
250
|
-
|
|
250
|
+
TimestampFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
251
251
|
return obj;
|
|
252
252
|
}
|
|
253
253
|
__destroy_into_raw() {
|
|
254
254
|
const ptr = this.__wbg_ptr;
|
|
255
255
|
this.__wbg_ptr = 0;
|
|
256
|
-
|
|
256
|
+
TimestampFinalization.unregister(this);
|
|
257
257
|
return ptr;
|
|
258
258
|
}
|
|
259
259
|
free() {
|
|
260
260
|
const ptr = this.__destroy_into_raw();
|
|
261
|
-
wasm.
|
|
261
|
+
wasm.__wbg_timestamp_free(ptr, 0);
|
|
262
262
|
}
|
|
263
263
|
/**
|
|
264
264
|
* Precision type: "ms" for milliseconds, "ns" for nanoseconds.
|
|
@@ -269,7 +269,7 @@ export class JsTimestamp {
|
|
|
269
269
|
let deferred1_1;
|
|
270
270
|
try {
|
|
271
271
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
272
|
-
wasm.
|
|
272
|
+
wasm.__wbg_get_decodedid_original(retptr, this.__wbg_ptr);
|
|
273
273
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
274
274
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
275
275
|
deferred1_0 = r0;
|
|
@@ -289,7 +289,7 @@ export class JsTimestamp {
|
|
|
289
289
|
let deferred1_1;
|
|
290
290
|
try {
|
|
291
291
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
292
|
-
wasm.
|
|
292
|
+
wasm.__wbg_get_decodedid_format(retptr, this.__wbg_ptr);
|
|
293
293
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
294
294
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
295
295
|
deferred1_0 = r0;
|
|
@@ -307,7 +307,7 @@ export class JsTimestamp {
|
|
|
307
307
|
set precision(arg0) {
|
|
308
308
|
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
309
309
|
const len0 = WASM_VECTOR_LEN;
|
|
310
|
-
wasm.
|
|
310
|
+
wasm.__wbg_set_decodedid_original(this.__wbg_ptr, ptr0, len0);
|
|
311
311
|
}
|
|
312
312
|
/**
|
|
313
313
|
* Timestamp value as string (to support u128 for nanoseconds).
|
|
@@ -316,10 +316,10 @@ export class JsTimestamp {
|
|
|
316
316
|
set value(arg0) {
|
|
317
317
|
const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export2, wasm.__wbindgen_export3);
|
|
318
318
|
const len0 = WASM_VECTOR_LEN;
|
|
319
|
-
wasm.
|
|
319
|
+
wasm.__wbg_set_decodedid_format(this.__wbg_ptr, ptr0, len0);
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
if (Symbol.dispose)
|
|
322
|
+
if (Symbol.dispose) Timestamp.prototype[Symbol.dispose] = Timestamp.prototype.free;
|
|
323
323
|
|
|
324
324
|
/**
|
|
325
325
|
* Decodes an ID string and returns its metadata.
|
|
@@ -328,7 +328,7 @@ if (Symbol.dispose) JsTimestamp.prototype[Symbol.dispose] = JsTimestamp.prototyp
|
|
|
328
328
|
*
|
|
329
329
|
* Returns an error string if the ID format is not recognized.
|
|
330
330
|
* @param {string} id
|
|
331
|
-
* @returns {
|
|
331
|
+
* @returns {DecodedId}
|
|
332
332
|
*/
|
|
333
333
|
export function decode_id(id) {
|
|
334
334
|
try {
|
|
@@ -342,7 +342,7 @@ export function decode_id(id) {
|
|
|
342
342
|
if (r2) {
|
|
343
343
|
throw takeObject(r1);
|
|
344
344
|
}
|
|
345
|
-
return
|
|
345
|
+
return DecodedId.__wrap(r0);
|
|
346
346
|
} finally {
|
|
347
347
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
348
348
|
}
|
|
@@ -356,9 +356,9 @@ export function decode_id(id) {
|
|
|
356
356
|
* # Errors
|
|
357
357
|
*
|
|
358
358
|
* Returns an error string if generation fails (e.g., invalid count).
|
|
359
|
-
* @param {
|
|
359
|
+
* @param {IdFormat} format
|
|
360
360
|
* @param {number} count
|
|
361
|
-
* @param {
|
|
361
|
+
* @param {IdCase} _case
|
|
362
362
|
* @returns {string[]}
|
|
363
363
|
*/
|
|
364
364
|
export function generate_ids(format, count, _case) {
|
|
@@ -540,12 +540,12 @@ function __wbg_get_imports() {
|
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
const
|
|
543
|
+
const DecodedIdFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
544
544
|
? { register: () => {}, unregister: () => {} }
|
|
545
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
546
|
-
const
|
|
545
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_decodedid_free(ptr >>> 0, 1));
|
|
546
|
+
const TimestampFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
547
547
|
? { register: () => {}, unregister: () => {} }
|
|
548
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
548
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_timestamp_free(ptr >>> 0, 1));
|
|
549
549
|
|
|
550
550
|
function addHeapObject(obj) {
|
|
551
551
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
package/id_generator_bg.wasm
CHANGED
|
Binary file
|