Commit Inicial.

This commit is contained in:
Leandro Costa 2022-02-01 17:09:16 -03:00
parent 337d192710
commit 5d307207d9
3 changed files with 44 additions and 22 deletions

View file

@ -1,29 +1,14 @@
# README # # README #
This README would normally document whatever steps are necessary to get your application up and running. Biblioteca com funções para formatação de dados.
### What is this repository for? ### ### Exemplos
* Quick summary ```js
* Version import { formatarCep } from 'lhmask';
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
### How do I get set up? ### console.log(formatarCep('12345000'));
* Summary of set up // logs: 12.345-000
* Configuration
* Dependencies
* Database configuration
* How to run tests
* Deployment instructions
### Contribution guidelines ### ```
* Writing tests
* Code review
* Other guidelines
### Who do I talk to? ###
* Repo owner or admin
* Other community or team contact

20
package.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "lhmask",
"version": "1.0.0",
"description": "Biblioteca com funções para formatação de dados.",
"main": "src/lhmask.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@bitbucket.org/leandro_costa/lhmask.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://bitbucket.org/leandro_costa/lhmask/issues"
},
"homepage": "https://bitbucket.org/leandro_costa/lhmask#readme"
}

17
src/lhmask.js Normal file
View file

@ -0,0 +1,17 @@
module.exports = {
// Entrada: 12345000 Saída: 12.345-000
formatarCep(txt) {
const soNumeros = e.target.value.replace(/[^\d]/g, '')
if (!soNumeros) onChange(soNumeros);
let cep = '';
cep += soNumeros.slice(0, 2);
if (soNumeros.length > 2)
cep += '.' + soNumeros.slice(2, 5);
if (soNumeros.length > 5)
cep += '-' + soNumeros.slice(5, 8);
return cep;
}
}