Lacus :: cpf-fmt

Utility function to format CNPJ (Brazilian personal ID).
Browser Support
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
Installation
$ npm install --save @lacussoft/cpf-fmt
$ bun add @lacussoft/cpf-fmt
Import
import cpfFmt from '@lacussoft/cpf-fmt'
const cpfFmt = require('@lacussoft/cpf-fmt')
or import it through your HTML file, using CDN:
<script src="https://cdn.jsdelivr.net/npm/@lacussoft/cpf-fmt@latest/dist/cpf-fmt.min.js"></script>
Usage
const cpf = '47844241055'
cpfFmt(cpf)
cpfFmt(cpf, {
hidden: true
})
cpfFmt(cpf, {
delimiters: {
dot: '',
dash: '_'
}
})
Formatting options
cpfFmt(cpf, {
delimiters: {
dot: '.',
dash: '-',
},
escape: false,
hidden: false,
hiddenKey: '*',
hiddenRange: {
start: 3,
end: 10,
},
onFail(value) {
return value
}
})
Contribution & Support
We welcome contributions! Please see our Contributing Guidelines for details. But if you find this project helpful, please consider:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Changelog
See CHANGELOG for a list of changes and version history.
Made with ❤️ by Lacus Solutions