{"id":26296355,"url":"https://github.com/maxroecker/immutable-cpf","last_synced_at":"2025-03-15T04:17:59.621Z","repository":{"id":57272764,"uuid":"373347080","full_name":"MaxRoecker/immutable-cpf","owner":"MaxRoecker","description":"A tiny library to handle CPF in an immutable flavour.","archived":false,"fork":false,"pushed_at":"2024-01-04T14:17:14.000Z","size":685,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-17T22:16:26.535Z","etag":null,"topics":["cpf","immutable"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaxRoecker.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-06-03T01:27:04.000Z","updated_at":"2023-11-15T22:34:58.000Z","dependencies_parsed_at":"2024-01-04T15:29:52.843Z","dependency_job_id":"244ecaa0-01e3-4b37-a9a1-ab97bc94ab65","html_url":"https://github.com/MaxRoecker/immutable-cpf","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaxRoecker","download_url":"https://codeload.github.com/MaxRoecker/immutable-cpf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243681038,"owners_count":20330155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpf","immutable"],"created_at":"2025-03-15T04:17:59.013Z","updated_at":"2025-03-15T04:17:59.608Z","avatar_url":"https://github.com/MaxRoecker.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Immutable CPF\n\nA tiny library to handle CPF in an immutable flavour.\n\n\u003e The **[CPF][cpf]** (Cadastro de Pessoas Físicas, [sepeˈɛfi]; portuguese for\n\u003e \"Natural Persons Register\") is the Brazilian individual taxpayer registry\n\u003e identification. This number is attributed by the Brazilian Federal Revenue to\n\u003e Brazilians and resident aliens who, directly or indirectly, pay taxes in\n\u003e Brazil.\n\n## [![View on NPM](https://img.shields.io/npm/v/immutable-cpf?style=flat-square)](https://www.npmjs.com/package/immutable-cpf) [![License](https://img.shields.io/npm/l/immutable-cpf?style=flat-square)](https://maxroecker.mit-license.org/) 🇧🇷\n\n## Installation\n\nUse the npm package manager to install Immutable CPF.\n\n```bash\nnpm i immutable-cpf\n```\n\n## Usage\n\nThe library provides a the [`CPF`][cpfclass] class to create immutable instances\nrepresenting CPF documents. You can create instances with any iterable of digits\nand format or validate them. See the example:\n\n```js\nimport { CPF } from 'immutable-cpf';\n\nconst cpf = new CPF([3, 1, 6, 7, 5, 7, 4, 5, 5, 0, 1]);\n\ncpf.equals(cpf); // true\n\ncpf.checkValidity(); // true\n\ncpf.format(); // '316.757.455-01'\n```\n\nYou can also create instances from strings using the [`CPF.from`][cpf.from]\nmethod.\n\n```js\nimport { CPF } from 'immutable-cpf';\n\nconst cpfA = new CPF([3, 1, 6, 7, 5, 7, 4, 5, 5, 0, 1]);\nconst cpfB = CPF.from('316.757.455-01');\nconst cpfC = CPF.from('3  1  6 7 5  7 4 5  5 0   1   ');\n\ncpfA.equals(cpfB); // true\n\ncpfA.equals(cpfC); // true\n```\n\n\u003e The `CPF` class implements the [`Evaluable`][evaluable] interface and it's\n\u003e suitable to be used along [ImmutableJS][immutablejs] data structures.\n\nThe method [`CPF.prototype.getValidity`][cpf.getvalidity] returns the validity\nstate of the instance. If you only want to check if the instance is valid or\nnot, see the [`CPF.prototype.checkValidity`][cpf.checkvalidity] method.\n\n```js\nimport { CPF } from 'immutable-cpf';\n\nconst empty = new CPF([]);\nempty.checkValidity(); // false, it's empty\n\nconst semi = new CPF([3, 1, 6, 7]);\nsemi.checkValidity(); // false, it's not complete\n\nconst invalid = new CPF([3, 1, 6, 7, 5, 7, 4, 5, 5, 1, 2]);\nsemi.checkValidity(); // false, its check digits fails\n\nconst valid = new CPF([3, 1, 6, 7, 5, 7, 4, 5, 5, 0, 1]);\nvalid.checkValidity(); // true\n```\n\nThe library also provides the method [`CPF.create`][cpf.create] to generate\nvalid instances with pseudo-random numbers.\n\n```js\nimport { CPF } from 'immutable-cpf';\n\nconst cpf = CPF.create();\n\ncpf.checkValidity(); // true\n```\n\nThe default JSON serialization a `CPF` instance is a string. You can also access\nit directly calling the [`CPF.prototype.toJSON`][cpf.tojson].\n\n```js\nimport { CPF } from 'immutable-cpf';\n\nconst user = {s\n  name: 'José Silva',\n  cpf: new CPF([3, 1, 6, 7, 5, 7, 4, 5, 5, 0, 1]),\n};\n\nJSON.stringify(user); // '{\"name\": \"José Silva\", \"cpf\": \"31675745501\"}'\n\nuser.cpf.toJSON(); // '31675745501'\n```\n\n## API\n\nSee the complete API on the [Wiki's page][wiki].\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to\ndiscuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://maxroecker.mit-license.org/)\n\n[evaluable]: https://github.com/MaxRoecker/evaluable\n[wiki]: https://github.com/MaxRoecker/immutable-cpf/wiki\n[cpf]: https://en.wikipedia.org/wiki/CPF_number\n[cpfclass]: https://github.com/MaxRoecker/immutable-cpf/wiki#class-cpf\n[cpf.from]: https://github.com/MaxRoecker/immutable-cpf/wiki#from\n[cpf.getvalidity]: https://github.com/MaxRoecker/immutable-cpf/wiki#getvalidity\n[cpf.checkvalidity]: https://github.com/MaxRoecker/immutable-cpf/wiki#checkvalidity\n[cpf.create]: https://github.com/MaxRoecker/immutable-cpf/wiki#create\n[cpf.tojson]: https://github.com/MaxRoecker/immutable-cpf/wiki#tojson\n[immutablejs]: https://immutable-js.github.io/immutable-js/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxroecker%2Fimmutable-cpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxroecker%2Fimmutable-cpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxroecker%2Fimmutable-cpf/lists"}