pix-utils-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

💸 pix-utils-js

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ção Parametro Retorno
identify input: {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ção Parametro Retorno
validate input: {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ção Parametro Retorno
normalize input: {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

Readme

Keywords

Package Sidebar

Install

npm i pix-utils-js

Weekly Downloads

30

Version

1.0.7

License

MIT

Unpacked Size

17.1 kB

Total Files

9

Last publish

Collaborators

  • paulohenriquesn