@stdbr/wasm 0.3.4
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/LICENSE +201 -0
- package/README.md +22 -0
- package/package.json +32 -0
- package/stdbr_wasm.d.ts +509 -0
- package/stdbr_wasm.js +1786 -0
- package/stdbr_wasm_bg.wasm +0 -0
package/stdbr_wasm.js
ADDED
|
@@ -0,0 +1,1786 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let cachedUint8ArrayMemory0 = null;
|
|
4
|
+
|
|
5
|
+
function getUint8ArrayMemory0() {
|
|
6
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
+
}
|
|
9
|
+
return cachedUint8ArrayMemory0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
+
|
|
14
|
+
cachedTextDecoder.decode();
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let heap = new Array(128).fill(undefined);
|
|
34
|
+
|
|
35
|
+
heap.push(undefined, null, true, false);
|
|
36
|
+
|
|
37
|
+
let heap_next = heap.length;
|
|
38
|
+
|
|
39
|
+
function addHeapObject(obj) {
|
|
40
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
41
|
+
const idx = heap_next;
|
|
42
|
+
heap_next = heap[idx];
|
|
43
|
+
|
|
44
|
+
heap[idx] = obj;
|
|
45
|
+
return idx;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let WASM_VECTOR_LEN = 0;
|
|
49
|
+
|
|
50
|
+
const cachedTextEncoder = new TextEncoder();
|
|
51
|
+
|
|
52
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
53
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
54
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
55
|
+
view.set(buf);
|
|
56
|
+
return {
|
|
57
|
+
read: arg.length,
|
|
58
|
+
written: buf.length
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
64
|
+
|
|
65
|
+
if (realloc === undefined) {
|
|
66
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
67
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
68
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
69
|
+
WASM_VECTOR_LEN = buf.length;
|
|
70
|
+
return ptr;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let len = arg.length;
|
|
74
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
75
|
+
|
|
76
|
+
const mem = getUint8ArrayMemory0();
|
|
77
|
+
|
|
78
|
+
let offset = 0;
|
|
79
|
+
|
|
80
|
+
for (; offset < len; offset++) {
|
|
81
|
+
const code = arg.charCodeAt(offset);
|
|
82
|
+
if (code > 0x7F) break;
|
|
83
|
+
mem[ptr + offset] = code;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (offset !== len) {
|
|
87
|
+
if (offset !== 0) {
|
|
88
|
+
arg = arg.slice(offset);
|
|
89
|
+
}
|
|
90
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
91
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
92
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
93
|
+
|
|
94
|
+
offset += ret.written;
|
|
95
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
WASM_VECTOR_LEN = offset;
|
|
99
|
+
return ptr;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let cachedDataViewMemory0 = null;
|
|
103
|
+
|
|
104
|
+
function getDataViewMemory0() {
|
|
105
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
106
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
107
|
+
}
|
|
108
|
+
return cachedDataViewMemory0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getObject(idx) { return heap[idx]; }
|
|
112
|
+
|
|
113
|
+
function dropObject(idx) {
|
|
114
|
+
if (idx < 132) return;
|
|
115
|
+
heap[idx] = heap_next;
|
|
116
|
+
heap_next = idx;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function takeObject(idx) {
|
|
120
|
+
const ret = getObject(idx);
|
|
121
|
+
dropObject(idx);
|
|
122
|
+
return ret;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Lenient CEP validation (strips non-digit characters first).
|
|
126
|
+
* @param {string} cep
|
|
127
|
+
* @returns {boolean}
|
|
128
|
+
*/
|
|
129
|
+
export function cepIsValid(cep) {
|
|
130
|
+
const ptr0 = passStringToWasm0(cep, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
132
|
+
const ret = wasm.cepIsValid(ptr0, len0);
|
|
133
|
+
return ret !== 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Strict CEP validation (accepts only `#####-###` or `########`).
|
|
138
|
+
* @param {string} cep
|
|
139
|
+
*/
|
|
140
|
+
export function cepIsValidStrict(cep) {
|
|
141
|
+
try {
|
|
142
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
143
|
+
const ptr0 = passStringToWasm0(cep, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
wasm.cepIsValidStrict(retptr, ptr0, len0);
|
|
146
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
147
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
148
|
+
if (r1) {
|
|
149
|
+
throw takeObject(r0);
|
|
150
|
+
}
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Format a CEP string as `#####-###`.
|
|
158
|
+
* Returns `undefined` if the input doesn't contain exactly 8 digits.
|
|
159
|
+
* @param {string} cep
|
|
160
|
+
* @returns {string | undefined}
|
|
161
|
+
*/
|
|
162
|
+
export function cepFormat(cep) {
|
|
163
|
+
try {
|
|
164
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
165
|
+
const ptr0 = passStringToWasm0(cep, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
166
|
+
const len0 = WASM_VECTOR_LEN;
|
|
167
|
+
wasm.cepFormat(retptr, ptr0, len0);
|
|
168
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
169
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
170
|
+
let v2;
|
|
171
|
+
if (r0 !== 0) {
|
|
172
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
173
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
174
|
+
}
|
|
175
|
+
return v2;
|
|
176
|
+
} finally {
|
|
177
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Remove all non-digit characters from a CEP string.
|
|
183
|
+
* @param {string} cep
|
|
184
|
+
* @returns {string}
|
|
185
|
+
*/
|
|
186
|
+
export function cepRemoveSymbols(cep) {
|
|
187
|
+
let deferred2_0;
|
|
188
|
+
let deferred2_1;
|
|
189
|
+
try {
|
|
190
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
191
|
+
const ptr0 = passStringToWasm0(cep, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
193
|
+
wasm.cepRemoveSymbols(retptr, ptr0, len0);
|
|
194
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
195
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
196
|
+
deferred2_0 = r0;
|
|
197
|
+
deferred2_1 = r1;
|
|
198
|
+
return getStringFromWasm0(r0, r1);
|
|
199
|
+
} finally {
|
|
200
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
201
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Generate a random valid CEP as an 8-digit string.
|
|
207
|
+
* @returns {string}
|
|
208
|
+
*/
|
|
209
|
+
export function cepGenerate() {
|
|
210
|
+
let deferred1_0;
|
|
211
|
+
let deferred1_1;
|
|
212
|
+
try {
|
|
213
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
214
|
+
wasm.cepGenerate(retptr);
|
|
215
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
216
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
217
|
+
deferred1_0 = r0;
|
|
218
|
+
deferred1_1 = r1;
|
|
219
|
+
return getStringFromWasm0(r0, r1);
|
|
220
|
+
} finally {
|
|
221
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
222
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Generate a random CEP for a given postal region.
|
|
228
|
+
* @param {PostalRegion} region
|
|
229
|
+
* @returns {string}
|
|
230
|
+
*/
|
|
231
|
+
export function cepGenerateForRegion(region) {
|
|
232
|
+
let deferred1_0;
|
|
233
|
+
let deferred1_1;
|
|
234
|
+
try {
|
|
235
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
236
|
+
wasm.cepGenerateForRegion(retptr, region);
|
|
237
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
238
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
239
|
+
deferred1_0 = r0;
|
|
240
|
+
deferred1_1 = r1;
|
|
241
|
+
return getStringFromWasm0(r0, r1);
|
|
242
|
+
} finally {
|
|
243
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
244
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Generate a random CEP within the range of a given state.
|
|
250
|
+
* @param {State} state
|
|
251
|
+
* @returns {string}
|
|
252
|
+
*/
|
|
253
|
+
export function cepGenerateForState(state) {
|
|
254
|
+
let deferred1_0;
|
|
255
|
+
let deferred1_1;
|
|
256
|
+
try {
|
|
257
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
258
|
+
wasm.cepGenerateForState(retptr, state);
|
|
259
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
260
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
261
|
+
deferred1_0 = r0;
|
|
262
|
+
deferred1_1 = r1;
|
|
263
|
+
return getStringFromWasm0(r0, r1);
|
|
264
|
+
} finally {
|
|
265
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
266
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
271
|
+
ptr = ptr >>> 0;
|
|
272
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Lenient CNPJ validation (strips non-alphanumeric characters first).
|
|
276
|
+
* @param {string} cnpj
|
|
277
|
+
* @returns {boolean}
|
|
278
|
+
*/
|
|
279
|
+
export function cnpjIsValid(cnpj) {
|
|
280
|
+
const ptr0 = passStringToWasm0(cnpj, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
281
|
+
const len0 = WASM_VECTOR_LEN;
|
|
282
|
+
const ret = wasm.cnpjIsValid(ptr0, len0);
|
|
283
|
+
return ret !== 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Strict CNPJ validation (accepts only `XX.XXX.XXX/XXXX-DD` or 14 raw characters).
|
|
288
|
+
* @param {string} cnpj
|
|
289
|
+
*/
|
|
290
|
+
export function cnpjIsValidStrict(cnpj) {
|
|
291
|
+
try {
|
|
292
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
293
|
+
const ptr0 = passStringToWasm0(cnpj, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
294
|
+
const len0 = WASM_VECTOR_LEN;
|
|
295
|
+
wasm.cnpjIsValidStrict(retptr, ptr0, len0);
|
|
296
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
297
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
298
|
+
if (r1) {
|
|
299
|
+
throw takeObject(r0);
|
|
300
|
+
}
|
|
301
|
+
} finally {
|
|
302
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Format a CNPJ string as `XX.XXX.XXX/XXXX-DD`.
|
|
308
|
+
* Returns `undefined` if the input is not a valid 14-character CNPJ.
|
|
309
|
+
* @param {string} cnpj
|
|
310
|
+
* @returns {string | undefined}
|
|
311
|
+
*/
|
|
312
|
+
export function cnpjFormat(cnpj) {
|
|
313
|
+
try {
|
|
314
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
315
|
+
const ptr0 = passStringToWasm0(cnpj, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
317
|
+
wasm.cnpjFormat(retptr, ptr0, len0);
|
|
318
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
319
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
320
|
+
let v2;
|
|
321
|
+
if (r0 !== 0) {
|
|
322
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
323
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
324
|
+
}
|
|
325
|
+
return v2;
|
|
326
|
+
} finally {
|
|
327
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Remove all non-alphanumeric characters from a CNPJ string, uppercase.
|
|
333
|
+
* @param {string} cnpj
|
|
334
|
+
* @returns {string}
|
|
335
|
+
*/
|
|
336
|
+
export function cnpjRemoveSymbols(cnpj) {
|
|
337
|
+
let deferred2_0;
|
|
338
|
+
let deferred2_1;
|
|
339
|
+
try {
|
|
340
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
341
|
+
const ptr0 = passStringToWasm0(cnpj, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
342
|
+
const len0 = WASM_VECTOR_LEN;
|
|
343
|
+
wasm.cnpjRemoveSymbols(retptr, ptr0, len0);
|
|
344
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
345
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
346
|
+
deferred2_0 = r0;
|
|
347
|
+
deferred2_1 = r1;
|
|
348
|
+
return getStringFromWasm0(r0, r1);
|
|
349
|
+
} finally {
|
|
350
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
351
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Generate a random valid CNPJ as a 14-character string.
|
|
357
|
+
* @param {CnpjKind} kind
|
|
358
|
+
* @returns {string}
|
|
359
|
+
*/
|
|
360
|
+
export function cnpjGenerate(kind) {
|
|
361
|
+
let deferred1_0;
|
|
362
|
+
let deferred1_1;
|
|
363
|
+
try {
|
|
364
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
365
|
+
wasm.cnpjGenerate(retptr, kind);
|
|
366
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
367
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
368
|
+
deferred1_0 = r0;
|
|
369
|
+
deferred1_1 = r1;
|
|
370
|
+
return getStringFromWasm0(r0, r1);
|
|
371
|
+
} finally {
|
|
372
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
373
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Compute check digits for a 12-character CNPJ base.
|
|
379
|
+
* Returns `undefined` if the input is invalid.
|
|
380
|
+
* @param {string} base
|
|
381
|
+
* @returns {Uint8Array | undefined}
|
|
382
|
+
*/
|
|
383
|
+
export function cnpjComputeCheckDigits(base) {
|
|
384
|
+
try {
|
|
385
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
386
|
+
const ptr0 = passStringToWasm0(base, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
387
|
+
const len0 = WASM_VECTOR_LEN;
|
|
388
|
+
wasm.cnpjComputeCheckDigits(retptr, ptr0, len0);
|
|
389
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
390
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
391
|
+
let v2;
|
|
392
|
+
if (r0 !== 0) {
|
|
393
|
+
v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
394
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
395
|
+
}
|
|
396
|
+
return v2;
|
|
397
|
+
} finally {
|
|
398
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Lenient CPF validation (strips non-digit characters first).
|
|
404
|
+
* @param {string} cpf
|
|
405
|
+
* @returns {boolean}
|
|
406
|
+
*/
|
|
407
|
+
export function cpfIsValid(cpf) {
|
|
408
|
+
const ptr0 = passStringToWasm0(cpf, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
409
|
+
const len0 = WASM_VECTOR_LEN;
|
|
410
|
+
const ret = wasm.cpfIsValid(ptr0, len0);
|
|
411
|
+
return ret !== 0;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Strict CPF validation (accepts only `###.###.###-##` or `###########`).
|
|
416
|
+
* @param {string} cpf
|
|
417
|
+
*/
|
|
418
|
+
export function cpfIsValidStrict(cpf) {
|
|
419
|
+
try {
|
|
420
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
421
|
+
const ptr0 = passStringToWasm0(cpf, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
422
|
+
const len0 = WASM_VECTOR_LEN;
|
|
423
|
+
wasm.cpfIsValidStrict(retptr, ptr0, len0);
|
|
424
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
425
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
426
|
+
if (r1) {
|
|
427
|
+
throw takeObject(r0);
|
|
428
|
+
}
|
|
429
|
+
} finally {
|
|
430
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Format a CPF string as `###.###.###-##`.
|
|
436
|
+
* Returns `undefined` if the input doesn't contain exactly 11 digits.
|
|
437
|
+
* @param {string} cpf
|
|
438
|
+
* @returns {string | undefined}
|
|
439
|
+
*/
|
|
440
|
+
export function cpfFormat(cpf) {
|
|
441
|
+
try {
|
|
442
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
443
|
+
const ptr0 = passStringToWasm0(cpf, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
444
|
+
const len0 = WASM_VECTOR_LEN;
|
|
445
|
+
wasm.cpfFormat(retptr, ptr0, len0);
|
|
446
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
447
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
448
|
+
let v2;
|
|
449
|
+
if (r0 !== 0) {
|
|
450
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
451
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
452
|
+
}
|
|
453
|
+
return v2;
|
|
454
|
+
} finally {
|
|
455
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Remove all non-digit characters from a CPF string.
|
|
461
|
+
* @param {string} cpf
|
|
462
|
+
* @returns {string}
|
|
463
|
+
*/
|
|
464
|
+
export function cpfRemoveSymbols(cpf) {
|
|
465
|
+
let deferred2_0;
|
|
466
|
+
let deferred2_1;
|
|
467
|
+
try {
|
|
468
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
469
|
+
const ptr0 = passStringToWasm0(cpf, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
470
|
+
const len0 = WASM_VECTOR_LEN;
|
|
471
|
+
wasm.cpfRemoveSymbols(retptr, ptr0, len0);
|
|
472
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
473
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
474
|
+
deferred2_0 = r0;
|
|
475
|
+
deferred2_1 = r1;
|
|
476
|
+
return getStringFromWasm0(r0, r1);
|
|
477
|
+
} finally {
|
|
478
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
479
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Generate a random valid CPF as an 11-digit string.
|
|
485
|
+
* @returns {string}
|
|
486
|
+
*/
|
|
487
|
+
export function cpfGenerate() {
|
|
488
|
+
let deferred1_0;
|
|
489
|
+
let deferred1_1;
|
|
490
|
+
try {
|
|
491
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
492
|
+
wasm.cpfGenerate(retptr);
|
|
493
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
494
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
495
|
+
deferred1_0 = r0;
|
|
496
|
+
deferred1_1 = r1;
|
|
497
|
+
return getStringFromWasm0(r0, r1);
|
|
498
|
+
} finally {
|
|
499
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
500
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Compute check digits for a 9-digit CPF base.
|
|
506
|
+
* Returns `undefined` if the input is invalid.
|
|
507
|
+
* @param {string} base
|
|
508
|
+
* @returns {Uint8Array | undefined}
|
|
509
|
+
*/
|
|
510
|
+
export function cpfComputeCheckDigits(base) {
|
|
511
|
+
try {
|
|
512
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
513
|
+
const ptr0 = passStringToWasm0(base, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
514
|
+
const len0 = WASM_VECTOR_LEN;
|
|
515
|
+
wasm.cpfComputeCheckDigits(retptr, ptr0, len0);
|
|
516
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
517
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
518
|
+
let v2;
|
|
519
|
+
if (r0 !== 0) {
|
|
520
|
+
v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
521
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
522
|
+
}
|
|
523
|
+
return v2;
|
|
524
|
+
} finally {
|
|
525
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Find a municipality by its IBGE code.
|
|
531
|
+
* @param {number} code
|
|
532
|
+
* @returns {Municipio | undefined}
|
|
533
|
+
*/
|
|
534
|
+
export function municipioFromIbgeCode(code) {
|
|
535
|
+
const ret = wasm.municipioFromIbgeCode(code);
|
|
536
|
+
return ret === 0 ? undefined : Municipio.__wrap(ret);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Get the capital of a given state.
|
|
541
|
+
* @param {State} state
|
|
542
|
+
* @returns {Municipio}
|
|
543
|
+
*/
|
|
544
|
+
export function municipioCapitalOf(state) {
|
|
545
|
+
const ret = wasm.municipioCapitalOf(state);
|
|
546
|
+
return Municipio.__wrap(ret);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Returns all municipalities in a given state.
|
|
551
|
+
* @param {State} state
|
|
552
|
+
* @returns {MunicipioList}
|
|
553
|
+
*/
|
|
554
|
+
export function municipiosByState(state) {
|
|
555
|
+
const ret = wasm.municipiosByState(state);
|
|
556
|
+
return MunicipioList.__wrap(ret);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* Find municipalities whose name contains the given substring (case-insensitive).
|
|
561
|
+
* @param {string} query
|
|
562
|
+
* @returns {MunicipioList}
|
|
563
|
+
*/
|
|
564
|
+
export function municipioSearchByName(query) {
|
|
565
|
+
const ptr0 = passStringToWasm0(query, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
566
|
+
const len0 = WASM_VECTOR_LEN;
|
|
567
|
+
const ret = wasm.municipioSearchByName(ptr0, len0);
|
|
568
|
+
return MunicipioList.__wrap(ret);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Total number of municipalities.
|
|
573
|
+
* @returns {number}
|
|
574
|
+
*/
|
|
575
|
+
export function municipioCount() {
|
|
576
|
+
const ret = wasm.municipioCount();
|
|
577
|
+
return ret >>> 0;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @param {string} rg
|
|
582
|
+
* @param {State} uf
|
|
583
|
+
* @returns {boolean}
|
|
584
|
+
*/
|
|
585
|
+
export function rgIsValid(rg, uf) {
|
|
586
|
+
const ptr0 = passStringToWasm0(rg, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
587
|
+
const len0 = WASM_VECTOR_LEN;
|
|
588
|
+
const ret = wasm.rgIsValid(ptr0, len0, uf);
|
|
589
|
+
return ret !== 0;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* @param {string} rg
|
|
594
|
+
* @param {State} uf
|
|
595
|
+
*/
|
|
596
|
+
export function rgIsValidStrict(rg, uf) {
|
|
597
|
+
try {
|
|
598
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
599
|
+
const ptr0 = passStringToWasm0(rg, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
600
|
+
const len0 = WASM_VECTOR_LEN;
|
|
601
|
+
wasm.rgIsValidStrict(retptr, ptr0, len0, uf);
|
|
602
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
603
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
604
|
+
if (r1) {
|
|
605
|
+
throw takeObject(r0);
|
|
606
|
+
}
|
|
607
|
+
} finally {
|
|
608
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* @param {string} rg
|
|
614
|
+
* @param {State} uf
|
|
615
|
+
* @returns {string | undefined}
|
|
616
|
+
*/
|
|
617
|
+
export function rgFormat(rg, uf) {
|
|
618
|
+
try {
|
|
619
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
620
|
+
const ptr0 = passStringToWasm0(rg, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
621
|
+
const len0 = WASM_VECTOR_LEN;
|
|
622
|
+
wasm.rgFormat(retptr, ptr0, len0, uf);
|
|
623
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
624
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
625
|
+
let v2;
|
|
626
|
+
if (r0 !== 0) {
|
|
627
|
+
v2 = getStringFromWasm0(r0, r1).slice();
|
|
628
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
629
|
+
}
|
|
630
|
+
return v2;
|
|
631
|
+
} finally {
|
|
632
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* @param {string} rg
|
|
638
|
+
* @param {State} uf
|
|
639
|
+
* @returns {string}
|
|
640
|
+
*/
|
|
641
|
+
export function rgRemoveSymbols(rg, uf) {
|
|
642
|
+
let deferred2_0;
|
|
643
|
+
let deferred2_1;
|
|
644
|
+
try {
|
|
645
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
646
|
+
const ptr0 = passStringToWasm0(rg, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
647
|
+
const len0 = WASM_VECTOR_LEN;
|
|
648
|
+
wasm.rgRemoveSymbols(retptr, ptr0, len0, uf);
|
|
649
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
650
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
651
|
+
deferred2_0 = r0;
|
|
652
|
+
deferred2_1 = r1;
|
|
653
|
+
return getStringFromWasm0(r0, r1);
|
|
654
|
+
} finally {
|
|
655
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
656
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* @param {string} base
|
|
662
|
+
* @param {State} uf
|
|
663
|
+
* @returns {number | undefined}
|
|
664
|
+
*/
|
|
665
|
+
export function rgComputeCheckDigit(base, uf) {
|
|
666
|
+
const ptr0 = passStringToWasm0(base, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
667
|
+
const len0 = WASM_VECTOR_LEN;
|
|
668
|
+
const ret = wasm.rgComputeCheckDigit(ptr0, len0, uf);
|
|
669
|
+
return ret === 0xFFFFFF ? undefined : ret;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* @param {State} uf
|
|
674
|
+
* @returns {string}
|
|
675
|
+
*/
|
|
676
|
+
export function rgGenerate(uf) {
|
|
677
|
+
let deferred2_0;
|
|
678
|
+
let deferred2_1;
|
|
679
|
+
try {
|
|
680
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
681
|
+
wasm.rgGenerate(retptr, uf);
|
|
682
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
683
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
684
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
685
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
686
|
+
var ptr1 = r0;
|
|
687
|
+
var len1 = r1;
|
|
688
|
+
if (r3) {
|
|
689
|
+
ptr1 = 0; len1 = 0;
|
|
690
|
+
throw takeObject(r2);
|
|
691
|
+
}
|
|
692
|
+
deferred2_0 = ptr1;
|
|
693
|
+
deferred2_1 = len1;
|
|
694
|
+
return getStringFromWasm0(ptr1, len1);
|
|
695
|
+
} finally {
|
|
696
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
697
|
+
wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Get the abbreviation of a state (e.g. "SP").
|
|
703
|
+
* @param {State} state
|
|
704
|
+
* @returns {string}
|
|
705
|
+
*/
|
|
706
|
+
export function stateAbbreviation(state) {
|
|
707
|
+
let deferred1_0;
|
|
708
|
+
let deferred1_1;
|
|
709
|
+
try {
|
|
710
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
711
|
+
wasm.stateAbbreviation(retptr, state);
|
|
712
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
713
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
714
|
+
deferred1_0 = r0;
|
|
715
|
+
deferred1_1 = r1;
|
|
716
|
+
return getStringFromWasm0(r0, r1);
|
|
717
|
+
} finally {
|
|
718
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
719
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Get the full name of a state (e.g. "São Paulo").
|
|
725
|
+
* @param {State} state
|
|
726
|
+
* @returns {string}
|
|
727
|
+
*/
|
|
728
|
+
export function stateName(state) {
|
|
729
|
+
let deferred1_0;
|
|
730
|
+
let deferred1_1;
|
|
731
|
+
try {
|
|
732
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
733
|
+
wasm.stateName(retptr, state);
|
|
734
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
735
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
736
|
+
deferred1_0 = r0;
|
|
737
|
+
deferred1_1 = r1;
|
|
738
|
+
return getStringFromWasm0(r0, r1);
|
|
739
|
+
} finally {
|
|
740
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
741
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Get the geographic region of a state.
|
|
747
|
+
* @param {State} state
|
|
748
|
+
* @returns {Region}
|
|
749
|
+
*/
|
|
750
|
+
export function stateRegion(state) {
|
|
751
|
+
const ret = wasm.stateRegion(state);
|
|
752
|
+
return ret;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Parse a state from its two-letter abbreviation (case-insensitive).
|
|
757
|
+
* @param {string} abbr
|
|
758
|
+
* @returns {State | undefined}
|
|
759
|
+
*/
|
|
760
|
+
export function stateFromAbbreviation(abbr) {
|
|
761
|
+
const ptr0 = passStringToWasm0(abbr, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
762
|
+
const len0 = WASM_VECTOR_LEN;
|
|
763
|
+
const ret = wasm.stateFromAbbreviation(ptr0, len0);
|
|
764
|
+
return ret === 27 ? undefined : ret;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
768
|
+
ptr = ptr >>> 0;
|
|
769
|
+
const mem = getDataViewMemory0();
|
|
770
|
+
const result = [];
|
|
771
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
772
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
773
|
+
}
|
|
774
|
+
return result;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Returns all 27 Brazilian states.
|
|
778
|
+
* @returns {any[]}
|
|
779
|
+
*/
|
|
780
|
+
export function allStates() {
|
|
781
|
+
try {
|
|
782
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
783
|
+
wasm.allStates(retptr);
|
|
784
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
785
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
786
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
787
|
+
wasm.__wbindgen_export3(r0, r1 * 4, 4);
|
|
788
|
+
return v1;
|
|
789
|
+
} finally {
|
|
790
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* @enum {0 | 1}
|
|
796
|
+
*/
|
|
797
|
+
export const CnpjKind = Object.freeze({
|
|
798
|
+
Numeric: 0, "0": "Numeric",
|
|
799
|
+
Alphanumeric: 1, "1": "Alphanumeric",
|
|
800
|
+
});
|
|
801
|
+
/**
|
|
802
|
+
* @enum {0 | 1}
|
|
803
|
+
*/
|
|
804
|
+
export const EstablishmentType = Object.freeze({
|
|
805
|
+
Matriz: 0, "0": "Matriz",
|
|
806
|
+
Filial: 1, "1": "Filial",
|
|
807
|
+
});
|
|
808
|
+
/**
|
|
809
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
|
|
810
|
+
*/
|
|
811
|
+
export const FiscalRegion = Object.freeze({
|
|
812
|
+
Rs: 0, "0": "Rs",
|
|
813
|
+
DfGoMsMtTo: 1, "1": "DfGoMsMtTo",
|
|
814
|
+
AcAmApPaRoRr: 2, "2": "AcAmApPaRoRr",
|
|
815
|
+
CeMaPi: 3, "3": "CeMaPi",
|
|
816
|
+
AlPbPeRn: 4, "4": "AlPbPeRn",
|
|
817
|
+
BaSe: 5, "5": "BaSe",
|
|
818
|
+
Mg: 6, "6": "Mg",
|
|
819
|
+
EsRj: 7, "7": "EsRj",
|
|
820
|
+
Sp: 8, "8": "Sp",
|
|
821
|
+
PrSc: 9, "9": "PrSc",
|
|
822
|
+
});
|
|
823
|
+
/**
|
|
824
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}
|
|
825
|
+
*/
|
|
826
|
+
export const PostalRegion = Object.freeze({
|
|
827
|
+
GranSaoPaulo: 0, "0": "GranSaoPaulo",
|
|
828
|
+
InteriorSaoPaulo: 1, "1": "InteriorSaoPaulo",
|
|
829
|
+
RjEs: 2, "2": "RjEs",
|
|
830
|
+
Mg: 3, "3": "Mg",
|
|
831
|
+
BaSe: 4, "4": "BaSe",
|
|
832
|
+
PeAlPbRn: 5, "5": "PeAlPbRn",
|
|
833
|
+
CePiMaPaAmAcApRr: 6, "6": "CePiMaPaAmAcApRr",
|
|
834
|
+
DfGoToMtMsRo: 7, "7": "DfGoToMtMsRo",
|
|
835
|
+
PrSc: 8, "8": "PrSc",
|
|
836
|
+
Rs: 9, "9": "Rs",
|
|
837
|
+
});
|
|
838
|
+
/**
|
|
839
|
+
* @enum {0 | 1 | 2 | 3 | 4}
|
|
840
|
+
*/
|
|
841
|
+
export const Region = Object.freeze({
|
|
842
|
+
Norte: 0, "0": "Norte",
|
|
843
|
+
Nordeste: 1, "1": "Nordeste",
|
|
844
|
+
CentroOeste: 2, "2": "CentroOeste",
|
|
845
|
+
Sudeste: 3, "3": "Sudeste",
|
|
846
|
+
Sul: 4, "4": "Sul",
|
|
847
|
+
});
|
|
848
|
+
/**
|
|
849
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26}
|
|
850
|
+
*/
|
|
851
|
+
export const State = Object.freeze({
|
|
852
|
+
AC: 0, "0": "AC",
|
|
853
|
+
AL: 1, "1": "AL",
|
|
854
|
+
AM: 2, "2": "AM",
|
|
855
|
+
AP: 3, "3": "AP",
|
|
856
|
+
BA: 4, "4": "BA",
|
|
857
|
+
CE: 5, "5": "CE",
|
|
858
|
+
DF: 6, "6": "DF",
|
|
859
|
+
ES: 7, "7": "ES",
|
|
860
|
+
GO: 8, "8": "GO",
|
|
861
|
+
MA: 9, "9": "MA",
|
|
862
|
+
MG: 10, "10": "MG",
|
|
863
|
+
MS: 11, "11": "MS",
|
|
864
|
+
MT: 12, "12": "MT",
|
|
865
|
+
PA: 13, "13": "PA",
|
|
866
|
+
PB: 14, "14": "PB",
|
|
867
|
+
PE: 15, "15": "PE",
|
|
868
|
+
PI: 16, "16": "PI",
|
|
869
|
+
PR: 17, "17": "PR",
|
|
870
|
+
RJ: 18, "18": "RJ",
|
|
871
|
+
RN: 19, "19": "RN",
|
|
872
|
+
RO: 20, "20": "RO",
|
|
873
|
+
RR: 21, "21": "RR",
|
|
874
|
+
RS: 22, "22": "RS",
|
|
875
|
+
SC: 23, "23": "SC",
|
|
876
|
+
SE: 24, "24": "SE",
|
|
877
|
+
SP: 25, "25": "SP",
|
|
878
|
+
TO: 26, "26": "TO",
|
|
879
|
+
});
|
|
880
|
+
|
|
881
|
+
const CepFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
882
|
+
? { register: () => {}, unregister: () => {} }
|
|
883
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_cep_free(ptr >>> 0, 1));
|
|
884
|
+
|
|
885
|
+
export class Cep {
|
|
886
|
+
|
|
887
|
+
static __wrap(ptr) {
|
|
888
|
+
ptr = ptr >>> 0;
|
|
889
|
+
const obj = Object.create(Cep.prototype);
|
|
890
|
+
obj.__wbg_ptr = ptr;
|
|
891
|
+
CepFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
892
|
+
return obj;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
__destroy_into_raw() {
|
|
896
|
+
const ptr = this.__wbg_ptr;
|
|
897
|
+
this.__wbg_ptr = 0;
|
|
898
|
+
CepFinalization.unregister(this);
|
|
899
|
+
return ptr;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
free() {
|
|
903
|
+
const ptr = this.__destroy_into_raw();
|
|
904
|
+
wasm.__wbg_cep_free(ptr, 0);
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Parse a CEP string (accepts `#####-###` or `########`).
|
|
908
|
+
* @param {string} raw
|
|
909
|
+
* @returns {Cep}
|
|
910
|
+
*/
|
|
911
|
+
static parse(raw) {
|
|
912
|
+
try {
|
|
913
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
914
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
915
|
+
const len0 = WASM_VECTOR_LEN;
|
|
916
|
+
wasm.cep_parse(retptr, ptr0, len0);
|
|
917
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
918
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
919
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
920
|
+
if (r2) {
|
|
921
|
+
throw takeObject(r1);
|
|
922
|
+
}
|
|
923
|
+
return Cep.__wrap(r0);
|
|
924
|
+
} finally {
|
|
925
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Generate a random valid CEP.
|
|
930
|
+
* @returns {Cep}
|
|
931
|
+
*/
|
|
932
|
+
static generate() {
|
|
933
|
+
const ret = wasm.cep_generate();
|
|
934
|
+
return Cep.__wrap(ret);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Generate a random CEP for a given postal region.
|
|
938
|
+
* @param {PostalRegion} region
|
|
939
|
+
* @returns {Cep}
|
|
940
|
+
*/
|
|
941
|
+
static generateForRegion(region) {
|
|
942
|
+
const ret = wasm.cep_generateForRegion(region);
|
|
943
|
+
return Cep.__wrap(ret);
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Generate a random CEP within the range of a given state.
|
|
947
|
+
* @param {State} state
|
|
948
|
+
* @returns {Cep}
|
|
949
|
+
*/
|
|
950
|
+
static generateForState(state) {
|
|
951
|
+
const ret = wasm.cep_generateForState(state);
|
|
952
|
+
return Cep.__wrap(ret);
|
|
953
|
+
}
|
|
954
|
+
/**
|
|
955
|
+
* Unformatted 8-digit string.
|
|
956
|
+
* @returns {string}
|
|
957
|
+
*/
|
|
958
|
+
asStr() {
|
|
959
|
+
let deferred1_0;
|
|
960
|
+
let deferred1_1;
|
|
961
|
+
try {
|
|
962
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
963
|
+
wasm.cep_asStr(retptr, this.__wbg_ptr);
|
|
964
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
965
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
966
|
+
deferred1_0 = r0;
|
|
967
|
+
deferred1_1 = r1;
|
|
968
|
+
return getStringFromWasm0(r0, r1);
|
|
969
|
+
} finally {
|
|
970
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
971
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Formatted as `#####-###`.
|
|
976
|
+
* @returns {string}
|
|
977
|
+
*/
|
|
978
|
+
formatted() {
|
|
979
|
+
let deferred1_0;
|
|
980
|
+
let deferred1_1;
|
|
981
|
+
try {
|
|
982
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
983
|
+
wasm.cep_formatted(retptr, this.__wbg_ptr);
|
|
984
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
985
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
986
|
+
deferred1_0 = r0;
|
|
987
|
+
deferred1_1 = r1;
|
|
988
|
+
return getStringFromWasm0(r0, r1);
|
|
989
|
+
} finally {
|
|
990
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
991
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Masked as `#####-***`.
|
|
996
|
+
* @returns {string}
|
|
997
|
+
*/
|
|
998
|
+
masked() {
|
|
999
|
+
let deferred1_0;
|
|
1000
|
+
let deferred1_1;
|
|
1001
|
+
try {
|
|
1002
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1003
|
+
wasm.cep_masked(retptr, this.__wbg_ptr);
|
|
1004
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1005
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1006
|
+
deferred1_0 = r0;
|
|
1007
|
+
deferred1_1 = r1;
|
|
1008
|
+
return getStringFromWasm0(r0, r1);
|
|
1009
|
+
} finally {
|
|
1010
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1011
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Postal region derived from the 1st digit.
|
|
1016
|
+
* @returns {PostalRegion}
|
|
1017
|
+
*/
|
|
1018
|
+
get postalRegion() {
|
|
1019
|
+
const ret = wasm.cep_postalRegion(this.__wbg_ptr);
|
|
1020
|
+
return ret;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* State lookup by CEP range. Returns the state abbreviation or undefined.
|
|
1024
|
+
* @returns {State | undefined}
|
|
1025
|
+
*/
|
|
1026
|
+
get state() {
|
|
1027
|
+
const ret = wasm.cep_state(this.__wbg_ptr);
|
|
1028
|
+
return ret === 27 ? undefined : ret;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
if (Symbol.dispose) Cep.prototype[Symbol.dispose] = Cep.prototype.free;
|
|
1032
|
+
|
|
1033
|
+
const CnpjFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1034
|
+
? { register: () => {}, unregister: () => {} }
|
|
1035
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_cnpj_free(ptr >>> 0, 1));
|
|
1036
|
+
|
|
1037
|
+
export class Cnpj {
|
|
1038
|
+
|
|
1039
|
+
static __wrap(ptr) {
|
|
1040
|
+
ptr = ptr >>> 0;
|
|
1041
|
+
const obj = Object.create(Cnpj.prototype);
|
|
1042
|
+
obj.__wbg_ptr = ptr;
|
|
1043
|
+
CnpjFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1044
|
+
return obj;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
__destroy_into_raw() {
|
|
1048
|
+
const ptr = this.__wbg_ptr;
|
|
1049
|
+
this.__wbg_ptr = 0;
|
|
1050
|
+
CnpjFinalization.unregister(this);
|
|
1051
|
+
return ptr;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
free() {
|
|
1055
|
+
const ptr = this.__destroy_into_raw();
|
|
1056
|
+
wasm.__wbg_cnpj_free(ptr, 0);
|
|
1057
|
+
}
|
|
1058
|
+
/**
|
|
1059
|
+
* Parse a CNPJ string (accepts `XX.XXX.XXX/XXXX-DD` or 14 raw characters).
|
|
1060
|
+
* @param {string} raw
|
|
1061
|
+
* @returns {Cnpj}
|
|
1062
|
+
*/
|
|
1063
|
+
static parse(raw) {
|
|
1064
|
+
try {
|
|
1065
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1066
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1067
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1068
|
+
wasm.cnpj_parse(retptr, ptr0, len0);
|
|
1069
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1070
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1071
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1072
|
+
if (r2) {
|
|
1073
|
+
throw takeObject(r1);
|
|
1074
|
+
}
|
|
1075
|
+
return Cnpj.__wrap(r0);
|
|
1076
|
+
} finally {
|
|
1077
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Generate a random valid CNPJ.
|
|
1082
|
+
* @param {CnpjKind} kind
|
|
1083
|
+
* @returns {Cnpj}
|
|
1084
|
+
*/
|
|
1085
|
+
static generate(kind) {
|
|
1086
|
+
const ret = wasm.cnpj_generate(kind);
|
|
1087
|
+
return Cnpj.__wrap(ret);
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Generate a random valid CNPJ with ordem "0001" (Matriz).
|
|
1091
|
+
* @param {CnpjKind} kind
|
|
1092
|
+
* @returns {Cnpj}
|
|
1093
|
+
*/
|
|
1094
|
+
static generateMatriz(kind) {
|
|
1095
|
+
const ret = wasm.cnpj_generateMatriz(kind);
|
|
1096
|
+
return Cnpj.__wrap(ret);
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Unformatted 14-character string.
|
|
1100
|
+
* @returns {string}
|
|
1101
|
+
*/
|
|
1102
|
+
asStr() {
|
|
1103
|
+
let deferred1_0;
|
|
1104
|
+
let deferred1_1;
|
|
1105
|
+
try {
|
|
1106
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1107
|
+
wasm.cnpj_asStr(retptr, this.__wbg_ptr);
|
|
1108
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1109
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1110
|
+
deferred1_0 = r0;
|
|
1111
|
+
deferred1_1 = r1;
|
|
1112
|
+
return getStringFromWasm0(r0, r1);
|
|
1113
|
+
} finally {
|
|
1114
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1115
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Formatted as `XX.XXX.XXX/XXXX-DD`.
|
|
1120
|
+
* @returns {string}
|
|
1121
|
+
*/
|
|
1122
|
+
formatted() {
|
|
1123
|
+
let deferred1_0;
|
|
1124
|
+
let deferred1_1;
|
|
1125
|
+
try {
|
|
1126
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1127
|
+
wasm.cnpj_formatted(retptr, this.__wbg_ptr);
|
|
1128
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1129
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1130
|
+
deferred1_0 = r0;
|
|
1131
|
+
deferred1_1 = r1;
|
|
1132
|
+
return getStringFromWasm0(r0, r1);
|
|
1133
|
+
} finally {
|
|
1134
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1135
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Masked as `XX.XXX.XXX/****-**`.
|
|
1140
|
+
* @returns {string}
|
|
1141
|
+
*/
|
|
1142
|
+
masked() {
|
|
1143
|
+
let deferred1_0;
|
|
1144
|
+
let deferred1_1;
|
|
1145
|
+
try {
|
|
1146
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1147
|
+
wasm.cnpj_masked(retptr, this.__wbg_ptr);
|
|
1148
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1149
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1150
|
+
deferred1_0 = r0;
|
|
1151
|
+
deferred1_1 = r1;
|
|
1152
|
+
return getStringFromWasm0(r0, r1);
|
|
1153
|
+
} finally {
|
|
1154
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1155
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Root (positions 1-8): identifies the company.
|
|
1160
|
+
* @returns {string}
|
|
1161
|
+
*/
|
|
1162
|
+
raiz() {
|
|
1163
|
+
let deferred1_0;
|
|
1164
|
+
let deferred1_1;
|
|
1165
|
+
try {
|
|
1166
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1167
|
+
wasm.cnpj_raiz(retptr, this.__wbg_ptr);
|
|
1168
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1169
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1170
|
+
deferred1_0 = r0;
|
|
1171
|
+
deferred1_1 = r1;
|
|
1172
|
+
return getStringFromWasm0(r0, r1);
|
|
1173
|
+
} finally {
|
|
1174
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1175
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Order (positions 9-12): identifies the establishment.
|
|
1180
|
+
* @returns {string}
|
|
1181
|
+
*/
|
|
1182
|
+
ordem() {
|
|
1183
|
+
let deferred1_0;
|
|
1184
|
+
let deferred1_1;
|
|
1185
|
+
try {
|
|
1186
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1187
|
+
wasm.cnpj_ordem(retptr, this.__wbg_ptr);
|
|
1188
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1189
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1190
|
+
deferred1_0 = r0;
|
|
1191
|
+
deferred1_1 = r1;
|
|
1192
|
+
return getStringFromWasm0(r0, r1);
|
|
1193
|
+
} finally {
|
|
1194
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1195
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Whether the CNPJ is numeric or alphanumeric.
|
|
1200
|
+
* @returns {CnpjKind}
|
|
1201
|
+
*/
|
|
1202
|
+
get kind() {
|
|
1203
|
+
const ret = wasm.cnpj_kind(this.__wbg_ptr);
|
|
1204
|
+
return ret;
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Whether this is Matriz or Filial.
|
|
1208
|
+
* @returns {EstablishmentType}
|
|
1209
|
+
*/
|
|
1210
|
+
get establishmentType() {
|
|
1211
|
+
const ret = wasm.cnpj_establishmentType(this.__wbg_ptr);
|
|
1212
|
+
return ret;
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* The two check digits as `Uint8Array`.
|
|
1216
|
+
* @returns {Uint8Array}
|
|
1217
|
+
*/
|
|
1218
|
+
get checkDigits() {
|
|
1219
|
+
try {
|
|
1220
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1221
|
+
wasm.cnpj_checkDigits(retptr, this.__wbg_ptr);
|
|
1222
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1223
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1224
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1225
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
1226
|
+
return v1;
|
|
1227
|
+
} finally {
|
|
1228
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (Symbol.dispose) Cnpj.prototype[Symbol.dispose] = Cnpj.prototype.free;
|
|
1233
|
+
|
|
1234
|
+
const CpfFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1235
|
+
? { register: () => {}, unregister: () => {} }
|
|
1236
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_cpf_free(ptr >>> 0, 1));
|
|
1237
|
+
|
|
1238
|
+
export class Cpf {
|
|
1239
|
+
|
|
1240
|
+
static __wrap(ptr) {
|
|
1241
|
+
ptr = ptr >>> 0;
|
|
1242
|
+
const obj = Object.create(Cpf.prototype);
|
|
1243
|
+
obj.__wbg_ptr = ptr;
|
|
1244
|
+
CpfFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1245
|
+
return obj;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
__destroy_into_raw() {
|
|
1249
|
+
const ptr = this.__wbg_ptr;
|
|
1250
|
+
this.__wbg_ptr = 0;
|
|
1251
|
+
CpfFinalization.unregister(this);
|
|
1252
|
+
return ptr;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
free() {
|
|
1256
|
+
const ptr = this.__destroy_into_raw();
|
|
1257
|
+
wasm.__wbg_cpf_free(ptr, 0);
|
|
1258
|
+
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Parse a CPF string (accepts `###.###.###-##` or `###########`).
|
|
1261
|
+
* @param {string} raw
|
|
1262
|
+
* @returns {Cpf}
|
|
1263
|
+
*/
|
|
1264
|
+
static parse(raw) {
|
|
1265
|
+
try {
|
|
1266
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1267
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1268
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1269
|
+
wasm.cpf_parse(retptr, ptr0, len0);
|
|
1270
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1271
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1272
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1273
|
+
if (r2) {
|
|
1274
|
+
throw takeObject(r1);
|
|
1275
|
+
}
|
|
1276
|
+
return Cpf.__wrap(r0);
|
|
1277
|
+
} finally {
|
|
1278
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Generate a random valid CPF.
|
|
1283
|
+
* @returns {Cpf}
|
|
1284
|
+
*/
|
|
1285
|
+
static generate() {
|
|
1286
|
+
const ret = wasm.cpf_generate();
|
|
1287
|
+
return Cpf.__wrap(ret);
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Generate a random valid CPF for a specific fiscal region.
|
|
1291
|
+
* @param {FiscalRegion} region
|
|
1292
|
+
* @returns {Cpf}
|
|
1293
|
+
*/
|
|
1294
|
+
static generateForRegion(region) {
|
|
1295
|
+
const ret = wasm.cpf_generateForRegion(region);
|
|
1296
|
+
return Cpf.__wrap(ret);
|
|
1297
|
+
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Unformatted 11-digit string.
|
|
1300
|
+
* @returns {string}
|
|
1301
|
+
*/
|
|
1302
|
+
asStr() {
|
|
1303
|
+
let deferred1_0;
|
|
1304
|
+
let deferred1_1;
|
|
1305
|
+
try {
|
|
1306
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1307
|
+
wasm.cpf_asStr(retptr, this.__wbg_ptr);
|
|
1308
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1309
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1310
|
+
deferred1_0 = r0;
|
|
1311
|
+
deferred1_1 = r1;
|
|
1312
|
+
return getStringFromWasm0(r0, r1);
|
|
1313
|
+
} finally {
|
|
1314
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1315
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Formatted as `###.###.###-##`.
|
|
1320
|
+
* @returns {string}
|
|
1321
|
+
*/
|
|
1322
|
+
formatted() {
|
|
1323
|
+
let deferred1_0;
|
|
1324
|
+
let deferred1_1;
|
|
1325
|
+
try {
|
|
1326
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1327
|
+
wasm.cpf_formatted(retptr, this.__wbg_ptr);
|
|
1328
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1329
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1330
|
+
deferred1_0 = r0;
|
|
1331
|
+
deferred1_1 = r1;
|
|
1332
|
+
return getStringFromWasm0(r0, r1);
|
|
1333
|
+
} finally {
|
|
1334
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1335
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Masked as `XXX.***.***-XX`.
|
|
1340
|
+
* @returns {string}
|
|
1341
|
+
*/
|
|
1342
|
+
masked() {
|
|
1343
|
+
let deferred1_0;
|
|
1344
|
+
let deferred1_1;
|
|
1345
|
+
try {
|
|
1346
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1347
|
+
wasm.cpf_masked(retptr, this.__wbg_ptr);
|
|
1348
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1349
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1350
|
+
deferred1_0 = r0;
|
|
1351
|
+
deferred1_1 = r1;
|
|
1352
|
+
return getStringFromWasm0(r0, r1);
|
|
1353
|
+
} finally {
|
|
1354
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1355
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Fiscal region derived from the 9th digit.
|
|
1360
|
+
* @returns {FiscalRegion}
|
|
1361
|
+
*/
|
|
1362
|
+
get fiscalRegion() {
|
|
1363
|
+
const ret = wasm.cpf_fiscalRegion(this.__wbg_ptr);
|
|
1364
|
+
return ret;
|
|
1365
|
+
}
|
|
1366
|
+
/**
|
|
1367
|
+
* The two check digits as `Uint8Array`.
|
|
1368
|
+
* @returns {Uint8Array}
|
|
1369
|
+
*/
|
|
1370
|
+
get checkDigits() {
|
|
1371
|
+
try {
|
|
1372
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1373
|
+
wasm.cpf_checkDigits(retptr, this.__wbg_ptr);
|
|
1374
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1375
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1376
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
1377
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
1378
|
+
return v1;
|
|
1379
|
+
} finally {
|
|
1380
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
if (Symbol.dispose) Cpf.prototype[Symbol.dispose] = Cpf.prototype.free;
|
|
1385
|
+
|
|
1386
|
+
const MunicipioFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1387
|
+
? { register: () => {}, unregister: () => {} }
|
|
1388
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_municipio_free(ptr >>> 0, 1));
|
|
1389
|
+
|
|
1390
|
+
export class Municipio {
|
|
1391
|
+
|
|
1392
|
+
static __wrap(ptr) {
|
|
1393
|
+
ptr = ptr >>> 0;
|
|
1394
|
+
const obj = Object.create(Municipio.prototype);
|
|
1395
|
+
obj.__wbg_ptr = ptr;
|
|
1396
|
+
MunicipioFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1397
|
+
return obj;
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
__destroy_into_raw() {
|
|
1401
|
+
const ptr = this.__wbg_ptr;
|
|
1402
|
+
this.__wbg_ptr = 0;
|
|
1403
|
+
MunicipioFinalization.unregister(this);
|
|
1404
|
+
return ptr;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
free() {
|
|
1408
|
+
const ptr = this.__destroy_into_raw();
|
|
1409
|
+
wasm.__wbg_municipio_free(ptr, 0);
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* IBGE 7-digit code.
|
|
1413
|
+
* @returns {number}
|
|
1414
|
+
*/
|
|
1415
|
+
get ibgeCode() {
|
|
1416
|
+
const ret = wasm.municipio_ibgeCode(this.__wbg_ptr);
|
|
1417
|
+
return ret >>> 0;
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Municipality name.
|
|
1421
|
+
* @returns {string}
|
|
1422
|
+
*/
|
|
1423
|
+
get name() {
|
|
1424
|
+
let deferred1_0;
|
|
1425
|
+
let deferred1_1;
|
|
1426
|
+
try {
|
|
1427
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1428
|
+
wasm.municipio_name(retptr, this.__wbg_ptr);
|
|
1429
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1430
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1431
|
+
deferred1_0 = r0;
|
|
1432
|
+
deferred1_1 = r1;
|
|
1433
|
+
return getStringFromWasm0(r0, r1);
|
|
1434
|
+
} finally {
|
|
1435
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1436
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
/**
|
|
1440
|
+
* State this municipality belongs to.
|
|
1441
|
+
* @returns {State}
|
|
1442
|
+
*/
|
|
1443
|
+
get state() {
|
|
1444
|
+
const ret = wasm.municipio_state(this.__wbg_ptr);
|
|
1445
|
+
return ret;
|
|
1446
|
+
}
|
|
1447
|
+
/**
|
|
1448
|
+
* Whether this municipality is a state capital.
|
|
1449
|
+
* @returns {boolean}
|
|
1450
|
+
*/
|
|
1451
|
+
get isCapital() {
|
|
1452
|
+
const ret = wasm.municipio_isCapital(this.__wbg_ptr);
|
|
1453
|
+
return ret !== 0;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
if (Symbol.dispose) Municipio.prototype[Symbol.dispose] = Municipio.prototype.free;
|
|
1457
|
+
|
|
1458
|
+
const MunicipioListFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1459
|
+
? { register: () => {}, unregister: () => {} }
|
|
1460
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_municipiolist_free(ptr >>> 0, 1));
|
|
1461
|
+
/**
|
|
1462
|
+
* Opaque list of municipalities for collection results.
|
|
1463
|
+
*/
|
|
1464
|
+
export class MunicipioList {
|
|
1465
|
+
|
|
1466
|
+
static __wrap(ptr) {
|
|
1467
|
+
ptr = ptr >>> 0;
|
|
1468
|
+
const obj = Object.create(MunicipioList.prototype);
|
|
1469
|
+
obj.__wbg_ptr = ptr;
|
|
1470
|
+
MunicipioListFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1471
|
+
return obj;
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
__destroy_into_raw() {
|
|
1475
|
+
const ptr = this.__wbg_ptr;
|
|
1476
|
+
this.__wbg_ptr = 0;
|
|
1477
|
+
MunicipioListFinalization.unregister(this);
|
|
1478
|
+
return ptr;
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
free() {
|
|
1482
|
+
const ptr = this.__destroy_into_raw();
|
|
1483
|
+
wasm.__wbg_municipiolist_free(ptr, 0);
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Number of municipalities in the list.
|
|
1487
|
+
* @returns {number}
|
|
1488
|
+
*/
|
|
1489
|
+
get count() {
|
|
1490
|
+
const ret = wasm.municipiolist_count(this.__wbg_ptr);
|
|
1491
|
+
return ret >>> 0;
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Get a municipality by index. Returns `undefined` if out of bounds.
|
|
1495
|
+
* @param {number} index
|
|
1496
|
+
* @returns {Municipio | undefined}
|
|
1497
|
+
*/
|
|
1498
|
+
get(index) {
|
|
1499
|
+
const ret = wasm.municipiolist_get(this.__wbg_ptr, index);
|
|
1500
|
+
return ret === 0 ? undefined : Municipio.__wrap(ret);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (Symbol.dispose) MunicipioList.prototype[Symbol.dispose] = MunicipioList.prototype.free;
|
|
1504
|
+
|
|
1505
|
+
const RgFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1506
|
+
? { register: () => {}, unregister: () => {} }
|
|
1507
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_rg_free(ptr >>> 0, 1));
|
|
1508
|
+
|
|
1509
|
+
export class Rg {
|
|
1510
|
+
|
|
1511
|
+
static __wrap(ptr) {
|
|
1512
|
+
ptr = ptr >>> 0;
|
|
1513
|
+
const obj = Object.create(Rg.prototype);
|
|
1514
|
+
obj.__wbg_ptr = ptr;
|
|
1515
|
+
RgFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1516
|
+
return obj;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
__destroy_into_raw() {
|
|
1520
|
+
const ptr = this.__wbg_ptr;
|
|
1521
|
+
this.__wbg_ptr = 0;
|
|
1522
|
+
RgFinalization.unregister(this);
|
|
1523
|
+
return ptr;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
free() {
|
|
1527
|
+
const ptr = this.__destroy_into_raw();
|
|
1528
|
+
wasm.__wbg_rg_free(ptr, 0);
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Parse an RG string for the given UF.
|
|
1532
|
+
* @param {string} raw
|
|
1533
|
+
* @param {State} uf
|
|
1534
|
+
* @returns {Rg}
|
|
1535
|
+
*/
|
|
1536
|
+
static parse(raw, uf) {
|
|
1537
|
+
try {
|
|
1538
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1539
|
+
const ptr0 = passStringToWasm0(raw, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
1540
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1541
|
+
wasm.rg_parse(retptr, ptr0, len0, uf);
|
|
1542
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1543
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1544
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1545
|
+
if (r2) {
|
|
1546
|
+
throw takeObject(r1);
|
|
1547
|
+
}
|
|
1548
|
+
return Rg.__wrap(r0);
|
|
1549
|
+
} finally {
|
|
1550
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Generate a random valid RG. Currently SP only.
|
|
1555
|
+
* @param {State} uf
|
|
1556
|
+
* @returns {Rg}
|
|
1557
|
+
*/
|
|
1558
|
+
static generate(uf) {
|
|
1559
|
+
try {
|
|
1560
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1561
|
+
wasm.rg_generate(retptr, uf);
|
|
1562
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1563
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1564
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
1565
|
+
if (r2) {
|
|
1566
|
+
throw takeObject(r1);
|
|
1567
|
+
}
|
|
1568
|
+
return Rg.__wrap(r0);
|
|
1569
|
+
} finally {
|
|
1570
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Unformatted body.
|
|
1575
|
+
* @returns {string}
|
|
1576
|
+
*/
|
|
1577
|
+
asStr() {
|
|
1578
|
+
let deferred1_0;
|
|
1579
|
+
let deferred1_1;
|
|
1580
|
+
try {
|
|
1581
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1582
|
+
wasm.rg_asStr(retptr, this.__wbg_ptr);
|
|
1583
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1584
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1585
|
+
deferred1_0 = r0;
|
|
1586
|
+
deferred1_1 = r1;
|
|
1587
|
+
return getStringFromWasm0(r0, r1);
|
|
1588
|
+
} finally {
|
|
1589
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1590
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* Formatted per the UF mask.
|
|
1595
|
+
* @returns {string}
|
|
1596
|
+
*/
|
|
1597
|
+
formatted() {
|
|
1598
|
+
let deferred1_0;
|
|
1599
|
+
let deferred1_1;
|
|
1600
|
+
try {
|
|
1601
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1602
|
+
wasm.rg_formatted(retptr, this.__wbg_ptr);
|
|
1603
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1604
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1605
|
+
deferred1_0 = r0;
|
|
1606
|
+
deferred1_1 = r1;
|
|
1607
|
+
return getStringFromWasm0(r0, r1);
|
|
1608
|
+
} finally {
|
|
1609
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1610
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
/**
|
|
1614
|
+
* Masked representation — first 2 digits visible, rest masked.
|
|
1615
|
+
* @returns {string}
|
|
1616
|
+
*/
|
|
1617
|
+
masked() {
|
|
1618
|
+
let deferred1_0;
|
|
1619
|
+
let deferred1_1;
|
|
1620
|
+
try {
|
|
1621
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1622
|
+
wasm.rg_masked(retptr, this.__wbg_ptr);
|
|
1623
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1624
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1625
|
+
deferred1_0 = r0;
|
|
1626
|
+
deferred1_1 = r1;
|
|
1627
|
+
return getStringFromWasm0(r0, r1);
|
|
1628
|
+
} finally {
|
|
1629
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1630
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Body without check digit (SP: 8-digit base; others: full string).
|
|
1635
|
+
* @returns {string}
|
|
1636
|
+
*/
|
|
1637
|
+
body() {
|
|
1638
|
+
let deferred1_0;
|
|
1639
|
+
let deferred1_1;
|
|
1640
|
+
try {
|
|
1641
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1642
|
+
wasm.rg_body(retptr, this.__wbg_ptr);
|
|
1643
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1644
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1645
|
+
deferred1_0 = r0;
|
|
1646
|
+
deferred1_1 = r1;
|
|
1647
|
+
return getStringFromWasm0(r0, r1);
|
|
1648
|
+
} finally {
|
|
1649
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1650
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* @returns {State}
|
|
1655
|
+
*/
|
|
1656
|
+
get uf() {
|
|
1657
|
+
const ret = wasm.rg_uf(this.__wbg_ptr);
|
|
1658
|
+
return ret;
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Check digit (`0..=9`, `10` for SP `'X'`, `undefined` otherwise).
|
|
1662
|
+
* @returns {number | undefined}
|
|
1663
|
+
*/
|
|
1664
|
+
get checkDigit() {
|
|
1665
|
+
const ret = wasm.rg_checkDigit(this.__wbg_ptr);
|
|
1666
|
+
return ret === 0xFFFFFF ? undefined : ret;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
if (Symbol.dispose) Rg.prototype[Symbol.dispose] = Rg.prototype.free;
|
|
1670
|
+
|
|
1671
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
1672
|
+
|
|
1673
|
+
async function __wbg_load(module, imports) {
|
|
1674
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1675
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1676
|
+
try {
|
|
1677
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1678
|
+
|
|
1679
|
+
} catch (e) {
|
|
1680
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
1681
|
+
|
|
1682
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1683
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1684
|
+
|
|
1685
|
+
} else {
|
|
1686
|
+
throw e;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
const bytes = await module.arrayBuffer();
|
|
1692
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1693
|
+
|
|
1694
|
+
} else {
|
|
1695
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1696
|
+
|
|
1697
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1698
|
+
return { instance, module };
|
|
1699
|
+
|
|
1700
|
+
} else {
|
|
1701
|
+
return instance;
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1706
|
+
function __wbg_get_imports() {
|
|
1707
|
+
const imports = {};
|
|
1708
|
+
imports.wbg = {};
|
|
1709
|
+
imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
|
|
1710
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1711
|
+
return addHeapObject(ret);
|
|
1712
|
+
};
|
|
1713
|
+
imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
|
|
1714
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1715
|
+
};
|
|
1716
|
+
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
1717
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1718
|
+
const ret = arg0;
|
|
1719
|
+
return addHeapObject(ret);
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
return imports;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
function __wbg_finalize_init(instance, module) {
|
|
1726
|
+
wasm = instance.exports;
|
|
1727
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
1728
|
+
cachedDataViewMemory0 = null;
|
|
1729
|
+
cachedUint8ArrayMemory0 = null;
|
|
1730
|
+
|
|
1731
|
+
|
|
1732
|
+
|
|
1733
|
+
return wasm;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
function initSync(module) {
|
|
1737
|
+
if (wasm !== undefined) return wasm;
|
|
1738
|
+
|
|
1739
|
+
|
|
1740
|
+
if (typeof module !== 'undefined') {
|
|
1741
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1742
|
+
({module} = module)
|
|
1743
|
+
} else {
|
|
1744
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
const imports = __wbg_get_imports();
|
|
1749
|
+
|
|
1750
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1751
|
+
module = new WebAssembly.Module(module);
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1755
|
+
|
|
1756
|
+
return __wbg_finalize_init(instance, module);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
async function __wbg_init(module_or_path) {
|
|
1760
|
+
if (wasm !== undefined) return wasm;
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
if (typeof module_or_path !== 'undefined') {
|
|
1764
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1765
|
+
({module_or_path} = module_or_path)
|
|
1766
|
+
} else {
|
|
1767
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
if (typeof module_or_path === 'undefined') {
|
|
1772
|
+
module_or_path = new URL('stdbr_wasm_bg.wasm', import.meta.url);
|
|
1773
|
+
}
|
|
1774
|
+
const imports = __wbg_get_imports();
|
|
1775
|
+
|
|
1776
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1777
|
+
module_or_path = fetch(module_or_path);
|
|
1778
|
+
}
|
|
1779
|
+
|
|
1780
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1781
|
+
|
|
1782
|
+
return __wbg_finalize_init(instance, module);
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
export { initSync };
|
|
1786
|
+
export default __wbg_init;
|