New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

@brazilian-utils/brazilian-utils

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brazilian-utils/brazilian-utils - npm Package Compare versions

Comparing version 1.0.0-rc.1 to 1.0.0-rc.2

2

dist/brazilian-utils.cjs.development.js

@@ -478,5 +478,5 @@ 'use strict';

exports.isValidBoleto = isValid$4;
exports.isValidCEP = isValid$1;
exports.isValidCNPJ = isValid$6;
exports.isValidCPF = isValid$5;
exports.isValidCep = isValid$1;
exports.isValidEmail = isValid$3;

@@ -483,0 +483,0 @@ exports.isValidPIS = isValid;

@@ -1,2 +0,2 @@

"use strict";function e(e,r){return e===r.length-1}function r(e){return String(e).replace(/[^\d]/g,"")}function n(e,n){var t=r(e),u="number"==typeof n?Array(t.length).fill(0).map((function(e,r){return n-r})):n;return t.split("").reduce((function(e,r,n){return e+parseInt(r,10)*u[n]}),0)}function t(e){return Array(e).fill(1).reduce((function(e,r){return""+e+Math.random().toString().substr(2,r)}),"")}Object.defineProperty(exports,"__esModule",{value:!0});var u=[3,2,9,8,7,6,5,4,3,2],o=["00000000000","11111111111","22222222222","33333333333","44444444444","55555555555","66666666666","77777777777","88888888888","99999999999"],i={RS:{code:"0",areaCodes:[51,53,54,55]},DF:{code:"1",areaCodes:[61]},GO:{code:"1",areaCodes:[62,64]},MT:{code:"1",areaCodes:[65,66]},MS:{code:"1",areaCodes:[67]},TO:{code:"1",areaCodes:[63]},AM:{code:"2",areaCodes:[92,97]},PA:{code:"2",areaCodes:[91,93,94]},RR:{code:"2",areaCodes:[95]},AP:{code:"2",areaCodes:[96]},AC:{code:"2",areaCodes:[68]},RO:{code:"2",areaCodes:[69]},CE:{code:"3",areaCodes:[85,88]},MA:{code:"3",areaCodes:[98,99]},PI:{code:"3",areaCodes:[86,89]},PB:{code:"4",areaCodes:[83]},PE:{code:"4",areaCodes:[81,87]},AL:{code:"4",areaCodes:[82]},RN:{code:"4",areaCodes:[84]},BA:{code:"5",areaCodes:[71,73,74,75,77]},SE:{code:"5",areaCodes:[79]},MG:{code:"6",areaCodes:[31,32,33,34,35,37,38]},RJ:{code:"7",areaCodes:[21,22,24]},ES:{code:"7",areaCodes:[27,28]},SP:{code:"8",areaCodes:[11,12,13,14,15,16,17,18,19]},PR:{code:"9",areaCodes:[41,42,43,44,45,46]},SC:{code:"9",areaCodes:[47,48,49]}},a=Object.keys(i),c=Object.keys(i).reduce((function(e,r){return e.concat(i[r].areaCodes)}),[]),s=[6,7,8,9],d=[2,3,4,5],f=/^([!#$%&'*+\-/=?^_`{|}~]{0,1}([a-zA-Z0-9][!#$%&'*+\-/=?^_`{|}~.]{0,1})+)@(([a-zA-Z0-9][-.]{0,1})+)([.]{1}[a-zA-Z0-9]+)$/,l=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return n.reduce((function(e,r){return e+r.length}),0)>e},p=[8,12,15],C=[6],g=[{end:9,start:0,index:9},{end:20,start:10,index:20},{end:31,start:21,index:31}],v=[4,14,25],x=[9,20,31,32],h=[2,1],y=[{end:4,start:0},{end:47,start:32},{end:9,start:4},{end:20,start:10},{end:31,start:21}],P=[2,5],S=[8],m=["00000000000","11111111111","22222222222","33333333333","44444444444","55555555555","66666666666","77777777777","88888888888","99999999999"],A=[9,10],b=[1,4],O=[7],N=[11],R=["00000000000000","11111111111111","22222222222222","33333333333333","44444444444444","55555555555555","66666666666666","77777777777777","88888888888888","99999999999999"],M=[12,13],V=[5,4,3,2,9,8,7,6,5,4,3,2],$=[6].concat(V);exports.formatBoleto=function(n){var t=r(n);return t.slice(0,47).split("").reduce((function(r,n,u){var o=""+r+n;if(!e(u,t)){if(v.indexOf(u)>=0)return o+".";if(x.indexOf(u)>=0)return o+" "}return o}),"")},exports.formatCNPJ=function(n){var t=r(n);return t.slice(0,14).split("").reduce((function(r,n,u){var o=""+r+n;if(!e(u,t)){if(b.includes(u))return o+".";if(O.includes(u))return o+"/";if(N.includes(u))return o+"-"}return o}),"")},exports.formatCPF=function(n){var t=r(n);return t.slice(0,11).split("").reduce((function(r,n,u){var o=""+r+n;if(!e(u,t)){if(P.indexOf(u)>=0)return o+".";if(S.indexOf(u)>=0)return o+"-"}return o}),"")},exports.formatJudicialProcess=function(n){return r(n).slice(0,20).split("").reduce((function(r,t,u){var o=""+r+t;if(!e(u,n)){if(p.includes(u))return o+".";if(C.includes(u))return o+"-"}return o}),"")},exports.generateCNPJ=function(){var e=t(12),r=n(e,V)%11,u=(r<2?0:11-r).toString(),o=n(e+u,$)%11;return""+e+u+(o<2?0:11-o).toString()},exports.generateCPF=function(e){var r=e&&a.includes(e)?i[e].code:t(1),u=t(8)+r,o=n(u,10)%11,c=(o<2?0:11-o).toString(),s=n(u+c,11)%11,d=(s<2?0:11-s).toString();return""+u+c.toString()+d.toString()},exports.generateChecksum=n,exports.generateRandomNumber=t,exports.isLastChar=e,exports.isValidBoleto=function(e){if(!e||"string"!=typeof e)return!1;var n,t,u=r(e);return!!function(e){return 47===e.length}(u)&&!!function(e){return g.every((function(r){var n=r.index,t=function(e){var r=e.split("").reverse().reduce((function(e,r,n){var t=parseInt(r,10)*h[n%2];return e+(t>9?1+t%10:t)}),0)%10;return r>0?10-r:0}(e.substring(r.start,r.end));return+e[n]===t}))}(u)&&(t=function(e){var r=2,n=e.split("").reverse().reduce((function(e,n){var t=parseInt(n,10)*r;return r=r<9?r+1:2,e+t}),0)%11;return 0===n||1===n?1:11-n}((n=function(e){return y.reduce((function(r,n){return r+e.substring(n.start,n.end)}),"")}(u)).slice(0,4)+n.slice(5)),+n[4]===t)},exports.isValidCNPJ=function(e){if(!e||"string"!=typeof e)return!1;var t=r(e);return function(e){return/^\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}$/.test(e)}(e)&&!(R.indexOf(t)>=0)&&function(e){var r=[].concat(V);return M.every((function(t){t===M[M.length-1]&&r.unshift(6);var u=n(e.slice(0,t).split("").reduce((function(e,r){return e+r}),""),r)%11;return e[t]===String(u<2?0:11-u)}))}(t)},exports.isValidCPF=function(e){if(!e||"string"!=typeof e)return!1;var t=r(e);return function(e){return/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/.test(e)}(e)&&!function(e){return m.indexOf(e)>=0}(t)&&function(e){return A.every((function(r){var t=n(e.slice(0,r).split("").reduce((function(e,r){return e+r}),""),r+1)%11;return e[r]===String(t<2?0:11-t)}))}(t)},exports.isValidCep=function(e){return!(!e||"string"!=typeof e)&&function(e){return 8===e.length}(r(e))},exports.isValidEmail=function(e){if(!e||"string"!=typeof e)return!1;if(l(318,e))return!1;var r=f.exec(e);if(!r)return!1;var n=r[3],t=r[5];return!l(64,r[1])&&!l(253,n,t)},exports.isValidPIS=function(e){if(!e||"string"!=typeof e)return!1;var r=function(e){return e.replace(/[ ().,*-]/g,"")}(e);if(!function(e){return 11===e.length}(r)||function(e){return o.indexOf(e)>=0}(r)||!function(e){return!!e.match(/^[0-9]+$/)}(r))return!1;var t=n(r.substr(0,r.length-1),u),i=+r.charAt(r.length-1),a=11-t%11;return a===i||10===a&&0===i||11===a&&0===i},exports.isValidPhone=function(e){if(!e||"string"!=typeof e)return!1;var n=r(e);return function(e){return e.length>=10&&e.length<=11}(n)&&function(e){return 10===e.length?d.includes(Number(e.charAt(2))):s.includes(Number(e.charAt(2)))}(n)&&function(e){return c.includes(Number(e.substr(0,2)))}(n)},exports.onlyNumbers=r;
"use strict";function e(e,r){return e===r.length-1}function r(e){return String(e).replace(/[^\d]/g,"")}function n(e,n){var t=r(e),u="number"==typeof n?Array(t.length).fill(0).map((function(e,r){return n-r})):n;return t.split("").reduce((function(e,r,n){return e+parseInt(r,10)*u[n]}),0)}function t(e){return Array(e).fill(1).reduce((function(e,r){return""+e+Math.random().toString().substr(2,r)}),"")}Object.defineProperty(exports,"__esModule",{value:!0});var u=[3,2,9,8,7,6,5,4,3,2],o=["00000000000","11111111111","22222222222","33333333333","44444444444","55555555555","66666666666","77777777777","88888888888","99999999999"],i={RS:{code:"0",areaCodes:[51,53,54,55]},DF:{code:"1",areaCodes:[61]},GO:{code:"1",areaCodes:[62,64]},MT:{code:"1",areaCodes:[65,66]},MS:{code:"1",areaCodes:[67]},TO:{code:"1",areaCodes:[63]},AM:{code:"2",areaCodes:[92,97]},PA:{code:"2",areaCodes:[91,93,94]},RR:{code:"2",areaCodes:[95]},AP:{code:"2",areaCodes:[96]},AC:{code:"2",areaCodes:[68]},RO:{code:"2",areaCodes:[69]},CE:{code:"3",areaCodes:[85,88]},MA:{code:"3",areaCodes:[98,99]},PI:{code:"3",areaCodes:[86,89]},PB:{code:"4",areaCodes:[83]},PE:{code:"4",areaCodes:[81,87]},AL:{code:"4",areaCodes:[82]},RN:{code:"4",areaCodes:[84]},BA:{code:"5",areaCodes:[71,73,74,75,77]},SE:{code:"5",areaCodes:[79]},MG:{code:"6",areaCodes:[31,32,33,34,35,37,38]},RJ:{code:"7",areaCodes:[21,22,24]},ES:{code:"7",areaCodes:[27,28]},SP:{code:"8",areaCodes:[11,12,13,14,15,16,17,18,19]},PR:{code:"9",areaCodes:[41,42,43,44,45,46]},SC:{code:"9",areaCodes:[47,48,49]}},a=Object.keys(i),c=Object.keys(i).reduce((function(e,r){return e.concat(i[r].areaCodes)}),[]),s=[6,7,8,9],d=[2,3,4,5],f=/^([!#$%&'*+\-/=?^_`{|}~]{0,1}([a-zA-Z0-9][!#$%&'*+\-/=?^_`{|}~.]{0,1})+)@(([a-zA-Z0-9][-.]{0,1})+)([.]{1}[a-zA-Z0-9]+)$/,l=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return n.reduce((function(e,r){return e+r.length}),0)>e},p=[8,12,15],C=[6],g=[{end:9,start:0,index:9},{end:20,start:10,index:20},{end:31,start:21,index:31}],v=[4,14,25],x=[9,20,31,32],h=[2,1],y=[{end:4,start:0},{end:47,start:32},{end:9,start:4},{end:20,start:10},{end:31,start:21}],P=[2,5],S=[8],m=["00000000000","11111111111","22222222222","33333333333","44444444444","55555555555","66666666666","77777777777","88888888888","99999999999"],A=[9,10],b=[1,4],O=[7],N=[11],R=["00000000000000","11111111111111","22222222222222","33333333333333","44444444444444","55555555555555","66666666666666","77777777777777","88888888888888","99999999999999"],M=[12,13],V=[5,4,3,2,9,8,7,6,5,4,3,2],E=[6].concat(V);exports.formatBoleto=function(n){var t=r(n);return t.slice(0,47).split("").reduce((function(r,n,u){var o=""+r+n;if(!e(u,t)){if(v.indexOf(u)>=0)return o+".";if(x.indexOf(u)>=0)return o+" "}return o}),"")},exports.formatCNPJ=function(n){var t=r(n);return t.slice(0,14).split("").reduce((function(r,n,u){var o=""+r+n;if(!e(u,t)){if(b.includes(u))return o+".";if(O.includes(u))return o+"/";if(N.includes(u))return o+"-"}return o}),"")},exports.formatCPF=function(n){var t=r(n);return t.slice(0,11).split("").reduce((function(r,n,u){var o=""+r+n;if(!e(u,t)){if(P.indexOf(u)>=0)return o+".";if(S.indexOf(u)>=0)return o+"-"}return o}),"")},exports.formatJudicialProcess=function(n){return r(n).slice(0,20).split("").reduce((function(r,t,u){var o=""+r+t;if(!e(u,n)){if(p.includes(u))return o+".";if(C.includes(u))return o+"-"}return o}),"")},exports.generateCNPJ=function(){var e=t(12),r=n(e,V)%11,u=(r<2?0:11-r).toString(),o=n(e+u,E)%11;return""+e+u+(o<2?0:11-o).toString()},exports.generateCPF=function(e){var r=e&&a.includes(e)?i[e].code:t(1),u=t(8)+r,o=n(u,10)%11,c=(o<2?0:11-o).toString(),s=n(u+c,11)%11,d=(s<2?0:11-s).toString();return""+u+c.toString()+d.toString()},exports.generateChecksum=n,exports.generateRandomNumber=t,exports.isLastChar=e,exports.isValidBoleto=function(e){if(!e||"string"!=typeof e)return!1;var n,t,u=r(e);return!!function(e){return 47===e.length}(u)&&!!function(e){return g.every((function(r){var n=r.index,t=function(e){var r=e.split("").reverse().reduce((function(e,r,n){var t=parseInt(r,10)*h[n%2];return e+(t>9?1+t%10:t)}),0)%10;return r>0?10-r:0}(e.substring(r.start,r.end));return+e[n]===t}))}(u)&&(t=function(e){var r=2,n=e.split("").reverse().reduce((function(e,n){var t=parseInt(n,10)*r;return r=r<9?r+1:2,e+t}),0)%11;return 0===n||1===n?1:11-n}((n=function(e){return y.reduce((function(r,n){return r+e.substring(n.start,n.end)}),"")}(u)).slice(0,4)+n.slice(5)),+n[4]===t)},exports.isValidCEP=function(e){return!(!e||"string"!=typeof e)&&function(e){return 8===e.length}(r(e))},exports.isValidCNPJ=function(e){if(!e||"string"!=typeof e)return!1;var t=r(e);return function(e){return/^\d{2}\.?\d{3}\.?\d{3}\/?\d{4}-?\d{2}$/.test(e)}(e)&&!(R.indexOf(t)>=0)&&function(e){var r=[].concat(V);return M.every((function(t){t===M[M.length-1]&&r.unshift(6);var u=n(e.slice(0,t).split("").reduce((function(e,r){return e+r}),""),r)%11;return e[t]===String(u<2?0:11-u)}))}(t)},exports.isValidCPF=function(e){if(!e||"string"!=typeof e)return!1;var t=r(e);return function(e){return/^\d{3}\.?\d{3}\.?\d{3}-?\d{2}$/.test(e)}(e)&&!function(e){return m.indexOf(e)>=0}(t)&&function(e){return A.every((function(r){var t=n(e.slice(0,r).split("").reduce((function(e,r){return e+r}),""),r+1)%11;return e[r]===String(t<2?0:11-t)}))}(t)},exports.isValidEmail=function(e){if(!e||"string"!=typeof e)return!1;if(l(318,e))return!1;var r=f.exec(e);if(!r)return!1;var n=r[3],t=r[5];return!l(64,r[1])&&!l(253,n,t)},exports.isValidPIS=function(e){if(!e||"string"!=typeof e)return!1;var r=function(e){return e.replace(/[ ().,*-]/g,"")}(e);if(!function(e){return 11===e.length}(r)||function(e){return o.indexOf(e)>=0}(r)||!function(e){return!!e.match(/^[0-9]+$/)}(r))return!1;var t=n(r.substr(0,r.length-1),u),i=+r.charAt(r.length-1),a=11-t%11;return a===i||10===a&&0===i||11===a&&0===i},exports.isValidPhone=function(e){if(!e||"string"!=typeof e)return!1;var n=r(e);return function(e){return e.length>=10&&e.length<=11}(n)&&function(e){return 10===e.length?d.includes(Number(e.charAt(2))):s.includes(Number(e.charAt(2)))}(n)&&function(e){return c.includes(Number(e.substr(0,2)))}(n)},exports.onlyNumbers=r;
//# sourceMappingURL=brazilian-utils.cjs.production.min.js.map

@@ -464,3 +464,3 @@ function isLastChar(index, input) {

export { format$1 as formatBoleto, format$3 as formatCNPJ, format$2 as formatCPF, format as formatJudicialProcess, generate$1 as generateCNPJ, generate as generateCPF, generateChecksum, generateRandomNumber, isLastChar, isValid$4 as isValidBoleto, isValid$6 as isValidCNPJ, isValid$5 as isValidCPF, isValid$1 as isValidCep, isValid$3 as isValidEmail, isValid as isValidPIS, isValid$2 as isValidPhone, onlyNumbers };
export { format$1 as formatBoleto, format$3 as formatCNPJ, format$2 as formatCPF, format as formatJudicialProcess, generate$1 as generateCNPJ, generate as generateCPF, generateChecksum, generateRandomNumber, isLastChar, isValid$4 as isValidBoleto, isValid$1 as isValidCEP, isValid$6 as isValidCNPJ, isValid$5 as isValidCPF, isValid$3 as isValidEmail, isValid as isValidPIS, isValid$2 as isValidPhone, onlyNumbers };
//# sourceMappingURL=brazilian-utils.esm.js.map
export { isValid as isValidPIS } from './pis';
export { isValid as isValidCep } from './cep';
export { isValid as isValidCEP } from './cep';
export { isValid as isValidPhone } from './phone';

@@ -4,0 +4,0 @@ export { isValid as isValidEmail } from './email';

{
"name": "@brazilian-utils/brazilian-utils",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.2",
"main": "dist/index.js",

@@ -18,3 +18,5 @@ "module": "dist/brazilianUtils.esm.js",

"prettify": "prettier --write ./src/**/**/*.ts",
"commit": "npx git-cz"
"commit": "npx git-cz",
"release": "np",
"docs": "docsify serve docs"
},

@@ -58,4 +60,6 @@ "husky": {

"cz-conventional-changelog": "^3.0.2",
"docsify-cli": "^4.4.0",
"husky": "^4.0.7",
"lint-staged": "^9.5.0",
"np": "^5.2.1",
"prettier": "^1.19.1",

@@ -62,0 +66,0 @@ "tsdx": "^0.12.3",

@@ -1,2 +0,2 @@

# :brazil: Brazilian Utils
# πŸ‡§πŸ‡· Brazilian Utils

@@ -7,2 +7,7 @@ [![Build Status](https://travis-ci.org/brazilian-utils/brazilian-utils.svg?branch=master)](https://travis-ci.org/brazilian-utils/brazilian-utils) [![Coverage Status](https://codecov.io/gh/brazilian-utils/brazilian-utils/branch/master/graph/badge.svg)](https://codecov.io/gh/brazilian-utils/brazilian-utils) [![Known Vulnerabilities](https://snyk.io/test/github/brazilian-utils/brazilian-utils/badge.svg?targetFile=package.json)](https://snyk.io/test/github/brazilian-utils/brazilian-utils?targetFile=package.json) [![Maintainability](https://api.codeclimate.com/v1/badges/05d3cd8492ed438bf51d/maintainability)](https://codeclimate.com/github/hyanmandian/brazilian-utils/maintainability) [![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors) [![License: MIT](https://img.shields.io/github/license/hyanmandian/brazilian-utils.svg)](LICENSE)

---
>## We are changing
>After one year of Brazilian Utils and a lot of feedbacks, we decide to refactoring our library to fix issues, create a website and make easier for other developers to contribute. If you use **v0 version**, please, check [v0](https://github.com/brazilian-utils/brazilian-utils/tree/v0) branch.
## Contributors

@@ -9,0 +14,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc