{"id":26296342,"url":"https://github.com/maxroecker/immutable-cnpj","last_synced_at":"2025-10-18T13:06:34.613Z","repository":{"id":57272754,"uuid":"374224951","full_name":"MaxRoecker/immutable-cnpj","owner":"MaxRoecker","description":"A tiny library to handle CNPJ in an immutable flavour.","archived":false,"fork":false,"pushed_at":"2024-01-04T14:27:53.000Z","size":380,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T11:19:45.771Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-05T22:39:44.000Z","updated_at":"2021-11-18T04:02:01.000Z","dependencies_parsed_at":"2022-09-04T06:03:18.620Z","dependency_job_id":null,"html_url":"https://github.com/MaxRoecker/immutable-cnpj","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cnpj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cnpj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cnpj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxRoecker%2Fimmutable-cnpj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaxRoecker","download_url":"https://codeload.github.com/MaxRoecker/immutable-cnpj/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":[],"created_at":"2025-03-15T04:17:56.882Z","updated_at":"2025-10-18T13:06:34.516Z","avatar_url":"https://github.com/MaxRoecker.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Immutable CNPJ\n\nA tiny library to handle CNPJ in an immutable flavour.\n\n\u003e The **[CNPJ][cnpj]** (Cadastro Nacional da Pessoa Jurídica; portuguese for\n\u003e \"National Registry of Legal Entities\") is an identification number issued to\n\u003e Brazilian companies. This number is attributed by the Brazilian Federal\n\u003e Revenue to companies that, directly or indirectly, pay taxes in Brazil.\n\n## [![View on NPM](https://img.shields.io/npm/v/immutable-cnpj?style=flat-square)](https://www.npmjs.com/package/immutable-cnpj) [![License](https://img.shields.io/npm/l/immutable-cnpj?style=flat-square)](https://maxroecker.mit-license.org/) 🇧🇷\n\n## Installation\n\nUse the npm package manager to install Immutable CNPJ.\n\n```bash\nnpm i immutable-cnpj\n```\n\n## Usage\n\nThe library provides a the [`CNPJ`][cnpjclass] class to create immutable\ninstances representing CNPJ documents. You can create instances with any\niterable of digits and format or validate them. See the example:\n\n```js\nimport { CNPJ } from 'immutable-cnpj';\n\nconst cnpj = new CNPJ([1, 1, 4, 4, 4, 7, 7, 7, 0, 0, 0, 1, 6, 1]);\n\ncnpj.equals(cnpj); // true\n\ncnpj.checkValidity(); // true\n\ncnpj.format(); // '11.444.777/0001-61'\n```\n\nYou can also create instances from strings using the [`CNPJ.from`][cnpj.from]\nmethod.\n\n```js\nimport { CNPJ } from 'immutable-cnpj';\n\nconst cnpjA = new CNPJ([1, 1, 4, 4, 4, 7, 7, 7, 0, 0, 0, 1, 6, 1]);\nconst cnpjB = CNPJ.from('11.444.777/0001-61');\nconst cnpjC = CNPJ.from('1 1  4 4 4  7 7 7   0 0 0 1    6 1    ');\n\ncnpjA.equals(cnpjB); // true\n\ncnpjA.equals(cnpjC); // true\n```\n\n\u003e The `CNPJ` class implements the [`Evaluable`][evaluable] interface and it's\n\u003e suitable to be used along [ImmutableJS][immutablejs] data structures.\n\nThe method [`CNPJ.prototype.getValidity`][cnpj.getvalidity] returns the validity\nstate of the instance. If you only want to check if the instance is valid or\nnot, see the [`CNPJ.prototype.checkValidity`][cnpj.checkvalidity] method.\n\n```js\nimport { CNPJ } from 'immutable-cnpj';\n\nconst empty = new CNPJ([]);\nempty.checkValidity(); // false, it's empty\n\nconst semi = new CNPJ([1, 1, 4, 4, 4]);\nsemi.checkValidity(); // false, it's not complete\n\nconst invalid = new CNPJ([1, 1, 4, 4, 4, 7, 7, 7, 0, 0, 0, 1, 7, 2]);\nsemi.checkValidity(); // false, its check digits fails\n\nconst valid = new CNPJ([1, 1, 4, 4, 4, 7, 7, 7, 0, 0, 0, 1, 6, 1]);\nvalid.checkValidity(); // true\n```\n\nThe library also provides the method [`CNPJ.create`][cnpj.create] to generate\nvalid instances with pseudo-random numbers.\n\n```js\nimport { CNPJ } from 'immutable-cnpj';\n\nconst cnpj = CNPJ.create();\n\ncnpj.checkValidity(); // true\n```\n\nThe default JSON serialization a `CNPJ` instance is a string. You can also\naccess it directly calling the [`CNPJ.prototype.toJSON`][cnpj.tojson].\n\n```js\nimport { CNPJ } from 'immutable-cnpj';\n\nconst user = {\n  name: 'Sá, Pato \u0026 Cia',\n  cnpj: new CNPJ([1, 1, 4, 4, 4, 7, 7, 7, 0, 0, 0, 1, 6, 1]),\n};\n\nJSON.stringify(user); // '{\"name\": \"Sá, Pato \u0026 Cia\", \"cnpj\": \"11444777000161\"}'\n\nuser.cnpj.toJSON(); // '11444777000161'\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-cnpj/wiki\n[cnpj]: https://en.wikipedia.org/wiki/CNPJ\n[cnpjclass]: https://github.com/MaxRoecker/immutable-cnpj/wiki#class-cnpj\n[cnpj.from]: https://github.com/MaxRoecker/immutable-cnpj/wiki#from\n[cnpj.getvalidity]: https://github.com/MaxRoecker/immutable-cnpj/wiki#getvalidity\n[cnpj.checkvalidity]: https://github.com/MaxRoecker/immutable-cnpj/wiki#checkvalidity\n[cnpj.create]: https://github.com/MaxRoecker/immutable-cnpj/wiki#create\n[cnpj.tojson]: https://github.com/MaxRoecker/immutable-cnpj/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-cnpj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxroecker%2Fimmutable-cnpj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxroecker%2Fimmutable-cnpj/lists"}