JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q32376F
  • License MIT

Can to convert a value for a brazilian CEP's format

Package Exports

  • kd-utils-rc
  • kd-utils-rc/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (kd-utils-rc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Funções úteis para formatação brasileira

Este pacote tem o objetivo de auxiliar, de maneira simples, na manipulação de alguns formatos de números de documentos e códigos úteis usados no Brasil

npm package version npm npm bundle size npm

Instalação

    npm i kd-utils-rc

Uso

    import { formatCep } from 'kd-utils-rc';

Funções

formatCep(value: string): string

  • Formata um valor para um formato de CEP XXXXX-XXX
    formatCep('12345678'); // => 12435-678
    formatCep('12ab45678'); // => 12435-678
    formatCep('12ab456789'); // => 12435-678
    formatCep('00000000'); // => 00000-000
    formatCep(''); // => 00000-000
    formatCep(null); // => 00000-000

formatCpf(value: string): string

  • Formata um valor para um formato de CPF XXX.XXX.XXX-XX
    formatCpf('12345678901'); // => 123.456.789-01
    formatCpf('00000000000'); // => 000.000.000-00

formatCnpj(value: string): string

  • Formata um valor para um formato de CNPJ XX.XXX.XXX/XXXX-XX
    formatCnpj('12345678901234'); // => 12.345.678/9012-34
    formatCnpj('00000000000000'); // => 00.000.000/0000-00

formatMobilePhone(value: string): string

  • Formata um valor para um formato de Telefone Celular (XXX) X XXXX-XXXX
    formatMobilePhone('123456789012'); // => (123) 4 5678-9012
    formatMobilePhone('000000000000'); // => (000) 0 0000-0000

formatLandLine(value: string): string

  • Formata um valor para um formato de Telefone Fixo (XXX) XXXX-XXXX
    formatLandLine('12345678901'); // => (123) 4567-8901
    formatLandLine('00000000000'); // => (000) 0000-0000

removeCharacter(value: string, characteresToRemove: string): string

  • Substitui os caracteres em valor de acordo com o solicitado no parâmetro characteresToRemove
    removeCharacter('1234#@567@8,901', '#@'); // => 12345678,901
    removeCharacter(null, 'aˆ*&j'); // => null
    removeCharacter('1234#@567@8,901', null); // => 1234#@567@8,901