Comparing version 1.3.0 to 1.3.1
@@ -448,3 +448,9 @@ "use strict"; | ||
if (Array.isArray(ie)) { | ||
return ie.map(function (i) { return validar(i, estado); }); | ||
var retorno_1 = true; | ||
ie.forEach(function (i) { | ||
if (!validar(i, estado)) { | ||
retorno_1 = false; | ||
} | ||
}); | ||
return retorno_1; | ||
} | ||
@@ -462,3 +468,8 @@ if (typeof ie !== 'string') { | ||
if (estado === '') { | ||
return lookup(ie); | ||
if (lookup(ie)) { | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
@@ -641,10 +652,5 @@ if (/^\d+$/.test(ie) || estado === 'sp') { | ||
} | ||
function calculoTrivial(valor, base, validarTamanho) { | ||
if (base === void 0) { base = null; } | ||
if (validarTamanho === void 0) { validarTamanho = null; } | ||
return valor === calculoTrivialGenerate(valor); | ||
} | ||
function calculoTrivialGenerate(valor, base, validarTamanho) { | ||
if (base === void 0) { base = null; } | ||
if (validarTamanho === void 0) { validarTamanho = null; } | ||
if (validarTamanho === void 0) { validarTamanho = false; } | ||
if (!validarTamanho && tamanhoNaoE(valor)) { | ||
@@ -651,0 +657,0 @@ return false; |
@@ -303,3 +303,8 @@ "use strict"; | ||
// Let's retrieve the first user character in the queue of characters we have left | ||
var _a = rawValueArr.shift(), rawValueChar = _a.char, isNew = _a.isNew; | ||
var shift = rawValueArr.shift(); | ||
var rawValueChar = void 0, isNew = void 0; | ||
if (shift) { | ||
rawValueChar = shift.char; | ||
isNew = shift.isNew; | ||
} | ||
// If the character we got from the user input is a placeholder character (which happens | ||
@@ -306,0 +311,0 @@ // regularly because user input could be something like (540) 90_-____, which includes |
@@ -61,2 +61,3 @@ "use strict"; | ||
} | ||
return false; | ||
} | ||
@@ -63,0 +64,0 @@ exports.allNumbersAreSame = allNumbersAreSame; |
{ | ||
"name": "js-brasil", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Javascript Utils para Brasil (cpf, cnpj...)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -38,3 +38,3 @@ import { ESTADOS_SIGLA } from './estados'; | ||
function rand(length: number, ...ranges: (any[] | { charCodeAt: (arg0: number) => void; }[])[]) { | ||
function rand(length: number, ...ranges: any[]) { | ||
var str = ""; // the string (initialized to "") | ||
@@ -41,0 +41,0 @@ while (length--) { // repeat this length of times |
@@ -555,3 +555,3 @@ import { allNumbersAreSame } from "./utils"; | ||
export function validar(ie: string, estado: any) { | ||
export function validar(ie: string | Array<string>, estado: any) { | ||
if (eIndefinido(estado) || estado === null) { | ||
@@ -572,3 +572,9 @@ estado = ''; | ||
if (Array.isArray(ie)) { | ||
return ie.map(function (i) { return validar(i, estado); }); | ||
let retorno = true; | ||
ie.forEach(function (i) { | ||
if(!validar(i, estado)) { | ||
retorno = false; | ||
} | ||
}); | ||
return retorno; | ||
} | ||
@@ -580,3 +586,3 @@ | ||
if(!allNumbersAreSame(ie)){ | ||
if (!allNumbersAreSame(ie)) { | ||
return new Error('ie com todos dígitos iguais'); | ||
@@ -592,3 +598,7 @@ } | ||
if (estado === '') { | ||
return lookup(ie); | ||
if (lookup(ie)) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -684,3 +694,3 @@ | ||
textMask: [/\d/, /\d/, '.', /\d/, /\d/, /\d/, '.', /\d/, /\d/, /\d/, '-', /\d/], | ||
textMaskFunction: function mask(userInput: { match: (arg0: RegExp) => void; }) { | ||
textMaskFunction: function mask(userInput: any) { | ||
const numbers: any = userInput.match(/\d/g); | ||
@@ -788,8 +798,3 @@ let numberLength = 0; | ||
function calculoTrivial(valor: any, base = null, validarTamanho = null) { | ||
return valor === calculoTrivialGenerate(valor); | ||
} | ||
function calculoTrivialGenerate(valor: any, base = null, validarTamanho = null) { | ||
function calculoTrivialGenerate(valor: any, base: any = null, validarTamanho = false) { | ||
if (!validarTamanho && tamanhoNaoE(valor)) { | ||
@@ -801,3 +806,3 @@ return false; | ||
} | ||
if(!base){ | ||
if (!base) { | ||
base = primeiros(valor); | ||
@@ -804,0 +809,0 @@ } |
@@ -357,3 +357,8 @@ import { isArray, processCaretTraps } from './utils'; | ||
// Let's retrieve the first user character in the queue of characters we have left | ||
const { char: rawValueChar, isNew } = rawValueArr.shift() | ||
const shift = rawValueArr.shift(); | ||
let rawValueChar: string, isNew: boolean; | ||
if (shift) { | ||
rawValueChar = shift.char; | ||
isNew = shift.isNew; | ||
} | ||
@@ -360,0 +365,0 @@ // If the character we got from the user input is a placeholder character (which happens |
@@ -35,3 +35,3 @@ export function isPresent(obj: any): boolean { | ||
export const modulo11 = (string: { substring: (arg0: number, arg1: number) => string; }, size: number, mod: number) => { | ||
export const modulo11 = (string: string, size: number, mod: number) => { | ||
let soma = 0; | ||
@@ -65,6 +65,7 @@ for (let i = 1; i <= size; i++) { | ||
} | ||
return false; | ||
} | ||
export function getAllDigits(input: { match: (arg0: RegExp) => { join: (arg0: string) => void; }; }) { | ||
export function getAllDigits(input: string) { | ||
return input.match(/\d/g).join(""); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
849203
14287