Commit Inicial.
This commit is contained in:
parent
337d192710
commit
5d307207d9
3 changed files with 44 additions and 22 deletions
29
README.md
29
README.md
|
@ -1,29 +1,14 @@
|
|||
# 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
|
||||
* Version
|
||||
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
||||
```js
|
||||
import { formatarCep } from 'lhmask';
|
||||
|
||||
### How do I get set up? ###
|
||||
console.log(formatarCep('12345000'));
|
||||
|
||||
* Summary of set up
|
||||
* Configuration
|
||||
* Dependencies
|
||||
* Database configuration
|
||||
* How to run tests
|
||||
* Deployment instructions
|
||||
// logs: 12.345-000
|
||||
|
||||
### 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
20
package.json
Normal 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
17
src/lhmask.js
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue