argous 1.2.200 → 1.2.201
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/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +26 -1
- package/lib/utils/index.ts +25 -1
- package/package.json +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -72,5 +72,6 @@ export declare const storageMeasures: {
|
|
|
72
72
|
exabyte: string;
|
|
73
73
|
};
|
|
74
74
|
export declare const bytesTranslator: (bytes?: number, decimals?: number, binary?: boolean) => object;
|
|
75
|
-
export declare const formatCpfCnpj: (value: string | number) => string;
|
|
75
|
+
export declare const formatCpfCnpj: (value: (string | number)) => string;
|
|
76
76
|
export declare function dataUrlToBlob(dataUrl: string): Blob | undefined;
|
|
77
|
+
export declare function cpfTest(cpf: (string | number)): boolean;
|
package/dist/utils/index.js
CHANGED
|
@@ -82,7 +82,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
82
82
|
return to;
|
|
83
83
|
};
|
|
84
84
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
|
-
exports.dataUrlToBlob = exports.formatCpfCnpj = exports.bytesTranslator = exports.storageMeasures = exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = exports.numbersOnly = exports.formataCpf = exports.useWebSocket = exports.formataTelefone = exports.reduxDispatch = exports.useStore = exports.useModal = exports.useGraph = exports.randomColor = exports.humanFileSize = exports.sanitizaHTML = exports.formataDinheiro = exports.useUpdateEffect = exports.usePrevious = exports.getNumeroFromInitials = exports.getInitials = exports.getRandomColor = exports.printPdf = exports.downloadFromUrl = exports.downloadBase64 = exports.formataNome = exports.addExtraZero = exports.getCookie = exports.widthToCenterVertically = void 0;
|
|
85
|
+
exports.cpfTest = exports.dataUrlToBlob = exports.formatCpfCnpj = exports.bytesTranslator = exports.storageMeasures = exports.confirm = exports.copyToClipboard = exports.toFloat = exports.currencyMask = exports.numbersOnly = exports.formataCpf = exports.useWebSocket = exports.formataTelefone = exports.reduxDispatch = exports.useStore = exports.useModal = exports.useGraph = exports.randomColor = exports.humanFileSize = exports.sanitizaHTML = exports.formataDinheiro = exports.useUpdateEffect = exports.usePrevious = exports.getNumeroFromInitials = exports.getInitials = exports.getRandomColor = exports.printPdf = exports.downloadFromUrl = exports.downloadBase64 = exports.formataNome = exports.addExtraZero = exports.getCookie = exports.widthToCenterVertically = void 0;
|
|
86
86
|
var store_1 = require("./store");
|
|
87
87
|
var api_1 = require("../api");
|
|
88
88
|
var ModalProvider_1 = require("../components/ConfirmModal/ModalProvider");
|
|
@@ -451,3 +451,28 @@ function dataUrlToBlob(dataUrl) {
|
|
|
451
451
|
return blob;
|
|
452
452
|
}
|
|
453
453
|
exports.dataUrlToBlob = dataUrlToBlob;
|
|
454
|
+
function cpfTest(cpf) {
|
|
455
|
+
if (cpf === '00000000000' || !cpf)
|
|
456
|
+
return false;
|
|
457
|
+
if (typeof cpf === 'number')
|
|
458
|
+
cpf = cpf.toString();
|
|
459
|
+
var sum = 0;
|
|
460
|
+
var rest;
|
|
461
|
+
for (var index = 1; index <= 9; index++)
|
|
462
|
+
sum += (parseInt(cpf.substring(index - 1, index)) * (11 - index));
|
|
463
|
+
rest = ((sum * 10) % 11);
|
|
464
|
+
if ((rest === 10) || (rest === 11))
|
|
465
|
+
rest = 0;
|
|
466
|
+
if (rest !== parseInt(cpf.substring(9, 10)))
|
|
467
|
+
return false;
|
|
468
|
+
sum = 0;
|
|
469
|
+
for (var index = 1; index <= 10; index++)
|
|
470
|
+
sum += (parseInt(cpf.substring(index - 1, index)) * (12 - index));
|
|
471
|
+
rest = ((sum * 10) % 11);
|
|
472
|
+
if ((rest === 10) || (rest === 11))
|
|
473
|
+
rest = 0;
|
|
474
|
+
if (rest !== parseInt(cpf.substring(10, 11)))
|
|
475
|
+
return false;
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
exports.cpfTest = cpfTest;
|
package/lib/utils/index.ts
CHANGED
|
@@ -338,7 +338,7 @@ export const bytesTranslator = (bytes: number = 0, decimals: number = 2, binary:
|
|
|
338
338
|
return { type, size };
|
|
339
339
|
};
|
|
340
340
|
|
|
341
|
-
export const formatCpfCnpj = (value: string
|
|
341
|
+
export const formatCpfCnpj = (value: (string|number)) => {
|
|
342
342
|
if (!value) return '';
|
|
343
343
|
if (isNumber(value)) value = value.toString();
|
|
344
344
|
value = value.replace(/[^\d]/g, '');
|
|
@@ -362,4 +362,28 @@ export function dataUrlToBlob(dataUrl: string) {
|
|
|
362
362
|
}
|
|
363
363
|
let blob = new Blob([arrayBuffer], { type: mimeString });
|
|
364
364
|
return blob;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export function cpfTest(cpf: (string|number)) {
|
|
368
|
+
|
|
369
|
+
if (cpf === '00000000000' || !cpf) return false;
|
|
370
|
+
if (typeof cpf === 'number') cpf = cpf.toString();
|
|
371
|
+
|
|
372
|
+
let sum = 0;
|
|
373
|
+
let rest: number;
|
|
374
|
+
|
|
375
|
+
for (let index = 1; index <= 9; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (11 - index));
|
|
376
|
+
rest = ((sum * 10) % 11);
|
|
377
|
+
|
|
378
|
+
if ((rest === 10) || (rest === 11)) rest = 0;
|
|
379
|
+
if (rest !== parseInt(cpf.substring(9, 10))) return false;
|
|
380
|
+
|
|
381
|
+
sum = 0;
|
|
382
|
+
for (let index = 1; index <= 10; index++) sum += (parseInt(cpf.substring(index - 1, index)) * (12 - index));
|
|
383
|
+
rest = ((sum * 10) % 11);
|
|
384
|
+
|
|
385
|
+
if ((rest === 10) || (rest === 11)) rest = 0;
|
|
386
|
+
if (rest !== parseInt(cpf.substring(10, 11))) return false;
|
|
387
|
+
|
|
388
|
+
return true;
|
|
365
389
|
}
|