[
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  extends: [\"@fnando/codestyle/javascript\", \"@fnando/codestyle/typescript\"],\n};\n"
  },
  {
    "path": ".gitignore",
    "content": "/node_modules\n/tmp\n*.log\n"
  },
  {
    "path": ".prettierrc.js",
    "content": "module.exports = require(\"@fnando/codestyle/prettier.json\");\n"
  },
  {
    "path": ".tool-versions",
    "content": "nodejs 12.16.1\n"
  },
  {
    "path": ".travis.yml",
    "content": "---\nsudo: false\nlanguage: node_js\nnotifications:\n  email: false\nnode_js:\n  - \"13\"\n  - \"12\"\n"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, gender identity and expression, level of\nexperience, nationality, personal appearance, race, religion, or sexual identity\nand orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n- Using welcoming and inclusive language\n- Being respectful of differing viewpoints and experiences\n- Gracefully accepting constructive criticism\n- Focusing on what is best for the community\n- Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n- The use of sexualized language or imagery and unwelcome sexual attention or\n  advances\n- Trolling, insulting/derogatory comments, and personal or political attacks\n- Public or private harassment\n- Publishing others' private information, such as a physical or electronic\n  address, without explicit permission\n- Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or reject\ncomments, commits, code, wiki edits, issues, and other contributions that are\nnot aligned to this Code of Conduct, or to ban temporarily or permanently any\ncontributor for other behaviors that they deem inappropriate, threatening,\noffensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting the project team at me@fnando.com. The project team will\nreview and investigate all complaints, and will respond in a way that it deems\nappropriate to the circumstances. The project team is obligated to maintain\nconfidentiality with regard to the reporter of an incident. Further details of\nspecific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage],\nversion 1.4, available at [http://contributor-covenant.org/version/1/4][version]\n\n[homepage]: http://contributor-covenant.org\n[version]: http://contributor-covenant.org/version/1/4/\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\nOnce you've made your great commits (include tests, please):\n\n1. Fork this repository\n2. Create a topic branch - `git checkout -b my_branch`\n3. Push to your branch - `git push origin my_branch`\n4. Create a pull request\n\nThat's it!\n\nPlease respect the indentation rules and code style. And use 2 spaces, not tabs.\nAnd don't touch the version thing or distribution files; this will be made when\na new version is going to be released.\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2018 Nando Vieira\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# CPF\n\n[![Build Status](https://travis-ci.org/fnando/cpf.svg?branch=master)](https://travis-ci.org/fnando/cpf)\n[![NPM package version](https://img.shields.io/npm/v/@fnando/cpf.svg)](https://www.npmjs.com/package/@fnando/cpf)\n![License: MIT](https://img.shields.io/npm/l/@fnando/cpf.svg)\n![Minified size](http://img.badgesize.io/fnando/cpf/master/web/cpf.min.js.svg?label=cpf+min+size)\n![Minified+Gzip size](http://img.badgesize.io/fnando/cpf/master/web/cpf.min.js.svg?compression=gzip&label=cpf+min%2Bgzip+size)\n\nThis package does some\n[CPF](http://en.wikipedia.org/wiki/Cadastro_de_Pessoas_F%C3%ADsicas) magic. It\nallows you to create, validate and format CPF documents.\n\n**HINT:** Check out the CNPJ counter part available at\n<https://github.com/fnando/cnpj>.\n\n## Installation\n\nThis lib is available as a NPM package. To install it, use the following\ncommand:\n\n```\nnpm install @fnando/cpf --save\n```\n\nIf you're using Yarn (and you should):\n\n```\nyarn add @fnando/cpf\n```\n\n## Usage\n\n```js\n// Node.js-specific\nconst cpf = require(\"@fnando/cpf/commonjs\");\n\n// @import\nimport * as cpf from \"@fnando/cpf\"; // import the whole library\nimport { isValid as isValidCpf } from \"@fnando/cpf\"; // import just one function\n\n// import via <script>; the lib will available as window.CPF\n// <script src=\"cpf.js\"></script>\n\ncpf.isValid(\"532.820.857-96\");\n//=> true\n\ncpf.isValid(\"53282085796\");\n//=> true\n\ncpf.strip(\"532.820.857-96\");\n//=> 53282085796\n\ncpf.format(\"53282085796\");\n//=> 532.820.857-96\n\ncpf.generate(true); // generate formatted number\n//=> 838.684.734-40\n\ncpf.generate(); // generate unformatted number\n//=> 72777632898\n```\n\nOn the web, without transformation, just use `web/cpf.min.js`.\n\n### Strict Validation\n\nBy default, validations will strip any characters you provide. This means that\nthe following is valid, because only numbers will be considered:\n\n```js\ncpf.isValid(\"101#688!!!!!!542......36\");\n//=> true\n\ncpf.strip(\"101#688!!!!!!542......36\");\n//=> 10168854236\n```\n\nIf you want to strict validate strings, use the following signature:\n\n```js\ncpf.isValid(number, strict);\n```\n\nThe same example would now return `false`:\n\n```js\ncpf.isValid(\"101#688!!!!!!542......36\", true);\n//=> false\n```\n"
  },
  {
    "path": "commonjs/index.js",
    "content": "!function(r,e){for(var t in e)r[t]=e[t]}(exports,function(r){var e={};function t(n){if(e[n])return e[n].exports;var u=e[n]={i:n,l:!1,exports:{}};return r[n].call(u.exports,u,u.exports,t),u.l=!0,u.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(r,\"__esModule\",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&\"object\"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,\"default\",{enumerable:!0,value:r}),2&e&&\"string\"!=typeof r)for(var u in r)t.d(n,u,function(e){return r[e]}.bind(null,u));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,\"a\",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p=\"\",t(t.s=0)}([function(r,e,t){\"use strict\";e.__esModule=!0,e.generate=e.isValid=e.strip=e.format=e.verifierDigit=void 0;var n=[\"00000000000\",\"11111111111\",\"22222222222\",\"33333333333\",\"44444444444\",\"55555555555\",\"66666666666\",\"77777777777\",\"88888888888\",\"99999999999\"],u=/[.-]/g,o=/[^\\d]/g;function i(r){var e=r.split(\"\").map((function(r){return parseInt(r,10)})),t=e.length+1,n=e.map((function(r,e){return r*(t-e)})).reduce((function(r,e){return r+e}))%11;return n<2?0:11-n}function f(r){return a(r).replace(/^(\\d{3})(\\d{3})(\\d{3})(\\d{2})$/,\"$1.$2.$3-$4\")}function a(r,e){void 0===e&&(e=!1);var t=e?u:o;return(r||\"\").toString().replace(t,\"\")}e.verifierDigit=i,e.format=f,e.strip=a,e.isValid=function(r,e){void 0===e&&(e=!1);var t=a(r,e);if(!t)return!1;if(11!==t.length)return!1;if(n.includes(t))return!1;var u=t.substr(0,9);return u+=i(u),(u+=i(u)).substr(-2)===t.substr(-2)},e.generate=function(r){void 0===r&&(r=!1);for(var e=\"\",t=0;t<9;t+=1)e+=Math.floor(9*Math.random());return e+=i(e),e+=i(e),r?f(e):e}}]));\n//# sourceMappingURL=index.js.map"
  },
  {
    "path": "es/index.d.ts",
    "content": "/**\n * Compute the Verifier Digit (or \"Dígito Verificador (DV)\" in PT-BR).\n *\n * You can learn more about the algorithm on [wikipedia (pt-br)](https://pt.wikipedia.org/wiki/D%C3%ADgito_verificador)\n *\n * @export\n * @param {string} numbers a string with only numbers.\n * @returns {number} the verifier digit.\n */\nexport declare function verifierDigit(numbers: string): number;\n/**\n * Transform the input into a pretty CPF format.\n *\n * Example:\n * ```\n * format('12345678901');\n * // Result: '123.456.789-01'\n * ```\n *\n * @export\n * @param {string} cpf the CPF.\n * @returns {string} the formatted CPF.\n */\nexport declare function format(cpf: string): string;\n/**\n * Remove some characters from the `number` input.\n *\n * Example:\n * ```\n * strip('29537995593'); // Result: '29537995593'\n * strip('295.379.955-93'); // Result: '29537995593'\n * strip('295a379b9c5d59e3'); // Result: '29537995593'\n * strip('295a379b9c5d59e3', true); // Result: '295a379b9c5d59e3' - Attention!\n * ```\n *\n * @export\n * @param {string} cpf the CPF text.\n * @param {boolean} [isStrict] if `true`, it will remove only `.` and `-` characters.\n *                             Otherwise, it will remove all non-digit (`[^\\d]`) characters. Optional.\n * @returns {string} the stripped CPF.\n */\nexport declare function strip(cpf: string, isStrict?: boolean): string;\n/**\n * Validate the CPF.\n *\n * @export\n * @param {string} cpf the CPF number.\n * @param {boolean} [isStrict] if `true`, it will accept only `digits`, `.` and `-` characters. Optional.\n * @returns {boolean} `true` if CPF is valid. Otherwise, `false`.\n */\nexport declare function isValid(cpf: string, isStrict?: boolean): boolean;\n/**\n * Generate a random CPF.\n *\n * @export\n * @param {boolean} [useFormat] if `true`, it will format using `.` and `-`. Optional.\n * @returns {string} the CPF.\n */\nexport declare function generate(useFormat?: boolean): string;\n"
  },
  {
    "path": "es/index.js",
    "content": "\"use strict\";\nexports.__esModule = true;\nexports.generate = exports.isValid = exports.strip = exports.format = exports.verifierDigit = void 0;\n// Reject common values.\nvar REJECT_LIST = [\n    \"00000000000\",\n    \"11111111111\",\n    \"22222222222\",\n    \"33333333333\",\n    \"44444444444\",\n    \"55555555555\",\n    \"66666666666\",\n    \"77777777777\",\n    \"88888888888\",\n    \"99999999999\",\n];\nvar STRICT_STRIP_REGEX = /[.-]/g;\nvar LOOSE_STRIP_REGEX = /[^\\d]/g;\n/**\n * Compute the Verifier Digit (or \"Dígito Verificador (DV)\" in PT-BR).\n *\n * You can learn more about the algorithm on [wikipedia (pt-br)](https://pt.wikipedia.org/wiki/D%C3%ADgito_verificador)\n *\n * @export\n * @param {string} numbers a string with only numbers.\n * @returns {number} the verifier digit.\n */\nfunction verifierDigit(numbers) {\n    var numberList = numbers.split(\"\").map(function (number) { return parseInt(number, 10); });\n    var modulus = numberList.length + 1;\n    var multiplied = numberList.map(function (number, index) { return number * (modulus - index); });\n    var mod = multiplied.reduce(function (buffer, number) { return buffer + number; }) % 11;\n    return mod < 2 ? 0 : 11 - mod;\n}\nexports.verifierDigit = verifierDigit;\n/**\n * Transform the input into a pretty CPF format.\n *\n * Example:\n * ```\n * format('12345678901');\n * // Result: '123.456.789-01'\n * ```\n *\n * @export\n * @param {string} cpf the CPF.\n * @returns {string} the formatted CPF.\n */\nfunction format(cpf) {\n    return strip(cpf).replace(/^(\\d{3})(\\d{3})(\\d{3})(\\d{2})$/, \"$1.$2.$3-$4\");\n}\nexports.format = format;\n/**\n * Remove some characters from the `number` input.\n *\n * Example:\n * ```\n * strip('29537995593'); // Result: '29537995593'\n * strip('295.379.955-93'); // Result: '29537995593'\n * strip('295a379b9c5d59e3'); // Result: '29537995593'\n * strip('295a379b9c5d59e3', true); // Result: '295a379b9c5d59e3' - Attention!\n * ```\n *\n * @export\n * @param {string} cpf the CPF text.\n * @param {boolean} [isStrict] if `true`, it will remove only `.` and `-` characters.\n *                             Otherwise, it will remove all non-digit (`[^\\d]`) characters. Optional.\n * @returns {string} the stripped CPF.\n */\nfunction strip(cpf, isStrict) {\n    if (isStrict === void 0) { isStrict = false; }\n    var regex = isStrict ? STRICT_STRIP_REGEX : LOOSE_STRIP_REGEX;\n    return (cpf || \"\").toString().replace(regex, \"\");\n}\nexports.strip = strip;\n/**\n * Validate the CPF.\n *\n * @export\n * @param {string} cpf the CPF number.\n * @param {boolean} [isStrict] if `true`, it will accept only `digits`, `.` and `-` characters. Optional.\n * @returns {boolean} `true` if CPF is valid. Otherwise, `false`.\n */\nfunction isValid(cpf, isStrict) {\n    if (isStrict === void 0) { isStrict = false; }\n    var stripped = strip(cpf, isStrict);\n    // CPF must be defined\n    if (!stripped) {\n        return false;\n    }\n    // CPF must have 11 chars\n    if (stripped.length !== 11) {\n        return false;\n    }\n    if (REJECT_LIST.includes(stripped)) {\n        return false;\n    }\n    var numbers = stripped.substr(0, 9);\n    numbers += verifierDigit(numbers);\n    numbers += verifierDigit(numbers);\n    return numbers.substr(-2) === stripped.substr(-2);\n}\nexports.isValid = isValid;\n/**\n * Generate a random CPF.\n *\n * @export\n * @param {boolean} [useFormat] if `true`, it will format using `.` and `-`. Optional.\n * @returns {string} the CPF.\n */\nfunction generate(useFormat) {\n    if (useFormat === void 0) { useFormat = false; }\n    var numbers = \"\";\n    for (var i = 0; i < 9; i += 1) {\n        numbers += Math.floor(Math.random() * 9);\n    }\n    numbers += verifierDigit(numbers);\n    numbers += verifierDigit(numbers);\n    return useFormat ? format(numbers) : numbers;\n}\nexports.generate = generate;\n"
  },
  {
    "path": "jest.config.js",
    "content": "module.exports = require(\"@fnando/codestyle/jest\");\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@fnando/cpf\",\n  \"version\": \"1.0.2\",\n  \"description\": \"Validate, generate and format CPF numbers\",\n  \"main\": \"es/index.js\",\n  \"module\": \"es/index.js\",\n  \"types\": \"es/index.d.ts\",\n  \"scripts\": {\n    \"lint\": \"yarn eslint src\",\n    \"test\": \"yarn jest\",\n    \"js:dist\": \"tsc\",\n    \"js:dist:web\": \"webpack --entry ./es/index.js --output ./web/cpf.min.js --mode production --target web --output-library-export var --output-library CPF --devtool source-map\",\n    \"js:dist:node\": \"webpack --entry ./es/index.js --output ./commonjs/index.js --mode production --target node --output-library-target commonjs --devtool source-map\",\n    \"dist\": \"rm -rf {es,commonjs,web} && yarn test && yarn js:dist && yarn js:dist:web && yarn js:dist:node\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/fnando/cpf.git\"\n  },\n  \"keywords\": [\n    \"cpf\",\n    \"document\"\n  ],\n  \"author\": \"Nando Vieira <fnando.vieira@gmail.com>\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/fnando/cpf/issues\"\n  },\n  \"devDependencies\": {\n    \"@babel/types\": \"*\",\n    \"@fnando/codestyle\": \"*\",\n    \"@fnando/eslint-config-codestyle\": \"*\",\n    \"@types/jest\": \"*\",\n    \"eslint\": \"*\",\n    \"eslint-config-prettier\": \"*\",\n    \"eslint-plugin-prettier\": \"*\",\n    \"jest\": \"*\",\n    \"jest-filename-transform\": \"*\",\n    \"ts-jest\": \"*\",\n    \"typescript\": \"*\",\n    \"webpack\": \"*\",\n    \"webpack-cli\": \"*\"\n  }\n}\n"
  },
  {
    "path": "src/index.ts",
    "content": "// Reject common values.\nconst REJECT_LIST = [\n  \"00000000000\",\n  \"11111111111\",\n  \"22222222222\",\n  \"33333333333\",\n  \"44444444444\",\n  \"55555555555\",\n  \"66666666666\",\n  \"77777777777\",\n  \"88888888888\",\n  \"99999999999\",\n];\n\nconst STRICT_STRIP_REGEX = /[.-]/g;\nconst LOOSE_STRIP_REGEX = /[^\\d]/g;\n\n/**\n * Compute the Verifier Digit (or \"Dígito Verificador (DV)\" in PT-BR).\n *\n * You can learn more about the algorithm on [wikipedia (pt-br)](https://pt.wikipedia.org/wiki/D%C3%ADgito_verificador)\n *\n * @export\n * @param {string} numbers a string with only numbers.\n * @returns {number} the verifier digit.\n */\nexport function verifierDigit(numbers: string): number {\n  const numberList = numbers.split(\"\").map((number) => parseInt(number, 10));\n\n  const modulus = numberList.length + 1;\n\n  const multiplied = numberList.map(\n    (number, index) => number * (modulus - index),\n  );\n\n  const mod = multiplied.reduce((buffer, number) => buffer + number) % 11;\n\n  return mod < 2 ? 0 : 11 - mod;\n}\n\n/**\n * Transform the input into a pretty CPF format.\n *\n * Example:\n * ```\n * format('12345678901');\n * // Result: '123.456.789-01'\n * ```\n *\n * @export\n * @param {string} cpf the CPF.\n * @returns {string} the formatted CPF.\n */\nexport function format(cpf: string): string {\n  return strip(cpf).replace(/^(\\d{3})(\\d{3})(\\d{3})(\\d{2})$/, \"$1.$2.$3-$4\");\n}\n\n/**\n * Remove some characters from the `number` input.\n *\n * Example:\n * ```\n * strip('29537995593'); // Result: '29537995593'\n * strip('295.379.955-93'); // Result: '29537995593'\n * strip('295a379b9c5d59e3'); // Result: '29537995593'\n * strip('295a379b9c5d59e3', true); // Result: '295a379b9c5d59e3' - Attention!\n * ```\n *\n * @export\n * @param {string} cpf the CPF text.\n * @param {boolean} [isStrict] if `true`, it will remove only `.` and `-` characters.\n *                             Otherwise, it will remove all non-digit (`[^\\d]`) characters. Optional.\n * @returns {string} the stripped CPF.\n */\nexport function strip(cpf: string, isStrict = false): string {\n  const regex = isStrict ? STRICT_STRIP_REGEX : LOOSE_STRIP_REGEX;\n  return (cpf || \"\").toString().replace(regex, \"\");\n}\n\n/**\n * Validate the CPF.\n *\n * @export\n * @param {string} cpf the CPF number.\n * @param {boolean} [isStrict] if `true`, it will accept only `digits`, `.` and `-` characters. Optional.\n * @returns {boolean} `true` if CPF is valid. Otherwise, `false`.\n */\nexport function isValid(cpf: string, isStrict: boolean = false): boolean {\n  const stripped = strip(cpf, isStrict);\n\n  // CPF must be defined\n  if (!stripped) {\n    return false;\n  }\n\n  // CPF must have 11 chars\n  if (stripped.length !== 11) {\n    return false;\n  }\n\n  if (REJECT_LIST.includes(stripped)) {\n    return false;\n  }\n\n  let numbers = stripped.substr(0, 9);\n  numbers += verifierDigit(numbers);\n  numbers += verifierDigit(numbers);\n\n  return numbers.substr(-2) === stripped.substr(-2);\n}\n\n/**\n * Generate a random CPF.\n *\n * @export\n * @param {boolean} [useFormat] if `true`, it will format using `.` and `-`. Optional.\n * @returns {string} the CPF.\n */\nexport function generate(useFormat: boolean = false): string {\n  let numbers = \"\";\n\n  for (let i = 0; i < 9; i += 1) {\n    numbers += Math.floor(Math.random() * 9);\n  }\n\n  numbers += verifierDigit(numbers);\n  numbers += verifierDigit(numbers);\n\n  return useFormat ? format(numbers) : numbers;\n}\n"
  },
  {
    "path": "test/cpf.test.ts",
    "content": "import * as cpf from \"../src/index\";\n\nit(\"rejects common numbers\", () => {\n  expect(cpf.isValid(\"00000000000\")).toBeFalsy();\n  expect(cpf.isValid(\"11111111111\")).toBeFalsy();\n  expect(cpf.isValid(\"22222222222\")).toBeFalsy();\n  expect(cpf.isValid(\"33333333333\")).toBeFalsy();\n  expect(cpf.isValid(\"44444444444\")).toBeFalsy();\n  expect(cpf.isValid(\"55555555555\")).toBeFalsy();\n  expect(cpf.isValid(\"66666666666\")).toBeFalsy();\n  expect(cpf.isValid(\"77777777777\")).toBeFalsy();\n  expect(cpf.isValid(\"88888888888\")).toBeFalsy();\n  expect(cpf.isValid(\"99999999999\")).toBeFalsy();\n});\n\nit(\"rejects falsy values\", () => {\n  expect(cpf.isValid(\"\")).toBeFalsy();\n  expect(cpf.isValid(null)).toBeFalsy();\n  expect(cpf.isValid(undefined)).toBeFalsy();\n});\n\nit(\"validates formatted strings\", () => {\n  expect(cpf.isValid(\"295.379.955-93\")).toBeTruthy();\n});\n\nit(\"validates unformatted strings\", () => {\n  expect(cpf.isValid(\"29537995593\")).toBeTruthy();\n});\n\nit(\"validates messed strings\", () => {\n  expect(cpf.isValid(\"295$379\\n955...93\")).toBeTruthy();\n  expect(cpf.isValid(\" 295$379 955\\ns93 \")).toBeTruthy();\n});\n\nit(\"strictly validates strings\", () => {\n  expect(cpf.isValid(\"295$379\\n955...93\", true)).toBeFalsy();\n  expect(cpf.isValid(\"295.379.955-93\", true)).toBeTruthy();\n  expect(cpf.isValid(\"29537995593\", true)).toBeTruthy();\n});\n\nit(\"returns stripped number\", () => {\n  expect(cpf.strip(\"295.379.955-93\")).toEqual(\"29537995593\");\n  expect(cpf.strip(\"295a379b955c93\")).toEqual(\"29537995593\");\n  expect(cpf.strip(\"295a379b955c93\", true)).not.toEqual(\"29537995593\");\n});\n\nit(\"returns formatted number\", () => {\n  const number = cpf.format(\"29537995593\");\n  expect(number).toEqual(\"295.379.955-93\");\n});\n\nit(\"generates formatted number\", () => {\n  const number = cpf.generate(true);\n\n  expect(number).toMatch(/^\\d{3}\\.\\d{3}\\.\\d{3}-\\d{2}$/);\n  expect(cpf.isValid(number)).toBeTruthy();\n});\n\nit(\"generates unformatted number\", () => {\n  const number = cpf.generate();\n\n  expect(number).toMatch(/^\\d{3}\\d{3}\\d{3}\\d{2}$/);\n  expect(cpf.isValid(number)).toBeTruthy();\n});\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"extends\": \"@fnando/codestyle/package\",\n  \"include\": [\"src\"],\n  \"compilerOptions\": {\n    \"moduleResolution\": \"node\",\n    \"lib\": [\"esnext\"],\n    \"declaration\": true,\n    \"declarationDir\": \"es\",\n    \"outDir\": \"es\"\n  }\n}\n"
  }
]