npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

malmeida-lib-formatacao

v0.1.4

Published

Esta biblioteca fornece várias funções úteis para formatação e validação de dados, especialmente para o contexto brasileiro. Inclui funções para formatação de datas, CEP, telefones, moedas, CPF, e mais.

Downloads

11

Readme

Minha Biblioteca de Utilidades

Esta biblioteca fornece várias funções úteis para formatação e validação de dados, especialmente para o contexto brasileiro. Inclui funções para formatação de datas, CEP, telefones, moedas, CPF, e mais.

Instalação

Você pode instalar a biblioteca via npm:

npm install malmeida-lib-formatacao

Uso
Importe as funções que você precisa:
import {
  formatDateTime,
  maskCep,
  maskPhone,
  maskCurrency,
  maskCPF,
  maskData,
  maskPorc,
  converterMoedaParaFloat,
  converterFloatParaMoeda,
  maskMoeda,
  maskAre,
  validateCPF,
  maskSafra,
  verificarFormatoData
} from 'malmeida-lib-formatacao';



Funções Disponíveis
formatDateTime(dateString: string): Date
Converte uma string de data em um objeto Date.

maskCep(value: string): string
Formata uma string como um CEP brasileiro.

maskPhone(value: string): string
Formata uma string como um número de telefone brasileiro.

maskCurrency(value: string): string
Formata uma string como um valor monetário brasileiro.

maskCPF(value: string): string
Formata uma string como um CPF brasileiro.

maskData(value: string): string
Formata uma string como uma data no formato DD/MM/YYYY.

maskPorc(value: string): string
Formata uma string como uma porcentagem.

converterMoedaParaFloat(moeda: string): number
Converte uma string formatada como moeda para um valor float.

converterFloatParaMoeda(valorFloat: number, area: boolean): string
Converte um valor float para uma string formatada como moeda brasileira.

maskMoeda(value: string): string
Formata uma string como um valor monetário brasileiro usando a biblioteca Intl.

maskAre(value: string): string
Formata uma string como uma área com quatro casas decimais.

validateCPF(cpf: string): boolean
Valida se um CPF brasileiro é válido.

maskSafra(value: string): string
Formata uma string como uma safra no formato YYYY/YYYY.

verificarFormatoData(data: string): boolean
Verifica se uma string está no formato de data DD/MM/YYYY ou é uma string vazia.





Exemplo de Uso
const cpf = "12345678909";
console.log(maskCPF(cpf)); // Saída: 123.456.789-09
console.log(validateCPF(cpf)); // Saída: true ou false

const cep = "12345678";
console.log(maskCep(cep)); // Saída: 12345-678

const phone = "11987654321";
console.log(maskPhone(phone)); // Saída: (11)98765-4321

const data = "01012020";
console.log(maskData(data)); // Saída: 01/01/2020

const moeda = "123456";
console.log(maskMoeda(moeda)); // Saída: R$ 1.234,56

const safra = "20232024";
console.log(maskSafra(safra)); // Saída: 2023/2024



import { verificarFormatoData } from 'minha-biblioteca-de-utilidades';

const dataValida = "01/01/2020";
console.log(verificarFormatoData(dataValida)); // Saída: true

const dataInvalida = "2020-01-01";
console.log(verificarFormatoData(dataInvalida)); // Saída: false

const dataVazia = "";
console.log(verificarFormatoData(dataVazia)); // Saída: true


Contribuição
Sinta-se à vontade para contribuir com melhorias e novas funcionalidades. Faça um fork deste repositório e envie um pull request com suas alterações.

Licença
Esta biblioteca é distribuída sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.


Adapte conforme necessário para refletir corretamente o nome da sua biblioteca e outros detalhes específicos.