1.0.7 • Published 2 years ago

pix-utils-js v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

💸 pix-utils-js

npm.io npm.io npm.io npm.io

Uma pequena biblioteca que irá te ajudar a lidar com chaves pix

Demo https://pix-key-js-demo.vercel.app/

Instalação

Instale pix-utils-js com npm ou yarn

  npm install pix-utils-js
  yarn add pix-utils-js

Documentação

Identifique uma chave pix

  import { identify } from 'pix-utils-js'
  const { pix, type } = identify({pix: 'test@gmail.com'}) // {pix: 'test@gmail.com', type: 'email'}
FunçãoParametroRetorno
identifyinput: {pix: string}Pix { pix: string, type: 'email' \| 'cpf' \| 'cnpj' \| 'random' \|'phone' \| 'qrcode' }

Validar uma chave pix

  import { validate } from 'pix-utils-js'
  console.log(validate({pix: 'test@gmail.com'})) // true
  console.log(validate({pix: 'test'})) // false
  console.log(validate({pix: 'test@gmail.com', type : 'cpf'})) // false
  console.log(validate({pix: '00020126360014BR.GOV...', type : 'qrcode'})) // true
FunçãoParametroRetorno
validateinput: {pix: string}boolean

Normalizar uma chave pix

  import { normalize } from 'pix-utils-js'
  console.log(normalize({pix: '000.000.000-00'})) // {pix: '00000000000', type: 'cpf'}
  console.log(normalize({pix: '00.000.000/0000-00'})) // {pix: '00000000000000', type: 'cnpj'}
  console.log(normalize({pix: '+55 (11) 0000-0000'})) // {pix: '551100000000', type: 'phone'}
  console.log(normalize({pix: '00020126360014BR.GOV...'})) // {pix: '00020126360014BR.GOV...', type: 'qrcode'}
FunçãoParametroRetorno
normalizeinput: {pix: string}Pix { pix: string, type: 'email' \| 'cpf' \| 'cnpj' \| 'random' \|'phone' \| 'qrcode' }

Rodando os testes

Para rodar os testes, rode o seguinte comando

  npm run test
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago