[
  {
    "path": ".circleci/config.yml",
    "content": "version: '2.1'\n\norbs:\n  node: circleci/node@5.1.1\n\njobs:\n  build:\n    docker:\n      - image: cimg/base:stable\n    steps:\n      - checkout\n      - node/install:\n          node-version: '20.10'\n      - restore_cache:\n          key: dependency-cache-{{ checksum \"package.json\" }}\n      - run:\n          name: Versions\n          command: sh bin/list-env-versions\n      - run:\n          name: Install\n          command: npm i\n      - run:\n          name: Test\n          command: npm run test-ci-build\n      - save_cache:\n          key: dependency-cache-{{ checksum \"package.json\" }}\n          paths:\n            - node_modules\n"
  },
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ntrim_trailing_whitespace = true\ninsert_final_newline = true\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"plugins\": [\n    \"eslint-plugin-jsdoc\",\n    \"eslint-plugin-prefer-arrow\",\n    \"@typescript-eslint\",\n    \"@stylistic/ts\"\n  ],\n  \"env\": {\n    \"browser\": true,\n    \"es6\": true,\n    \"node\": true\n  },\n  \"ignorePatterns\": [\n    \"bin\",\n    \"lib\",\n    \"test/fixtures\"\n  ],\n  \"extends\": [\n    \"plugin:@typescript-eslint/recommended\",\n    \"plugin:@typescript-eslint/recommended-requiring-type-checking\"\n  ],\n  \"parser\": \"@typescript-eslint/parser\",\n  \"parserOptions\": {\n    \"project\": \"tsconfig.json\",\n    \"sourceType\": \"module\"\n  },\n  \"root\": true,\n  \"rules\": {\n    \"@stylistic/ts/semi\": [\"error\", \"never\"],\n    \"@stylistic/ts/comma-dangle\": [\"error\", \"never\"],\n    \"@stylistic/ts/type-annotation-spacing\": [\"error\", { \"before\": true, \"after\": true }],\n    \"@typescript-eslint/no-unused-vars\": \"off\",\n    \"@typescript-eslint/no-var-requires\": \"off\"\n  }\n}\n"
  },
  {
    "path": ".gitattributes",
    "content": "lib/** linguist-generated\ntest/fixtures/** linguist-generated\nbin/** linguist-vendored\npackage-lock.json linguist-generated\n\n* text eol=lf\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n.nyc_output\ncoverage\nnpm-debug.log\n.ignore\n"
  },
  {
    "path": ".release-it.json",
    "content": "\n{\n  \"git\": {\n    \"changelog\": \"\",\n    \"requireCleanWorkingDir\": true,\n    \"requireBranch\": false,\n    \"requireUpstream\": false,\n    \"requireCommits\": false,\n    \"requireCommitsFail\": true,\n    \"commitsPath\": \"\",\n    \"addUntrackedFiles\": false,\n    \"commit\": true,\n    \"commitMessage\": \"v${version}\",\n    \"commitArgs\": [],\n    \"tag\": true,\n    \"tagExclude\": null,\n    \"tagName\": null,\n    \"tagMatch\": null,\n    \"getLatestTagFromAllRefs\": false,\n    \"tagAnnotation\": \"v${version}\",\n    \"tagArgs\": [],\n    \"push\": true,\n    \"pushArgs\": [\"--follow-tags\"],\n    \"pushRepo\": \"\"\n  },\n  \"npm\": {\n    \"publish\": true,\n    \"publishPath\": \".\",\n    \"publishArgs\": [],\n    \"tag\": null,\n    \"otp\": null,\n    \"ignoreVersion\": false,\n    \"allowSameVersion\": false,\n    \"versionArgs\": [],\n    \"skipChecks\": false,\n    \"timeout\": 10\n  }\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Synt Changelog\n\nPlease see the GitHub [releases](https://github.com/brentlintner/synt/releases) section.\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 experience,\nnationality, personal appearance, race, religion, or sexual identity and\norientation.\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\nadvances\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\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, 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 brent.lintner@gmail.com. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific 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], version 1.4,\navailable 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\nCurrent list of [Contributors](https://github.com/brentlintner/synt/graphs/contributors).\n\n## Issues\n\nCurrent issue tracker is on [GitHub](https://github.com/brentlintner/synt/issues).\n\nEven if you are uncomfortable with code, an Issue helps!\n\n## Patches\n\nAll you need to do is submit a [Pull Request](https://github.com/brentlintner/synt/pulls).\n\n1. Please consider tests and code quality before submitting.\n2. Please try to keep commits clean, atomic and well explained (for others).\n\n## Code Of Conduct\n\nBy participating in this project you agree to our [Code of Conduct](CODE_OF_CONDUCT.md).\n\n## Developing\n\n    git clone git@github.com:brentlintner/synt.git\n    cd synt\n    npm i\n    npm run -s compile\n\n### Testing\n\n    npm test\n    npm run -s test-cov\n\n### Dev Scripts\n\n*watch and compile files on save*:\n\n    npm run dev\n"
  },
  {
    "path": "LICENSE",
    "content": "Mozilla Public License Version 2.0\n==================================\n\n1. Definitions\n--------------\n\n1.1. \"Contributor\"\n    means each individual or legal entity that creates, contributes to\n    the creation of, or owns Covered Software.\n\n1.2. \"Contributor Version\"\n    means the combination of the Contributions of others (if any) used\n    by a Contributor and that particular Contributor's Contribution.\n\n1.3. \"Contribution\"\n    means Covered Software of a particular Contributor.\n\n1.4. \"Covered Software\"\n    means Source Code Form to which the initial Contributor has attached\n    the notice in Exhibit A, the Executable Form of such Source Code\n    Form, and Modifications of such Source Code Form, in each case\n    including portions thereof.\n\n1.5. \"Incompatible With Secondary Licenses\"\n    means\n\n    (a) that the initial Contributor has attached the notice described\n        in Exhibit B to the Covered Software; or\n\n    (b) that the Covered Software was made available under the terms of\n        version 1.1 or earlier of the License, but not also under the\n        terms of a Secondary License.\n\n1.6. \"Executable Form\"\n    means any form of the work other than Source Code Form.\n\n1.7. \"Larger Work\"\n    means a work that combines Covered Software with other material, in\n    a separate file or files, that is not Covered Software.\n\n1.8. \"License\"\n    means this document.\n\n1.9. \"Licensable\"\n    means having the right to grant, to the maximum extent possible,\n    whether at the time of the initial grant or subsequently, any and\n    all of the rights conveyed by this License.\n\n1.10. \"Modifications\"\n    means any of the following:\n\n    (a) any file in Source Code Form that results from an addition to,\n        deletion from, or modification of the contents of Covered\n        Software; or\n\n    (b) any new file in Source Code Form that contains any Covered\n        Software.\n\n1.11. \"Patent Claims\" of a Contributor\n    means any patent claim(s), including without limitation, method,\n    process, and apparatus claims, in any patent Licensable by such\n    Contributor that would be infringed, but for the grant of the\n    License, by the making, using, selling, offering for sale, having\n    made, import, or transfer of either its Contributions or its\n    Contributor Version.\n\n1.12. \"Secondary License\"\n    means either the GNU General Public License, Version 2.0, the GNU\n    Lesser General Public License, Version 2.1, the GNU Affero General\n    Public License, Version 3.0, or any later versions of those\n    licenses.\n\n1.13. \"Source Code Form\"\n    means the form of the work preferred for making modifications.\n\n1.14. \"You\" (or \"Your\")\n    means an individual or a legal entity exercising rights under this\n    License. For legal entities, \"You\" includes any entity that\n    controls, is controlled by, or is under common control with You. For\n    purposes of this definition, \"control\" means (a) the power, direct\n    or indirect, to cause the direction or management of such entity,\n    whether by contract or otherwise, or (b) ownership of more than\n    fifty percent (50%) of the outstanding shares or beneficial\n    ownership of such entity.\n\n2. License Grants and Conditions\n--------------------------------\n\n2.1. Grants\n\nEach Contributor hereby grants You a world-wide, royalty-free,\nnon-exclusive license:\n\n(a) under intellectual property rights (other than patent or trademark)\n    Licensable by such Contributor to use, reproduce, make available,\n    modify, display, perform, distribute, and otherwise exploit its\n    Contributions, either on an unmodified basis, with Modifications, or\n    as part of a Larger Work; and\n\n(b) under Patent Claims of such Contributor to make, use, sell, offer\n    for sale, have made, import, and otherwise transfer either its\n    Contributions or its Contributor Version.\n\n2.2. Effective Date\n\nThe licenses granted in Section 2.1 with respect to any Contribution\nbecome effective for each Contribution on the date the Contributor first\ndistributes such Contribution.\n\n2.3. Limitations on Grant Scope\n\nThe licenses granted in this Section 2 are the only rights granted under\nthis License. No additional rights or licenses will be implied from the\ndistribution or licensing of Covered Software under this License.\nNotwithstanding Section 2.1(b) above, no patent license is granted by a\nContributor:\n\n(a) for any code that a Contributor has removed from Covered Software;\n    or\n\n(b) for infringements caused by: (i) Your and any other third party's\n    modifications of Covered Software, or (ii) the combination of its\n    Contributions with other software (except as part of its Contributor\n    Version); or\n\n(c) under Patent Claims infringed by Covered Software in the absence of\n    its Contributions.\n\nThis License does not grant any rights in the trademarks, service marks,\nor logos of any Contributor (except as may be necessary to comply with\nthe notice requirements in Section 3.4).\n\n2.4. Subsequent Licenses\n\nNo Contributor makes additional grants as a result of Your choice to\ndistribute the Covered Software under a subsequent version of this\nLicense (see Section 10.2) or under the terms of a Secondary License (if\npermitted under the terms of Section 3.3).\n\n2.5. Representation\n\nEach Contributor represents that the Contributor believes its\nContributions are its original creation(s) or it has sufficient rights\nto grant the rights to its Contributions conveyed by this License.\n\n2.6. Fair Use\n\nThis License is not intended to limit any rights You have under\napplicable copyright doctrines of fair use, fair dealing, or other\nequivalents.\n\n2.7. Conditions\n\nSections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted\nin Section 2.1.\n\n3. Responsibilities\n-------------------\n\n3.1. Distribution of Source Form\n\nAll distribution of Covered Software in Source Code Form, including any\nModifications that You create or to which You contribute, must be under\nthe terms of this License. You must inform recipients that the Source\nCode Form of the Covered Software is governed by the terms of this\nLicense, and how they can obtain a copy of this License. You may not\nattempt to alter or restrict the recipients' rights in the Source Code\nForm.\n\n3.2. Distribution of Executable Form\n\nIf You distribute Covered Software in Executable Form then:\n\n(a) such Covered Software must also be made available in Source Code\n    Form, as described in Section 3.1, and You must inform recipients of\n    the Executable Form how they can obtain a copy of such Source Code\n    Form by reasonable means in a timely manner, at a charge no more\n    than the cost of distribution to the recipient; and\n\n(b) You may distribute such Executable Form under the terms of this\n    License, or sublicense it under different terms, provided that the\n    license for the Executable Form does not attempt to limit or alter\n    the recipients' rights in the Source Code Form under this License.\n\n3.3. Distribution of a Larger Work\n\nYou may create and distribute a Larger Work under terms of Your choice,\nprovided that You also comply with the requirements of this License for\nthe Covered Software. If the Larger Work is a combination of Covered\nSoftware with a work governed by one or more Secondary Licenses, and the\nCovered Software is not Incompatible With Secondary Licenses, this\nLicense permits You to additionally distribute such Covered Software\nunder the terms of such Secondary License(s), so that the recipient of\nthe Larger Work may, at their option, further distribute the Covered\nSoftware under the terms of either this License or such Secondary\nLicense(s).\n\n3.4. Notices\n\nYou may not remove or alter the substance of any license notices\n(including copyright notices, patent notices, disclaimers of warranty,\nor limitations of liability) contained within the Source Code Form of\nthe Covered Software, except that You may alter any license notices to\nthe extent required to remedy known factual inaccuracies.\n\n3.5. Application of Additional Terms\n\nYou may choose to offer, and to charge a fee for, warranty, support,\nindemnity or liability obligations to one or more recipients of Covered\nSoftware. However, You may do so only on Your own behalf, and not on\nbehalf of any Contributor. You must make it absolutely clear that any\nsuch warranty, support, indemnity, or liability obligation is offered by\nYou alone, and You hereby agree to indemnify every Contributor for any\nliability incurred by such Contributor as a result of warranty, support,\nindemnity or liability terms You offer. You may include additional\ndisclaimers of warranty and limitations of liability specific to any\njurisdiction.\n\n4. Inability to Comply Due to Statute or Regulation\n---------------------------------------------------\n\nIf it is impossible for You to comply with any of the terms of this\nLicense with respect to some or all of the Covered Software due to\nstatute, judicial order, or regulation then You must: (a) comply with\nthe terms of this License to the maximum extent possible; and (b)\ndescribe the limitations and the code they affect. Such description must\nbe placed in a text file included with all distributions of the Covered\nSoftware under this License. Except to the extent prohibited by statute\nor regulation, such description must be sufficiently detailed for a\nrecipient of ordinary skill to be able to understand it.\n\n5. Termination\n--------------\n\n5.1. The rights granted under this License will terminate automatically\nif You fail to comply with any of its terms. However, if You become\ncompliant, then the rights granted under this License from a particular\nContributor are reinstated (a) provisionally, unless and until such\nContributor explicitly and finally terminates Your grants, and (b) on an\nongoing basis, if such Contributor fails to notify You of the\nnon-compliance by some reasonable means prior to 60 days after You have\ncome back into compliance. Moreover, Your grants from a particular\nContributor are reinstated on an ongoing basis if such Contributor\nnotifies You of the non-compliance by some reasonable means, this is the\nfirst time You have received notice of non-compliance with this License\nfrom such Contributor, and You become compliant prior to 30 days after\nYour receipt of the notice.\n\n5.2. If You initiate litigation against any entity by asserting a patent\ninfringement claim (excluding declaratory judgment actions,\ncounter-claims, and cross-claims) alleging that a Contributor Version\ndirectly or indirectly infringes any patent, then the rights granted to\nYou by any and all Contributors for the Covered Software under Section\n2.1 of this License shall terminate.\n\n5.3. In the event of termination under Sections 5.1 or 5.2 above, all\nend user license agreements (excluding distributors and resellers) which\nhave been validly granted by You or Your distributors under this License\nprior to termination shall survive termination.\n\n************************************************************************\n*                                                                      *\n*  6. Disclaimer of Warranty                                           *\n*  -------------------------                                           *\n*                                                                      *\n*  Covered Software is provided under this License on an \"as is\"       *\n*  basis, without warranty of any kind, either expressed, implied, or  *\n*  statutory, including, without limitation, warranties that the       *\n*  Covered Software is free of defects, merchantable, fit for a        *\n*  particular purpose or non-infringing. The entire risk as to the     *\n*  quality and performance of the Covered Software is with You.        *\n*  Should any Covered Software prove defective in any respect, You     *\n*  (not any Contributor) assume the cost of any necessary servicing,   *\n*  repair, or correction. This disclaimer of warranty constitutes an   *\n*  essential part of this License. No use of any Covered Software is   *\n*  authorized under this License except under this disclaimer.         *\n*                                                                      *\n************************************************************************\n\n************************************************************************\n*                                                                      *\n*  7. Limitation of Liability                                          *\n*  --------------------------                                          *\n*                                                                      *\n*  Under no circumstances and under no legal theory, whether tort      *\n*  (including negligence), contract, or otherwise, shall any           *\n*  Contributor, or anyone who distributes Covered Software as          *\n*  permitted above, be liable to You for any direct, indirect,         *\n*  special, incidental, or consequential damages of any character      *\n*  including, without limitation, damages for lost profits, loss of    *\n*  goodwill, work stoppage, computer failure or malfunction, or any    *\n*  and all other commercial damages or losses, even if such party      *\n*  shall have been informed of the possibility of such damages. This   *\n*  limitation of liability shall not apply to liability for death or   *\n*  personal injury resulting from such party's negligence to the       *\n*  extent applicable law prohibits such limitation. Some               *\n*  jurisdictions do not allow the exclusion or limitation of           *\n*  incidental or consequential damages, so this exclusion and          *\n*  limitation may not apply to You.                                    *\n*                                                                      *\n************************************************************************\n\n8. Litigation\n-------------\n\nAny litigation relating to this License may be brought only in the\ncourts of a jurisdiction where the defendant maintains its principal\nplace of business and such litigation shall be governed by laws of that\njurisdiction, without reference to its conflict-of-law provisions.\nNothing in this Section shall prevent a party's ability to bring\ncross-claims or counter-claims.\n\n9. Miscellaneous\n----------------\n\nThis License represents the complete agreement concerning the subject\nmatter hereof. If any provision of this License is held to be\nunenforceable, such provision shall be reformed only to the extent\nnecessary to make it enforceable. Any law or regulation which provides\nthat the language of a contract shall be construed against the drafter\nshall not be used to construe this License against a Contributor.\n\n10. Versions of the License\n---------------------------\n\n10.1. New Versions\n\nMozilla Foundation is the license steward. Except as provided in Section\n10.3, no one other than the license steward has the right to modify or\npublish new versions of this License. Each version will be given a\ndistinguishing version number.\n\n10.2. Effect of New Versions\n\nYou may distribute the Covered Software under the terms of the version\nof the License under which You originally received the Covered Software,\nor under the terms of any subsequent version published by the license\nsteward.\n\n10.3. Modified Versions\n\nIf you create software not governed by this License, and you want to\ncreate a new license for such software, you may create and use a\nmodified version of this License if you rename the license and remove\nany references to the name of the license steward (except to note that\nsuch modified license differs from this License).\n\n10.4. Distributing Source Code Form that is Incompatible With Secondary\nLicenses\n\nIf You choose to distribute Source Code Form that is Incompatible With\nSecondary Licenses under the terms of this version of the License, the\nnotice described in Exhibit B of this License must be attached.\n\nExhibit A - Source Code Form License Notice\n-------------------------------------------\n\n  This Source Code Form is subject to the terms of the Mozilla Public\n  License, v. 2.0. If a copy of the MPL was not distributed with this\n  file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\nIf it is not possible or desirable to put the notice in a particular\nfile, then You may include the notice in a location (such as a LICENSE\nfile in a relevant directory) where a recipient would be likely to look\nfor such a notice.\n\nYou may add additional accurate notices of copyright ownership.\n\nExhibit B - \"Incompatible With Secondary Licenses\" Notice\n---------------------------------------------------------\n\n  This Source Code Form is \"Incompatible With Secondary Licenses\", as\n  defined by the Mozilla Public License, v. 2.0.\n"
  },
  {
    "path": "README.md",
    "content": "# synt [![Circle CI](https://circleci.com/gh/brentlintner/synt.svg?style=shield)](https://circleci.com/gh/brentlintner/synt) [![Windows Build status](https://ci.appveyor.com/api/projects/status/t2hy3nxlqc685n1m/branch/master?svg=true)](https://ci.appveyor.com/project/brentlintner/synt/branch/master) [![npm version](https://badge.fury.io/js/synt.svg)](https://badge.fury.io/js/synt)\n\nFind similar functions and classes in your JavaScript/TypeScript code.\n\n## Supported Languages\n\n* JavaScript ([ES3-ES15](https://github.com/eslint/espree?tab=readme-ov-file#options))\n* TypeScript ([5.x](https://github.com/microsoft/TypeScript/tree/v5.3.3))\n\n## System Requirements\n\n* [NodeJS](http://nodejs.org)\n\n## Installation & Usage\n\n```sh\nnpm i synt\n```\n\n### CLI\n\n*install*\n\n```sh\nnpm i -g synt\n```\n\n*help*\n\n```sh\nsynt -h\n```\n\n*example*\n\n```sh\ngit clone https://github.com/brentlintner/synt.git\ncd synt\nsynt analyze src\n```\n\n### Library\n\n*example*\n\n```javascript\nconst synt = require(\"synt\")\n\nconst files = [ \"a.js\", \"b.ts\" ]\n\nconst { js, ts } = synt.compare(files, {\n  similarity: 80,\n  ngram: 1,\n  minLength: 20,\n  sourceType: \"module\",\n  ecmaVersion: 6\n})\n\nsynt.print(js)\n\nsynt.print(ts)\n```\n\n## Licensing\n\nThis project is licensed under the [MPL-2.0](LICENSE) license.\n\nAny contributions made to this project are made under the current license.\n\n## Contributing\n\nAny contributions are welcome and appreciated!\n\nPlease see [CONTRIBUTING.md](CONTRIBUTING.md) for more info.\n\n## Versioning\n\nThis project ascribes to [semantic versioning](http://semver.org).\n\n## Name\n\n`synt` is short for [synteny](http://en.wikipedia.org/wiki/Synteny), and is\nan (attempted) play on comparing code evolution to genetic (evolution).\n"
  },
  {
    "path": "appveyor.yml",
    "content": "version: \"1.0.{build}\"\n\ncache:\n  - node_modules -> package.json\n\nenvironment:\n  nodejs_version: 20\n\nmatrix:\n  fast_finish: true\n\nplatform:\n  - x64\n\ninit:\n  - git config --global core.autocrlf input\n\nskip_tags: true\n\nclone_depth: 10\n\nbuild: off\n\ninstall:\n  - ps: Install-Product node $env:nodejs_version\n  - ver && node --version && npm --version\n  - npm install\n\ntest_script:\n  - npm run compile\n  - npm run test\n"
  },
  {
    "path": "bin/list-env-versions",
    "content": "#!/usr/bin/env sh\nuname -a\nnode --version\nnpm --version\n"
  },
  {
    "path": "bin/release",
    "content": "#!/usr/bin/env sh\nlevel=$1\n\nset -e\n\nif [ -z \"${level}\" ]; then\n  level=patch\nfi\n\nnpm run -s compile\n\nnpm t\n\ngit add -f lib\n\nnpm run -s release -- \"$level\"\n"
  },
  {
    "path": "bin/synt",
    "content": "#!/usr/bin/env node\nrequire('./../lib/cli').interpret(process.argv)\n"
  },
  {
    "path": "coffeelint.json",
    "content": "{\n  \"arrow_spacing\": {\n    \"level\": \"warn\"\n  },\n  \"camel_case_classes\": {\n    \"level\": \"error\"\n  },\n  \"coffeescript_error\": {\n    \"level\": \"error\"\n  },\n  \"colon_assignment_spacing\": {\n    \"level\": \"ignore\",\n    \"spacing\": {\n      \"left\": 0,\n      \"right\": 0\n    }\n  },\n  \"cyclomatic_complexity\": {\n    \"value\": 4,\n    \"level\": \"warn\"\n  },\n  \"duplicate_key\": {\n    \"level\": \"error\"\n  },\n  \"empty_constructor_needs_parens\": {\n    \"level\": \"warn\"\n  },\n  \"indentation\": {\n    \"value\": 2,\n    \"level\": \"error\"\n  },\n  \"line_endings\": {\n    \"level\": \"warn\",\n    \"value\": \"unix\"\n  },\n  \"max_line_length\": {\n    \"value\": 100,\n    \"level\": \"error\",\n    \"limitComments\": true\n  },\n  \"missing_fat_arrows\": {\n    \"level\": \"warn\"\n  },\n  \"newlines_after_classes\": {\n    \"value\": 3,\n    \"level\": \"warn\"\n  },\n  \"no_backticks\": {\n    \"level\": \"error\"\n  },\n  \"no_debugger\": {\n    \"level\": \"warn\"\n  },\n  \"no_empty_functions\": {\n    \"level\": \"warn\"\n  },\n  \"no_empty_param_list\": {\n    \"level\": \"ignore\"\n  },\n  \"no_implicit_braces\": {\n    \"level\": \"ignore\",\n    \"strict\": true\n  },\n  \"no_implicit_parens\": {\n    \"strict\": true,\n    \"level\": \"ignore\"\n  },\n  \"no_interpolation_in_single_quotes\": {\n    \"level\": \"warn\"\n  },\n  \"no_plusplus\": {\n    \"level\": \"warn\"\n  },\n  \"no_stand_alone_at\": {\n    \"level\": \"warn\"\n  },\n  \"no_tabs\": {\n    \"level\": \"error\"\n  },\n  \"no_throwing_strings\": {\n    \"level\": \"error\"\n  },\n  \"no_trailing_semicolons\": {\n    \"level\": \"error\"\n  },\n  \"no_trailing_whitespace\": {\n    \"level\": \"error\",\n    \"allowed_in_comments\": false,\n    \"allowed_in_empty_lines\": false\n  },\n  \"no_unnecessary_double_quotes\": {\n    \"level\": \"ignore\"\n  },\n  \"no_unnecessary_fat_arrows\": {\n    \"level\": \"warn\"\n  },\n  \"non_empty_constructor_needs_parens\": {\n    \"level\": \"ignore\"\n  },\n  \"space_operators\": {\n    \"level\": \"warn\"\n  }\n}\n"
  },
  {
    "path": "lib/cli/file_collector.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.files = void 0;\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst _ = require(\"lodash\");\nconst walk_sync = require(\"walk-sync\");\nconst all_files = (target) => {\n    if (fs.statSync(target).isDirectory()) {\n        const dirs = walk_sync(target, { directories: false });\n        return _.map(dirs, (dir) => path.join(target, dir));\n    }\n    else {\n        return [target];\n    }\n};\nconst normalize_cli_targets = (targets) => {\n    targets = _.concat([], targets);\n    let files = _.uniq(_.reduce(targets, (paths, target) => _.concat(paths, all_files(target)), []));\n    files = _.map(files, (file) => path.relative(process.cwd(), file));\n    return _.filter(files, (file) => /\\.(js|ts)$/.test(file));\n};\nexports.files = normalize_cli_targets;\n"
  },
  {
    "path": "lib/cli.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.interpret = void 0;\nconst commander_1 = require(\"commander\");\nconst espree = require(\"espree\");\nconst similar = require(\"./similar\");\nconst fs_collector = require(\"./cli/file_collector\");\nconst pkg = require(\"./../package.json\");\nconst compare = (targets, opts) => {\n    const files = fs_collector.files(targets);\n    const ecmaVersion = opts.ecmaVersion && opts.ecmaVersion != \"latest\" ?\n        parseInt(opts.ecmaVersion) : opts.ecmaVersion;\n    const { js, ts } = similar.compare(files, Object.assign(Object.assign({}, opts), { ecmaVersion }));\n    similar.print(js, opts.color);\n    similar.print(ts, opts.color);\n    if (opts.exitCode && (Object.keys(js).length > 0 || Object.keys(ts).length > 0)) {\n        process.exit(1);\n    }\n};\nconst configure = () => {\n    commander_1.program\n        .version(pkg.version)\n        .command(\"analyze [paths...]\")\n        .alias(\"a\")\n        .option(\"-s, --similarity [number]\", `Lowest % similarity to look for ` +\n        `[default=${similar.DEFAULT_THRESHOLD}].`)\n        .option(\"-m, --min-length [number]\", `Default token length a function needs to be to compare it ` +\n        `[default=${similar.DEFAULT_TOKEN_LENGTH}].`)\n        .option(\"-g, --ngram [number]\", `Specify ngram length for comparing token sequences. ` +\n        `[default=${similar.DEFAULT_NGRAM_LENGTH},2,3...]`)\n        .option(\"-n, --no-color\", \"Disable color output\")\n        .option(\"-e, --exit-code\", \"Exit with a nonzero code when issues found\")\n        .option(\"-t, --source-type [value]\", \"Set JS source type [default=module,script,commonjs]\")\n        .option(\"-a, --ecma-version [value]\", `Set JS version [default=latest,${espree.supportedEcmaVersions.join(\",\")}]`)\n        .action(compare);\n    commander_1.program.on(\"--help\", () => {\n        console.log(\"  Command specific help:\");\n        console.log(\"\");\n        console.log(\"    {cmd} -h, --help\");\n        console.log(\"\");\n        console.log(\"  Examples:\");\n        console.log(\"\");\n        console.log(\"    $ synt analyze lib\");\n        console.log(\"    $ synt analyze -s 90 foo.js bar.js baz.js\");\n        console.log(\"\");\n    });\n};\nconst interpret = (argv) => {\n    configure();\n    commander_1.program.parse(argv);\n};\nexports.interpret = interpret;\n"
  },
  {
    "path": "lib/index.js",
    "content": "\"use strict\";\nconst similar = require(\"./similar\");\nconst library = similar;\nmodule.exports = library;\n"
  },
  {
    "path": "lib/similar/javascript.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.find = void 0;\nconst escodegen = require(\"@javascript-obfuscator/escodegen\");\nconst espree = require(\"espree\");\nconst estraverse = require(\"estraverse\");\nconst fs = require(\"fs\");\nconst _ = require(\"lodash\");\nconst FUNCTION_OR_CLASS_NODE = [\n    espree.Syntax.ArrowFunctionExpression,\n    espree.Syntax.ClassDeclaration,\n    espree.Syntax.FunctionDeclaration,\n    espree.Syntax.FunctionExpression\n];\nconst normalize = (token_list) => _.map(token_list, (t) => t.value);\nconst tokenize = (code, opts) => {\n    const tokenize_opts = {\n        ecmaVersion: opts.ecmaVersion || \"latest\",\n        sourceType: opts.sourceType || \"module\"\n    };\n    return normalize(espree.tokenize(code, tokenize_opts));\n};\nconst astify = (code, opts) => {\n    const module_type = opts.sourceType || \"module\";\n    const ecma_version = opts.ecmaVersion || \"latest\";\n    const parse_opts = {\n        ecmaVersion: ecma_version,\n        loc: true,\n        sourceType: module_type\n    };\n    return espree.parse(code, parse_opts);\n};\nconst ast_to_code = (node) => {\n    const opts = { format: { indent: { style: \"  \" } } };\n    return escodegen.generate(node, opts);\n};\nconst is_a_method_or_class = (node) => _.some(FUNCTION_OR_CLASS_NODE, (type) => type === node.type);\nconst line_info = (node) => node.loc;\nconst parse_methods_and_classes = (root_node, filepath, opts) => {\n    const entries = [];\n    estraverse.traverse(root_node, {\n        enter(node, _parent) {\n            if (!is_a_method_or_class(node))\n                return;\n            const method = ast_to_code(node);\n            const tokens = tokenize(method, opts);\n            const is_class = node.type === espree.Syntax.ClassDeclaration;\n            const result = {\n                ast: node,\n                code: method,\n                is_class,\n                path: filepath,\n                pos: line_info(node),\n                tokens,\n                type: node.type\n            };\n            entries.push(result);\n        }\n    });\n    return entries;\n};\nconst find_similar_methods_and_classes = (filepaths, opts) => _.flatMap(filepaths, (filepath) => {\n    const code = fs.readFileSync(filepath).toString();\n    let node;\n    try {\n        node = astify(code, opts);\n    }\n    catch (err) {\n        throw new Error(`in ${filepath}\\n\\n${_.get(err, \"stack\", err)}`);\n    }\n    return parse_methods_and_classes(node, filepath, opts);\n});\nexports.find = find_similar_methods_and_classes;\n"
  },
  {
    "path": "lib/similar/ngram.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generate = void 0;\nconst generate = (arr, len = 1) => {\n    if (len > arr.length)\n        len = 1;\n    if (len == 1)\n        return arr;\n    const sets = [];\n    arr.forEach((token, index) => {\n        const s_len = index + len;\n        if (s_len <= arr.length) {\n            sets.push(arr.slice(index, s_len).join(\"\"));\n        }\n    });\n    return sets;\n};\nexports.generate = generate;\n"
  },
  {
    "path": "lib/similar/print.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.print = void 0;\nconst _ = require(\"lodash\");\nconst cardinal = require(\"cardinal\");\nconst chalk = require(\"chalk\");\nconst print = (group, color) => {\n    _.each(group, (results, sim) => {\n        _.each(results, (result) => {\n            const [src, cmp] = result;\n            console.log(\"\");\n            const match_sim = sim + \"% similar\";\n            if (color) {\n                console.log(chalk.red.bold(match_sim));\n            }\n            else {\n                console.log(match_sim);\n            }\n            console.log(\"\");\n            if (color) {\n                console.log(chalk.gray(\"in: \") + chalk.green(src.path));\n            }\n            else {\n                console.log(`in: ${src.path}`);\n            }\n            console.log(\"\");\n            if (color) {\n                console.log(cardinal.highlight(src.code, {\n                    firstline: src.pos.start.line,\n                    linenos: true\n                }));\n            }\n            else {\n                console.log(src.code.split(\"\\n\").map((line, idx) => {\n                    return `${src.pos.start.line + idx + 1}: ${line}`;\n                }).join(\"\\n\"));\n            }\n            console.log(\"\");\n            if (src.path !== cmp.path) {\n                if (color) {\n                    console.log(chalk.gray(\"in: \") + chalk.green(cmp.path));\n                }\n                else {\n                    console.log(`in: ${cmp.path}`);\n                }\n                console.log(\"\");\n            }\n            if (color) {\n                console.log(cardinal.highlight(cmp.code, {\n                    firstline: cmp.pos.start.line,\n                    linenos: true\n                }));\n            }\n            else {\n                console.log(cmp.code.split(\"\\n\").map((line, idx) => {\n                    return `${cmp.pos.start.line + idx + 1}: ${line}`;\n                }).join(\"\\n\"));\n            }\n        });\n    });\n};\nexports.print = print;\n"
  },
  {
    "path": "lib/similar/typescript.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.find = void 0;\nconst _ = require(\"lodash\");\nconst fs = require(\"fs\");\nconst ts = require(\"typescript\");\nconst STOP_AT_NODES = [\n    ts.SyntaxKind.ArrayType,\n    ts.SyntaxKind.PrefixUnaryExpression,\n    ts.SyntaxKind.RegularExpressionLiteral\n];\nconst FUNCTION_OR_CLASS_NODE = [\n    ts.SyntaxKind.ArrowFunction,\n    ts.SyntaxKind.ClassDeclaration,\n    ts.SyntaxKind.Constructor,\n    ts.SyntaxKind.FunctionDeclaration,\n    ts.SyntaxKind.FunctionExpression,\n    ts.SyntaxKind.MethodDeclaration\n];\nconst PASSTHROUGH_NODES = FUNCTION_OR_CLASS_NODE.concat([\n    ts.SyntaxKind.ArrowFunction,\n    ts.SyntaxKind.ArrayLiteralExpression,\n    ts.SyntaxKind.BinaryExpression,\n    ts.SyntaxKind.Block,\n    ts.SyntaxKind.CallExpression,\n    ts.SyntaxKind.CatchClause,\n    ts.SyntaxKind.ConditionalExpression,\n    ts.SyntaxKind.ElementAccessExpression,\n    ts.SyntaxKind.ExpressionStatement,\n    ts.SyntaxKind.FirstNode,\n    ts.SyntaxKind.FunctionExpression,\n    ts.SyntaxKind.FunctionDeclaration,\n    ts.SyntaxKind.FunctionType,\n    ts.SyntaxKind.IfStatement,\n    ts.SyntaxKind.IndexSignature,\n    ts.SyntaxKind.NewExpression,\n    ts.SyntaxKind.ObjectLiteralExpression,\n    ts.SyntaxKind.Parameter,\n    ts.SyntaxKind.ParenthesizedExpression,\n    ts.SyntaxKind.PropertyAccessExpression,\n    ts.SyntaxKind.PropertyAssignment,\n    ts.SyntaxKind.PropertyDeclaration,\n    ts.SyntaxKind.ReturnStatement,\n    ts.SyntaxKind.TemplateExpression,\n    ts.SyntaxKind.TemplateSpan,\n    ts.SyntaxKind.TryStatement,\n    ts.SyntaxKind.TypeReference,\n    ts.SyntaxKind.TypeLiteral,\n    ts.SyntaxKind.VariableDeclaration,\n    ts.SyntaxKind.VariableDeclarationList,\n    ts.SyntaxKind.VariableStatement\n]);\nconst astify = (code, filepath, _opts) => {\n    ts.createProgram([filepath], {});\n    return ts.createSourceFile(filepath, code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);\n};\nconst is_a_base_node = (node) => _.some(STOP_AT_NODES, (kind) => kind === node.kind);\nconst is_a_passthrough_node = (node) => _.some(PASSTHROUGH_NODES, (kind) => kind === node.kind);\nconst is_a_method_or_class = (node) => _.some(FUNCTION_OR_CLASS_NODE, (kind) => kind === node.kind);\nconst _tokenize = (tokens) => (node) => {\n    if (is_a_base_node(node)) {\n        tokens.push(node.getText());\n    }\n    else if (is_a_passthrough_node(node)) {\n        ts.forEachChild(node, _tokenize(tokens));\n    }\n    else {\n        tokens.push(node.getText());\n        ts.forEachChild(node, _tokenize(tokens));\n    }\n};\nconst tokenize = (ast_node) => {\n    const tokens = [];\n    _tokenize(tokens)(ast_node);\n    return tokens;\n};\nconst find_all_methods_and_classes = (list) => (node) => {\n    if (is_a_method_or_class(node)) {\n        list.push(node);\n    }\n    ts.forEachChild(node, find_all_methods_and_classes(list));\n};\nconst line_info = (node, root_node) => {\n    const { line, character } = root_node\n        .getLineAndCharacterOfPosition(node.getStart());\n    return {\n        start: {\n            column: character,\n            line: line + 1\n        }\n    };\n};\nconst parse_methods_and_classes = (node, root_node, path) => {\n    const methods_and_classes = [];\n    find_all_methods_and_classes(methods_and_classes)(node);\n    return _.map(methods_and_classes, (method_or_class) => {\n        const tokens = tokenize(method_or_class);\n        const code = method_or_class.getText();\n        const is_class = method_or_class.kind == ts.SyntaxKind.ClassDeclaration;\n        return {\n            ast: method_or_class,\n            code,\n            is_class,\n            path,\n            pos: line_info(method_or_class, root_node),\n            tokens,\n            type: ts.SyntaxKind[method_or_class.kind]\n        };\n    });\n};\nconst find_similar_methods_and_classes = (filepaths, opts) => _.flatMap(filepaths, (filepath) => {\n    const code = fs.readFileSync(filepath).toString();\n    const node = astify(code, filepath, opts);\n    const root_node = node;\n    return parse_methods_and_classes(node, root_node, filepath);\n});\nexports.find = find_similar_methods_and_classes;\n"
  },
  {
    "path": "lib/similar.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.print = exports.compare = exports.DEFAULT_TOKEN_LENGTH = exports.DEFAULT_THRESHOLD = exports.DEFAULT_NGRAM_LENGTH = void 0;\nconst _ = require(\"lodash\");\nconst ngram = require(\"./similar/ngram\");\nconst parse_js = require(\"./similar/javascript\");\nconst parse_ts = require(\"./similar/typescript\");\nconst print_1 = require(\"./similar/print\");\nObject.defineProperty(exports, \"print\", { enumerable: true, get: function () { return print_1.print; } });\nconst DEFAULT_NGRAM_LENGTH = 1;\nexports.DEFAULT_NGRAM_LENGTH = DEFAULT_NGRAM_LENGTH;\nconst DEFAULT_THRESHOLD = 70;\nexports.DEFAULT_THRESHOLD = DEFAULT_THRESHOLD;\nconst DEFAULT_TOKEN_LENGTH = 10;\nexports.DEFAULT_TOKEN_LENGTH = DEFAULT_TOKEN_LENGTH;\nconst similarity = (src, cmp) => {\n    const a = _.uniq(src);\n    const b = _.uniq(cmp);\n    const i = _.intersection(a, b);\n    const u = _.union(a, b);\n    return _.toNumber(_.toNumber((i.length / u.length) * 100)\n        .toFixed(0));\n};\nconst parse_token_length = (str) => _.isEmpty(str) ?\n    DEFAULT_TOKEN_LENGTH :\n    _.toNumber(str);\nconst parse_ngram_length = (str) => _.isEmpty(str) ?\n    DEFAULT_NGRAM_LENGTH :\n    _.toNumber(str);\nconst parse_threshold = (str) => {\n    const threshold = _.toNumber(str);\n    return threshold || DEFAULT_THRESHOLD;\n};\nconst is_ts_ancestor = (src, cmp) => {\n    let match = false;\n    let last = src.ast;\n    while (true) {\n        const { parent } = last;\n        if (parent === cmp.ast)\n            match = true;\n        if (!parent || last === parent || match)\n            break;\n        last = parent;\n    }\n    return match;\n};\nconst false_positive = (src, cmp, t_len) => {\n    const same_node = () => cmp.ast === src.ast;\n    const size_is_too_different = () => {\n        const l1 = src.tokens.length;\n        const l2 = cmp.tokens.length;\n        return l1 * 2 < l2 || l2 * 2 < l1;\n    };\n    const one_is_too_short = () => src.tokens.length < t_len ||\n        cmp.tokens.length < t_len;\n    const subset_of_other = () => {\n        const is_eithers_ancestor = () => is_ts_ancestor(src, cmp) ||\n            is_ts_ancestor(cmp, src);\n        const is_eithers_middle = () => {\n            const src_j = src.tokens.join(\"\");\n            const cmp_j = cmp.tokens.join(\"\");\n            return src_j !== cmp_j &&\n                (_.includes(src_j, cmp_j) ||\n                    _.includes(cmp_j, src_j));\n        };\n        return is_eithers_ancestor() || is_eithers_middle();\n    };\n    const both_are_not_classes = () => (src.is_class && !cmp.is_class) ||\n        (!src.is_class && cmp.is_class);\n    return same_node() ||\n        both_are_not_classes() ||\n        subset_of_other() ||\n        one_is_too_short() ||\n        size_is_too_different();\n};\nconst each_pair = (items, callback) => {\n    _.each(items, (src) => {\n        _.each(items, (cmp) => {\n            callback(src, cmp);\n        });\n    });\n};\nconst filter_redundencies = (group) => {\n    _.each(group, (results, sim) => {\n        group[sim] = _.reduce(results, (new_arr, result) => {\n            const already_added = _.some(new_arr, (result_two) => _.xor(result, result_two).length === 0);\n            if (!already_added) {\n                new_arr.push(result);\n            }\n            return new_arr;\n        }, []);\n    });\n    return group;\n};\nconst _compare = (files, ftype, opts) => {\n    const is_ts = ftype === \"ts\";\n    const is_file = is_ts ? /\\.ts$/ : /\\.js$/;\n    files = _.filter(files, (file) => is_file.test(file));\n    const parse = is_ts ? parse_ts : parse_js;\n    const items = parse.find(files, opts);\n    const group = {};\n    const t_len = parse_token_length(_.toString(opts.minLength));\n    const n_len = parse_ngram_length(_.toString(opts.ngram));\n    const sim_min = parse_threshold(_.toString(opts.similarity));\n    each_pair(items, (src, cmp) => {\n        if (false_positive(src, cmp, t_len))\n            return;\n        const src_grams = ngram.generate(src.tokens, n_len);\n        const cmp_grams = ngram.generate(cmp.tokens, n_len);\n        const val = similarity(src_grams, cmp_grams);\n        if (val < sim_min)\n            return;\n        if (_.isEmpty(group[val]))\n            group[val] = [];\n        group[val].push([src, cmp]);\n    });\n    return filter_redundencies(group);\n};\nconst compare = (files, opts = {}) => {\n    files = _.concat([], files);\n    const js_group = _compare(files, \"js\", opts);\n    const ts_group = _compare(files, \"ts\", opts);\n    return { js: js_group, ts: ts_group };\n};\nexports.compare = compare;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"synt\",\n  \"version\": \"0.5.0\",\n  \"description\": \"Find similar functions and classes in your JavaScript/TypeScript code\",\n  \"author\": \"Brent Lintner <brent.lintner@gmail.com>\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/brentlintner/synt.git\"\n  },\n  \"main\": \"lib/index.js\",\n  \"types\": \"src/@types/index.d.ts\",\n  \"bin\": {\n    \"synt\": \"bin/synt\"\n  },\n  \"files\": [\n    \"bin/synt\",\n    \"src/@types\",\n    \"lib\",\n    \"LICENSE\",\n    \"README.md\"\n  ],\n  \"engines\": {\n    \"node\": \">=4.0.0\",\n    \"npm\": \">=2.0.0\"\n  },\n  \"keywords\": [\n    \"duplicate\",\n    \"similar\",\n    \"functions\",\n    \"methods\",\n    \"classes\",\n    \"code\",\n    \"analysis\",\n    \"compare\",\n    \"javascript\",\n    \"typescript\"\n  ],\n  \"license\": \"MPL-2.0\",\n  \"bugs\": {\n    \"url\": \"https://github.com/brentlintner/synt/issues\"\n  },\n  \"homepage\": \"https://github.com/brentlintner/synt\",\n  \"scripts\": {\n    \"compile\": \"tsc\",\n    \"clean\": \"rm -rf {.nyc_output,coverage,lib} && git checkout -- lib\",\n    \"dev\": \"tsc -w\",\n    \"lint\": \"eslint .; coffeelint -q test\",\n    \"lint-cov\": \"nyc check-coverage --statements 100 --functions 100 --branches 100 --lines 100\",\n    \"release\": \"release-it\",\n    \"test\": \"mocha --require coffeescript/register -R dot -s 2000 --recursive 'test/spec/**/*.coffee'\",\n    \"test-cov\": \"nyc -r lcov -r text -x test/fixtures npm run test\",\n    \"test-ci-build\": \"npm run lint && npm run compile && npm run test-cov && npm run lint-cov\",\n    \"tsc\": \"tsc\"\n  },\n  \"dependencies\": {\n    \"@javascript-obfuscator/escodegen\": \"^2.3.0\",\n    \"@types/escodegen\": \"0.0.10\",\n    \"@types/esprima\": \"^4.0.6\",\n    \"@types/estraverse\": \"^5.1.7\",\n    \"@types/estree\": \"^1.0.5\",\n    \"@types/lodash\": \"^4.14.202\",\n    \"@types/node\": \"^20.10.5\",\n    \"cardinal\": \"^2.1.1\",\n    \"chalk\": \"^4.1.2\",\n    \"commander\": \"^11.1.0\",\n    \"espree\": \"^9.6.1\",\n    \"estraverse\": \"^5.3.0\",\n    \"lodash\": \"^4.17.21\",\n    \"typescript\": \"^5.3.3\",\n    \"walk-sync\": \"^3.0.0\"\n  },\n  \"devDependencies\": {\n    \"@stylistic/eslint-plugin-ts\": \"^1.5.1\",\n    \"@typescript-eslint/eslint-plugin\": \"^6.15.0\",\n    \"@typescript-eslint/parser\": \"^6.15.0\",\n    \"chai\": \"^4.3.10\",\n    \"coffeelint\": \"^2.1.0\",\n    \"coffeescript\": \"^2.7.0\",\n    \"eslint\": \"^8.56.0\",\n    \"eslint-plugin-jsdoc\": \"^46.9.1\",\n    \"eslint-plugin-prefer-arrow\": \"^1.2.3\",\n    \"mocha\": \"^10.2.0\",\n    \"npm-check-updates\": \"^16.14.12\",\n    \"nyc\": \"^15.1.0\",\n    \"release-it\": \"^17.0.1\",\n    \"retire\": \"^4.3.4\",\n    \"sinon\": \"^17.0.1\",\n    \"sinon-chai\": \"^3.7.0\"\n  }\n}\n"
  },
  {
    "path": "src/@types/@javascript-obfuscator/index.d.ts",
    "content": "declare module \"@javascript-obfuscator/escodegen\" {\n  import * as ec from \"escodegen\"\n  import * as et from \"estree\"\n\n  export function generate(ast : et.Node, options ?: ec.GenerateOptions) : string\n}\n"
  },
  {
    "path": "src/@types/cardinal/index.d.ts",
    "content": "declare module \"cardinal\" {\n  export interface CardinalOptions {\n    linenos   ?: boolean\n    firstline ?: number\n    theme     ?: string\n  }\n\n  function highlight(\n    code  : string,\n    opts ?: CardinalOptions\n  ) : string\n}\n"
  },
  {
    "path": "src/@types/espree/index.d.ts",
    "content": "declare module \"espree\" {\n  import * as es from \"esprima\"\n\n  export const supportedEcmaVersions : string[]\n\n  export interface Options {\n    range           ?: boolean\n    loc             ?: boolean\n    comment         ?: boolean\n    tokens          ?: boolean\n    ecmaVersion     ?: string | number\n    allowReserved   ?: boolean\n    sourceType      ?: string\n    ecmaFeatures ?: {\n      jsx           ?: boolean\n      globalReturn  ?: boolean\n      impliedStrict ?: boolean\n    }\n  }\n  export const Syntax : typeof es.Syntax\n  export type Token = es.Token\n  export function parse(code : string, options ?: Options) : es.Program\n  export function tokenize(code : string, options ?: Options) : es.Token[]\n}\n"
  },
  {
    "path": "src/@types/index.d.ts",
    "content": "import * as ts from \"typescript\"\nimport * as es from \"estree\"\nimport * as commander from \"commander\"\n\ndeclare const synt : synt.Lib\n\nexport = synt\nexport as namespace synt\n\ndeclare namespace synt {\n  export type TokenList = string[]\n\n  interface Package {\n    version : string\n  }\n\n  interface BaseOptions {\n    minLength   ?: string | number\n    ngram       ?: string | number\n    similarity  ?: string | number\n    sourceType  ?: string\n  }\n\n  interface EcmaVersionOptions {\n    ecmaVersion ?: string | number\n  }\n\n  export interface CLIOptions extends BaseOptions, commander.Command {\n    color       ?: boolean\n    exitCode    ?: boolean\n    ecmaVersion ?: string\n  }\n\n  export interface CompareOptions extends BaseOptions, EcmaVersionOptions {}\n\n  interface ParseResultBase {\n    code     : string\n    is_class : boolean\n    path     : string\n    pos      : LineInfo\n    tokens   : string[]\n    type     : string\n  }\n\n  export interface TSParseResult extends ParseResultBase {\n    ast : ts.Node\n  }\n\n  export interface JSParseResult extends ParseResultBase {\n    ast : es.Node\n  }\n\n  export type ParseResult = JSParseResult | TSParseResult\n\n  export type ParseResultMatchList = ParseResult[][]\n\n  export interface ParseResultGroup {\n    [sim : string] : ParseResultMatchList\n  }\n\n  export interface ParseResultGroups {\n    js : ParseResultGroup\n    ts : ParseResultGroup\n  }\n\n  export interface LineInfo {\n    start ?: {\n      line    : number\n      column ?: number\n    }\n\n    end ?: {\n      line   : number\n      column ?: number\n    }\n  }\n\n  export interface Lib {\n    compare : (\n      files : string[],\n      opts  : CompareOptions\n    ) => ParseResultGroups\n\n    print : (\n      group    : synt.ParseResultGroup,\n      nocolors : boolean\n    ) => void\n\n    DEFAULT_NGRAM_LENGTH : number\n    DEFAULT_THRESHOLD    : number\n    DEFAULT_TOKEN_LENGTH : number\n  }\n}\n\n"
  },
  {
    "path": "src/@types/walk-sync/index.d.ts",
    "content": "declare module \"walk-sync\" {\n  interface WalkSyncOptions {\n    directories ?: boolean\n  }\n\n  function walk_sync(\n    target : string,\n    opts   ?: WalkSyncOptions\n  ) : string[]\n\n  export = walk_sync\n}\n"
  },
  {
    "path": "src/cli/file_collector.ts",
    "content": "import * as fs from \"fs\"\nimport * as path from \"path\"\nimport * as _ from \"lodash\"\nimport walk_sync = require(\"walk-sync\")\n\nconst all_files = (target : string) : string[] => {\n  if (fs.statSync(target).isDirectory()) {\n    const dirs = walk_sync(target, { directories: false })\n    return _.map(dirs, (dir : string) => path.join(target, dir))\n  } else {\n    return [ target ]\n  }\n}\n\nconst normalize_cli_targets = (\n  targets : string | string[]\n) : string[] => {\n  targets = _.concat([], targets)\n\n  let files : string[] = _.uniq(_.reduce(targets,\n    (paths : string[], target : string) =>\n      _.concat(paths, all_files(target)), []))\n\n  files = _.map(files, (file : string) =>\n    path.relative(process.cwd(), file))\n\n  return _.filter(files, (file : string) =>\n    /\\.(js|ts)$/.test(file))\n}\n\nexport {\n  normalize_cli_targets as files\n}\n"
  },
  {
    "path": "src/cli.ts",
    "content": "import { program } from \"commander\"\nimport * as espree from 'espree'\nimport * as similar from \"./similar\"\nimport * as fs_collector from \"./cli/file_collector\"\n\nconst pkg = require(\"./../package.json\") as synt.Package\n\nconst compare = (\n  targets : string[],\n  opts : synt.CLIOptions\n) => {\n  const files = fs_collector.files(targets)\n  const ecmaVersion = opts.ecmaVersion && opts.ecmaVersion != \"latest\" ?\n    parseInt(opts.ecmaVersion) : opts.ecmaVersion\n  const { js, ts } = similar.compare(files, { ...opts, ecmaVersion })\n\n  similar.print(js, opts.color)\n  similar.print(ts, opts.color)\n\n  if (opts.exitCode && (Object.keys(js).length > 0 || Object.keys(ts).length > 0)) {\n    process.exit(1)\n  }\n}\n\nconst configure = () => {\n  program\n    .version(pkg.version)\n    .command(\"analyze [paths...]\")\n    .alias(\"a\")\n    .option(\n      \"-s, --similarity [number]\",\n      `Lowest % similarity to look for ` +\n      `[default=${ similar.DEFAULT_THRESHOLD }].`)\n    .option(\n      \"-m, --min-length [number]\",\n      `Default token length a function needs to be to compare it ` +\n      `[default=${ similar.DEFAULT_TOKEN_LENGTH }].`)\n    .option(\n      \"-g, --ngram [number]\",\n      `Specify ngram length for comparing token sequences. ` +\n      `[default=${ similar.DEFAULT_NGRAM_LENGTH },2,3...]`)\n    .option(\"-n, --no-color\", \"Disable color output\")\n    .option(\"-e, --exit-code\", \"Exit with a nonzero code when issues found\")\n    .option(\n      \"-t, --source-type [value]\",\n      \"Set JS source type [default=module,script,commonjs]\")\n    .option(\n      \"-a, --ecma-version [value]\",\n      `Set JS version [default=latest,${espree.supportedEcmaVersions.join(\",\")}]`)\n    .action(compare)\n\n  program.on(\"--help\", () => {\n    console.log(\"  Command specific help:\")\n    console.log(\"\")\n    console.log(\"    {cmd} -h, --help\")\n    console.log(\"\")\n    console.log(\"  Examples:\")\n    console.log(\"\")\n    console.log(\"    $ synt analyze lib\")\n    console.log(\"    $ synt analyze -s 90 foo.js bar.js baz.js\")\n    console.log(\"\")\n  })\n}\n\nconst interpret = (argv : string[]) => {\n  configure()\n  program.parse(argv)\n}\n\nexport { interpret }\n"
  },
  {
    "path": "src/index.ts",
    "content": "import * as similar from \"./similar\"\n\nconst library : synt.Lib = similar\n\nexport = library\n"
  },
  {
    "path": "src/similar/javascript.ts",
    "content": "import * as escodegen from \"@javascript-obfuscator/escodegen\"\nimport * as espree from \"espree\"\nimport * as estraverse from \"estraverse\"\nimport * as es from \"estree\"\nimport * as fs from \"fs\"\nimport * as _ from \"lodash\"\n\nconst FUNCTION_OR_CLASS_NODE : string[] = [\n  espree.Syntax.ArrowFunctionExpression,\n  espree.Syntax.ClassDeclaration,\n  espree.Syntax.FunctionDeclaration,\n  espree.Syntax.FunctionExpression\n  // TODO: (FE/FD causes dupe of MD)\n  // espree.Syntaxt.MethodDefinition\n  ]\n\nconst normalize = (\n  token_list : espree.Token[]\n) : string[] =>\n  _.map(token_list, (t : espree.Token) => t.value)\n\nconst tokenize = (code : string, opts : synt.CompareOptions) : string[] => {\n  const tokenize_opts : espree.Options = {\n    ecmaVersion: opts.ecmaVersion || \"latest\",\n    sourceType: opts.sourceType || \"module\"\n  }\n\n  return normalize(espree.tokenize(code, tokenize_opts))\n}\n\nconst astify = (\n  code : string,\n  opts : synt.CompareOptions\n) : es.Program => {\n  const module_type : string = opts.sourceType || \"module\"\n  const ecma_version : string | number = opts.ecmaVersion || \"latest\"\n  const parse_opts : espree.Options = {\n    ecmaVersion: ecma_version,\n    loc: true,\n    sourceType: module_type\n  }\n  return espree.parse(code, parse_opts)\n}\n\nconst ast_to_code = (node : es.Node) => {\n  const opts = { format: { indent: { style: \"  \" } } }\n  return escodegen.generate(node, opts)\n}\n\nconst is_a_method_or_class = (node : es.Node) =>\n  _.some(FUNCTION_OR_CLASS_NODE, (type) => type === node.type)\n\nconst line_info = (node : es.Node) : es.SourceLocation => node.loc\n\nconst parse_methods_and_classes = (\n  root_node : es.Node,\n  filepath : string,\n  opts : synt.CompareOptions\n) : synt.ParseResult[] => {\n  const entries : synt.ParseResult[] = []\n\n  // TODO: need to construct a proper parent chain\n  estraverse.traverse(root_node, {\n    enter(node : es.Node, _parent : es.Node) {\n      if (!is_a_method_or_class(node)) return\n      const method = ast_to_code(node)\n      const tokens = tokenize(method, opts)\n      const is_class = node.type === espree.Syntax.ClassDeclaration\n      const result = {\n        ast: node,\n        code: method,\n        is_class,\n        path: filepath,\n        pos: line_info(node),\n        tokens,\n        type: node.type\n      }\n      entries.push(result)\n    }\n  })\n\n  return entries\n}\n\nconst find_similar_methods_and_classes = (\n  filepaths : string[],\n  opts : synt.CompareOptions\n) : synt.ParseResult[] =>\n  _.flatMap(filepaths, (filepath) => {\n    const code = fs.readFileSync(filepath).toString()\n    let node : es.Node\n\n    try {\n      node = astify(code, opts)\n    } catch (err) {\n      throw new Error(`in ${filepath}\\n\\n${_.get(err, \"stack\", err)}`)\n    }\n\n    return parse_methods_and_classes(node, filepath, opts)\n  })\n\nexport {\n  find_similar_methods_and_classes as find\n}\n"
  },
  {
    "path": "src/similar/ngram.ts",
    "content": "const generate = (\n  arr : string[],\n  len = 1\n) : string[] => {\n  if (len > arr.length) len = 1\n  if (len == 1) return arr\n\n  const sets : string[] = []\n\n  arr.forEach((token : string, index : number) => {\n    const s_len = index + len\n    if (s_len <= arr.length) {\n      sets.push(arr.slice(index, s_len).join(\"\"))\n    }\n  })\n\n  return sets\n}\n\nexport { generate }\n"
  },
  {
    "path": "src/similar/print.ts",
    "content": "import * as _ from \"lodash\"\nimport * as cardinal from \"cardinal\"\nimport * as chalk from \"chalk\"\n\nconst print = (\n  group : synt.ParseResultGroup,\n  color : boolean\n) : void => {\n  _.each(group, (results : synt.ParseResultMatchList, sim : string) => {\n    _.each(results, (result : synt.ParseResult[]) => {\n      const [src, cmp] = result\n\n      console.log(\"\")\n\n      const match_sim = sim + \"% similar\"\n      if (color) {\n        console.log(chalk.red.bold(match_sim))\n      } else {\n        console.log(match_sim)\n      }\n\n      console.log(\"\")\n      if (color) {\n        console.log(chalk.gray(\"in: \") + chalk.green(src.path))\n      } else {\n        console.log(`in: ${ src.path }`)\n      }\n\n      console.log(\"\")\n      if (color) {\n        console.log(cardinal.highlight(src.code, {\n          firstline: src.pos.start.line,\n          linenos: true\n        }))\n      } else {\n        console.log(src.code.split(\"\\n\").map((line : string, idx : number) => {\n          return `${src.pos.start.line + idx + 1}: ${line}`\n        }).join(\"\\n\"))\n      }\n      console.log(\"\")\n\n      if (src.path !== cmp.path) {\n        if (color) {\n          console.log(chalk.gray(\"in: \") + chalk.green(cmp.path))\n        } else {\n          console.log(`in: ${ cmp.path }`)\n        }\n        console.log(\"\")\n      }\n\n      if (color) {\n        console.log(cardinal.highlight(cmp.code, {\n          firstline: cmp.pos.start.line,\n          linenos: true\n        }))\n      } else {\n        console.log(cmp.code.split(\"\\n\").map((line : string, idx : number) => {\n          return `${cmp.pos.start.line + idx + 1}: ${line}`\n        }).join(\"\\n\"))\n      }\n\n    })\n  })\n}\n\nexport { print }\n"
  },
  {
    "path": "src/similar/typescript.ts",
    "content": "import * as _ from \"lodash\"\nimport * as fs from \"fs\"\nimport * as ts from \"typescript\"\n\nconst STOP_AT_NODES : ts.SyntaxKind[] = [\n  ts.SyntaxKind.ArrayType,\n  ts.SyntaxKind.PrefixUnaryExpression,\n  ts.SyntaxKind.RegularExpressionLiteral\n]\n\nconst FUNCTION_OR_CLASS_NODE : ts.SyntaxKind[] = [\n  ts.SyntaxKind.ArrowFunction,\n  ts.SyntaxKind.ClassDeclaration,\n  ts.SyntaxKind.Constructor,\n  ts.SyntaxKind.FunctionDeclaration,\n  ts.SyntaxKind.FunctionExpression,\n  ts.SyntaxKind.MethodDeclaration\n]\n\nconst PASSTHROUGH_NODES : ts.SyntaxKind[] = FUNCTION_OR_CLASS_NODE.concat([\n  ts.SyntaxKind.ArrowFunction,\n  ts.SyntaxKind.ArrayLiteralExpression,\n  ts.SyntaxKind.BinaryExpression,\n  ts.SyntaxKind.Block,\n  ts.SyntaxKind.CallExpression,\n  ts.SyntaxKind.CatchClause,\n  ts.SyntaxKind.ConditionalExpression,\n  ts.SyntaxKind.ElementAccessExpression,\n  ts.SyntaxKind.ExpressionStatement,\n  ts.SyntaxKind.FirstNode,\n  ts.SyntaxKind.FunctionExpression,\n  ts.SyntaxKind.FunctionDeclaration,\n  ts.SyntaxKind.FunctionType,\n  ts.SyntaxKind.IfStatement,\n  ts.SyntaxKind.IndexSignature,\n  ts.SyntaxKind.NewExpression,\n  ts.SyntaxKind.ObjectLiteralExpression,\n  ts.SyntaxKind.Parameter,\n  ts.SyntaxKind.ParenthesizedExpression,\n  ts.SyntaxKind.PropertyAccessExpression,\n  ts.SyntaxKind.PropertyAssignment,\n  ts.SyntaxKind.PropertyDeclaration,\n  ts.SyntaxKind.ReturnStatement,\n  ts.SyntaxKind.TemplateExpression,\n  ts.SyntaxKind.TemplateSpan,\n  ts.SyntaxKind.TryStatement,\n  ts.SyntaxKind.TypeReference,\n  ts.SyntaxKind.TypeLiteral,\n  ts.SyntaxKind.VariableDeclaration,\n  ts.SyntaxKind.VariableDeclarationList,\n  ts.SyntaxKind.VariableStatement\n])\n\nconst astify = (\n  code : string,\n  filepath : string,\n  _opts : synt.CompareOptions\n) : ts.SourceFile => {\n  ts.createProgram([ filepath ], {})\n  return ts.createSourceFile(\n    filepath,\n    code,\n    ts.ScriptTarget.Latest,\n    true, // setParentNodes\n    ts.ScriptKind.TS)\n}\n\nconst is_a_base_node = (node : ts.Node) : boolean =>\n  _.some(STOP_AT_NODES, (kind) => kind === node.kind)\n\nconst is_a_passthrough_node = (node : ts.Node) : boolean =>\n  _.some(PASSTHROUGH_NODES, (kind) => kind === node.kind)\n\nconst is_a_method_or_class = (node : ts.Node) : boolean =>\n  _.some(FUNCTION_OR_CLASS_NODE, (kind) => kind === node.kind)\n\nconst _tokenize = (\n  tokens : string[]\n) => (\n  node : ts.Node\n) => {\n  if (is_a_base_node(node)) {\n    tokens.push(node.getText())\n  } else if (is_a_passthrough_node(node)) {\n    ts.forEachChild(node, _tokenize(tokens))\n  } else {\n    tokens.push(node.getText())\n    ts.forEachChild(node, _tokenize(tokens))\n  }\n}\n\nconst tokenize = (ast_node : ts.Node) : string[] => {\n  const tokens : string[] = []\n  _tokenize(tokens)(ast_node)\n  return tokens\n}\n\nconst find_all_methods_and_classes = (\n  list : ts.Node[]\n) => (\n  node : ts.Node\n) => {\n  if (is_a_method_or_class(node)) { list.push(node) }\n  ts.forEachChild(node, find_all_methods_and_classes(list))\n}\n\nconst line_info = (\n  node : ts.Node,\n  root_node : ts.SourceFile\n) : synt.LineInfo => {\n  const { line, character } = root_node\n    .getLineAndCharacterOfPosition(node.getStart())\n  return {\n    start: {\n      column: character,\n      line: line + 1 // zero-indexed\n    }\n  }\n}\n\nconst parse_methods_and_classes = (\n  node : ts.Node,\n  root_node : ts.SourceFile,\n  path : string\n) : synt.ParseResult[] => {\n  const methods_and_classes : ts.Node[] = []\n\n  find_all_methods_and_classes(methods_and_classes)(node)\n\n  return _.map(methods_and_classes, (method_or_class : ts.Node) => {\n    const tokens = tokenize(method_or_class)\n    const code = method_or_class.getText()\n    const is_class = method_or_class.kind == ts.SyntaxKind.ClassDeclaration\n    return {\n      ast: method_or_class,\n      code,\n      is_class,\n      path,\n      pos: line_info(method_or_class, root_node),\n      tokens,\n      type: ts.SyntaxKind[method_or_class.kind]\n    }\n  })\n}\n\nconst find_similar_methods_and_classes = (\n  filepaths : string[],\n  opts : synt.CompareOptions\n) : synt.ParseResult[] =>\n  _.flatMap(filepaths, (filepath) => {\n    const code = fs.readFileSync(filepath).toString()\n    const node = astify(code, filepath, opts)\n    const root_node = node\n    return parse_methods_and_classes(node, root_node, filepath)\n  })\n\nexport {\n  find_similar_methods_and_classes as find\n}\n"
  },
  {
    "path": "src/similar.ts",
    "content": "import * as _ from \"lodash\"\nimport * as ngram from \"./similar/ngram\"\nimport * as parse_js from \"./similar/javascript\"\nimport * as parse_ts from \"./similar/typescript\"\nimport { print } from \"./similar/print\"\n\nconst DEFAULT_NGRAM_LENGTH = 1\nconst DEFAULT_THRESHOLD    = 70\nconst DEFAULT_TOKEN_LENGTH = 10\n\n// http://en.wikipedia.org/wiki/Jaccard_index\nconst similarity = (\n  src : synt.TokenList,\n  cmp : synt.TokenList\n) : number => {\n  const a = _.uniq(src)\n  const b = _.uniq(cmp)\n  const i = _.intersection(a, b)\n  const u = _.union(a, b)\n\n  return _.toNumber(\n      _.toNumber((i.length / u.length) * 100)\n        .toFixed(0))\n}\n\nconst parse_token_length = (str : string) : number =>\n  _.isEmpty(str) ?\n    DEFAULT_TOKEN_LENGTH :\n    _.toNumber(str)\n\nconst parse_ngram_length = (str : string) : number =>\n  _.isEmpty(str) ?\n    DEFAULT_NGRAM_LENGTH :\n    _.toNumber(str)\n\nconst parse_threshold = (str : string) : number => {\n  const threshold = _.toNumber(str)\n  return threshold || DEFAULT_THRESHOLD\n}\n\nconst is_ts_ancestor = (\n  src : synt.TSParseResult,\n  cmp : synt.TSParseResult\n) : boolean => {\n  let match = false\n\n  let last = src.ast\n\n  while (true) {\n    const { parent } = last\n    if (parent === cmp.ast) match = true\n    if (!parent || last === parent || match) break\n    last = parent\n  }\n\n  return match\n}\n\nconst false_positive = (\n  src : synt.ParseResult,\n  cmp : synt.ParseResult,\n  t_len : number\n) => {\n  const same_node = () => cmp.ast === src.ast\n\n  const size_is_too_different = () => {\n    const l1 = src.tokens.length\n    const l2 = cmp.tokens.length\n    return l1 * 2 < l2 || l2 * 2 < l1\n  }\n\n  const one_is_too_short = () =>\n    src.tokens.length < t_len ||\n      cmp.tokens.length < t_len\n\n  // HACK: TypeScript provides a parent chain\n  //       Esprima does not (out of the box), so we\n  //       also use hacky token string check to catch all\n  const subset_of_other = () : boolean => {\n    const is_eithers_ancestor = () : boolean =>\n      is_ts_ancestor(\n        (src as synt.TSParseResult),\n        (cmp as synt.TSParseResult)) ||\n      is_ts_ancestor(\n        (cmp as synt.TSParseResult),\n        (src as synt.TSParseResult))\n\n    const is_eithers_middle = () : boolean => {\n      const src_j = src.tokens.join(\"\")\n      const cmp_j = cmp.tokens.join(\"\")\n      return src_j !== cmp_j &&\n        (_.includes(src_j, cmp_j) ||\n          _.includes(cmp_j, src_j))\n    }\n\n    return is_eithers_ancestor() || is_eithers_middle()\n  }\n\n  const both_are_not_classes = () : boolean =>\n    (src.is_class && !cmp.is_class) ||\n      (!src.is_class && cmp.is_class)\n\n  return same_node() ||\n    both_are_not_classes() ||\n      subset_of_other() ||\n        one_is_too_short() ||\n          size_is_too_different()\n}\n\nconst each_pair = (\n  items : synt.ParseResult[],\n  callback : (\n    src : synt.ParseResult,\n    cmp : synt.ParseResult\n  ) => void\n) : void => {\n  _.each(items, (src) => {\n    _.each(items, (cmp) => {\n      callback(src, cmp)\n    })\n  })\n}\n\nconst filter_redundencies = (\n  group : synt.ParseResultGroup\n) : synt.ParseResultGroup => {\n  _.each(group, (\n    results : synt.ParseResultMatchList,\n    sim : string\n  ) => {\n    group[sim] = _.reduce(\n      results,\n      (\n        new_arr : synt.ParseResultMatchList,\n        result : synt.ParseResult[]\n      ) => {\n        const already_added : boolean = _.some(\n          new_arr, (result_two : synt.ParseResult[]) =>\n            _.xor(result, result_two).length === 0)\n        if (!already_added) { new_arr.push(result) }\n        return new_arr\n      },\n      ([] as synt.ParseResultMatchList))\n  })\n\n  return group\n}\n\nconst _compare = (\n  files : string[],\n  ftype : string,\n  opts  : synt.CompareOptions\n) : synt.ParseResultGroup => {\n  const is_ts = ftype === \"ts\"\n  const is_file = is_ts ? /\\.ts$/ : /\\.js$/\n  files = _.filter(files, (file) => is_file.test(file))\n  const parse = is_ts ? parse_ts : parse_js\n  const items : synt.ParseResult[] = parse.find(files, opts)\n  const group : synt.ParseResultGroup = {}\n  const t_len = parse_token_length(_.toString(opts.minLength))\n  const n_len = parse_ngram_length(_.toString(opts.ngram))\n  const sim_min = parse_threshold(_.toString(opts.similarity))\n\n  each_pair(items, (src : synt.ParseResult, cmp : synt.ParseResult) => {\n    if (false_positive(src, cmp, t_len)) return\n    const src_grams = ngram.generate(src.tokens, n_len)\n    const cmp_grams = ngram.generate(cmp.tokens, n_len)\n    const val = similarity(src_grams, cmp_grams)\n    if (val < sim_min) return\n    if (_.isEmpty(group[val])) group[val] = []\n    group[val].push([src, cmp])\n  })\n\n  return filter_redundencies(group)\n}\n\nconst compare = (\n  files : string[],\n  opts : synt.CompareOptions = {}\n) : synt.ParseResultGroups => {\n  files = _.concat([], files)\n  const js_group = _compare(files, \"js\", opts)\n  const ts_group = _compare(files, \"ts\", opts)\n  return { js: js_group, ts: ts_group }\n}\n\nexport {\n  DEFAULT_NGRAM_LENGTH,\n  DEFAULT_THRESHOLD,\n  DEFAULT_TOKEN_LENGTH,\n  compare,\n  print\n}\n"
  },
  {
    "path": "test/fixtures/cli_output/test-es-fail.js.txt",
    "content": ""
  },
  {
    "path": "test/fixtures/cli_output/test-es.js.txt",
    "content": "\n76% similar\n\nin: test/fixtures/system/test-es.js\n\n10: function diag(x, y) {\n11:   return sqrt(square(x) + square(y));\n12: }\n\n14: function dude(x, y) {\n15:   return sqrt(square(x ^ 2) + square(y));\n16: }\n"
  },
  {
    "path": "test/fixtures/cli_output/test.dir.color.txt",
    "content": "\n76% similar\n\nin: test/fixtures/system/test-es.js\n\n\u001b[90m 9: \u001b[94mfunction\u001b[39m \u001b[37mdiag\u001b[39m\u001b[90m(\u001b[39m\u001b[37mx\u001b[39m\u001b[32m,\u001b[39m \u001b[37my\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m10:   \u001b[31mreturn\u001b[39m \u001b[37msqrt\u001b[39m\u001b[90m(\u001b[39m\u001b[37msquare\u001b[39m\u001b[90m(\u001b[39m\u001b[37mx\u001b[39m\u001b[90m)\u001b[39m \u001b[93m+\u001b[39m \u001b[37msquare\u001b[39m\u001b[90m(\u001b[39m\u001b[37my\u001b[39m\u001b[90m)\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m11: \u001b[33m}\u001b[39m\n\n\u001b[90m13: \u001b[94mfunction\u001b[39m \u001b[37mdude\u001b[39m\u001b[90m(\u001b[39m\u001b[37mx\u001b[39m\u001b[32m,\u001b[39m \u001b[37my\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m14:   \u001b[31mreturn\u001b[39m \u001b[37msqrt\u001b[39m\u001b[90m(\u001b[39m\u001b[37msquare\u001b[39m\u001b[90m(\u001b[39m\u001b[37mx\u001b[39m \u001b[93m^\u001b[39m \u001b[34m2\u001b[39m\u001b[90m)\u001b[39m \u001b[93m+\u001b[39m \u001b[37msquare\u001b[39m\u001b[90m(\u001b[39m\u001b[37my\u001b[39m\u001b[90m)\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m15: \u001b[33m}\u001b[39m\n\n83% similar\n\nin: test/fixtures/system/test.js\n\n\u001b[90m63: \u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m64:   \u001b[94mconst\u001b[39m \u001b[37mdx\u001b[39m \u001b[93m=\u001b[39m \u001b[37ma\u001b[39m\u001b[32m.\u001b[39m\u001b[37mx\u001b[39m \u001b[93m-\u001b[39m \u001b[37mb\u001b[39m\u001b[32m.\u001b[39m\u001b[37mx\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m65:   \u001b[94mconst\u001b[39m \u001b[37mdy\u001b[39m \u001b[93m=\u001b[39m \u001b[37ma\u001b[39m\u001b[32m.\u001b[39m\u001b[37my\u001b[39m \u001b[93m-\u001b[39m \u001b[37mb\u001b[39m\u001b[32m.\u001b[39m\u001b[37my\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m66:   \u001b[31mreturn\u001b[39m \u001b[37mMath\u001b[39m\u001b[32m.\u001b[39m\u001b[37msqrt\u001b[39m\u001b[90m(\u001b[39m\u001b[37mdx\u001b[39m \u001b[93m*\u001b[39m \u001b[37mdx\u001b[39m \u001b[93m+\u001b[39m \u001b[37mdy\u001b[39m \u001b[93m*\u001b[39m \u001b[37mdy\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m67: \u001b[33m}\u001b[39m\n\n\u001b[90m70: \u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[37man\u001b[39m\u001b[32m,\u001b[39m \u001b[37mab\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m71:   \u001b[94mconst\u001b[39m \u001b[37mdx\u001b[39m \u001b[93m=\u001b[39m \u001b[37man\u001b[39m\u001b[32m.\u001b[39m\u001b[37mx\u001b[39m \u001b[93m-\u001b[39m \u001b[37mab\u001b[39m\u001b[32m.\u001b[39m\u001b[37mx\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m72:   \u001b[94mconst\u001b[39m \u001b[37mdy\u001b[39m \u001b[93m=\u001b[39m \u001b[37man\u001b[39m\u001b[32m.\u001b[39m\u001b[37my\u001b[39m \u001b[93m-\u001b[39m \u001b[37mab\u001b[39m\u001b[32m.\u001b[39m\u001b[37my\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m73:   \u001b[31mreturn\u001b[39m \u001b[37mMath\u001b[39m\u001b[32m.\u001b[39m\u001b[37msqrt\u001b[39m\u001b[90m(\u001b[39m\u001b[37mdx\u001b[39m \u001b[93m*\u001b[39m \u001b[37mdx\u001b[39m \u001b[93m+\u001b[39m \u001b[37mdy\u001b[39m \u001b[93m*\u001b[39m \u001b[37mdy\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m74: \u001b[33m}\u001b[39m\n\n89% similar\n\nin: test/fixtures/system/test.js\n\n\u001b[90m27: \u001b[94mclass\u001b[39m \u001b[37mFooBazzzz\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m28:   \u001b[37mconstructor\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m29:   \u001b[33m}\u001b[39m\n\u001b[90m30:   \u001b[94mstatic\u001b[39m \u001b[37mget\u001b[39m \u001b[37marea\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m31:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'a'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m32:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'b'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m33:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m34:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m35:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m36:   \u001b[33m}\u001b[39m\n\u001b[90m37: \u001b[33m}\u001b[39m\n\n\u001b[90m40: \u001b[94mclass\u001b[39m \u001b[37mFooBarrr\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m41:   \u001b[37mconstructor\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m42:   \u001b[33m}\u001b[39m\n\u001b[90m43:   \u001b[94mstatic\u001b[39m \u001b[37mget\u001b[39m \u001b[37marea\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m44:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'a'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m45:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'b'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m46:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m47:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m48:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m49:   \u001b[33m}\u001b[39m\n\u001b[90m50: \u001b[33m}\u001b[39m\n\n93% similar\n\nin: test/fixtures/system/test.copy.js\n\n\u001b[90m1: \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[93m=>\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3:   \u001b[94mif\u001b[39m \u001b[90m(\u001b[39m\u001b[93m!\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m4:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m5:   \u001b[33m}\u001b[39m\n\u001b[90m6: \u001b[33m}\u001b[39m\n\nin: test/fixtures/system/test.js\n\n\u001b[90m1: \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[93m=>\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37mb\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3:   \u001b[94mif\u001b[39m \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m4:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m5:   \u001b[33m}\u001b[39m\n\u001b[90m6: \u001b[33m}\u001b[39m\n\n93% similar\n\nin: test/fixtures/system/test.js\n\n\u001b[90m1: \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[93m=>\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37mb\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3:   \u001b[94mif\u001b[39m \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m4:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m5:   \u001b[33m}\u001b[39m\n\u001b[90m6: \u001b[33m}\u001b[39m\n\n\u001b[90m 9: \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[93m=>\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m10:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m11:   \u001b[94mif\u001b[39m \u001b[90m(\u001b[39m\u001b[93m!\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m12:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m13:   \u001b[33m}\u001b[39m\n\u001b[90m14: \u001b[33m}\u001b[39m\n\n100% similar\n\nin: test/fixtures/system/test.copy.js\n\n\u001b[90m1: \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[93m=>\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m2:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m3:   \u001b[94mif\u001b[39m \u001b[90m(\u001b[39m\u001b[93m!\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m4:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m5:   \u001b[33m}\u001b[39m\n\u001b[90m6: \u001b[33m}\u001b[39m\n\nin: test/fixtures/system/test.js\n\n\u001b[90m 9: \u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37mb\u001b[39m\u001b[90m)\u001b[39m \u001b[93m=>\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m10:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m11:   \u001b[94mif\u001b[39m \u001b[90m(\u001b[39m\u001b[93m!\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m12:     \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m13:   \u001b[33m}\u001b[39m\n\u001b[90m14: \u001b[33m}\u001b[39m\n\n100% similar\n\nin: test/fixtures/system/test.js\n\n\u001b[90m31: \u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m32:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'a'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m33:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'b'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m34:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m35:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m36:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m37: \u001b[33m}\u001b[39m\n\n\u001b[90m44: \u001b[94mfunction\u001b[39m \u001b[90m(\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m45:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'a'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m46:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'b'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m47:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m48:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m49:   \u001b[34mconsole\u001b[39m\u001b[32m.\u001b[39m\u001b[34mlog\u001b[39m\u001b[90m(\u001b[39m\u001b[92m'c'\u001b[39m\u001b[90m)\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m50: \u001b[33m}\u001b[39m\n\n87% similar\n\nin: test/fixtures/system/test.ts\n\n\u001b[90m20: \u001b[94mclass\u001b[39m \u001b[37mGreeter\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m21:   \u001b[37mgreeting\u001b[39m\u001b[93m:\u001b[39m \u001b[37mstring\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m22:   \u001b[37mconstructor\u001b[39m\u001b[90m(\u001b[39m\u001b[37mmessage\u001b[39m\u001b[93m:\u001b[39m \u001b[37mstring\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m23:     \u001b[91mthis\u001b[39m\u001b[32m.\u001b[39m\u001b[37mgreeting\u001b[39m \u001b[93m=\u001b[39m \u001b[37mmessage\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m24:   \u001b[33m}\u001b[39m\n\u001b[90m25:   \u001b[94mstatic\u001b[39m \u001b[37mgreet\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37my\u001b[39m\u001b[32m,\u001b[39m \u001b[37mx\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m26:     \u001b[94mlet\u001b[39m \u001b[37mb\u001b[39m \u001b[93m=\u001b[39m \u001b[37my\u001b[39m \u001b[93m+\u001b[39m \u001b[37mx\u001b[39m\n\u001b[90m27:     \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\"Hello, \"\u001b[39m \u001b[93m+\u001b[39m \u001b[91mthis\u001b[39m\u001b[32m.\u001b[39m\u001b[37mgreeting\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m28:   \u001b[33m}\u001b[39m\n\u001b[90m29: \u001b[33m}\u001b[39m\n\n\u001b[90m31: \u001b[94mclass\u001b[39m \u001b[37mFooGreeter\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m32:   \u001b[37mconstructor\u001b[39m\u001b[90m(\u001b[39m\u001b[37mmessage\u001b[39m\u001b[93m:\u001b[39m \u001b[37mstring\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m33:     \u001b[91mthis\u001b[39m\u001b[32m.\u001b[39m\u001b[37mgreeting\u001b[39m \u001b[93m=\u001b[39m \u001b[37mmessage\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m34:   \u001b[33m}\u001b[39m\n\u001b[90m35:   \u001b[94mstatic\u001b[39m \u001b[37mgreet\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37my\u001b[39m\u001b[32m,\u001b[39m \u001b[37mx\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m36:     \u001b[94mlet\u001b[39m \u001b[37mb\u001b[39m \u001b[93m=\u001b[39m \u001b[37mx\u001b[39m \u001b[93m+\u001b[39m \u001b[37my\u001b[39m\n\u001b[90m37:     \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\"Hello, \"\u001b[39m \u001b[93m+\u001b[39m \u001b[91mthis\u001b[39m\u001b[32m.\u001b[39m\u001b[37mgreeting\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m38:   \u001b[33m}\u001b[39m\n\u001b[90m39: \u001b[33m}\u001b[39m\n\n100% similar\n\nin: test/fixtures/system/test.ts\n\n\u001b[90m25: \u001b[94mstatic\u001b[39m \u001b[37mgreet\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37my\u001b[39m\u001b[32m,\u001b[39m \u001b[37mx\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m26:     \u001b[94mlet\u001b[39m \u001b[37mb\u001b[39m \u001b[93m=\u001b[39m \u001b[37my\u001b[39m \u001b[93m+\u001b[39m \u001b[37mx\u001b[39m\n\u001b[90m27:     \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\"Hello, \"\u001b[39m \u001b[93m+\u001b[39m \u001b[91mthis\u001b[39m\u001b[32m.\u001b[39m\u001b[37mgreeting\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m28:   \u001b[33m}\u001b[39m\n\n\u001b[90m35: \u001b[94mstatic\u001b[39m \u001b[37mgreet\u001b[39m\u001b[90m(\u001b[39m\u001b[37ma\u001b[39m\u001b[32m,\u001b[39m \u001b[37my\u001b[39m\u001b[32m,\u001b[39m \u001b[37mx\u001b[39m\u001b[90m)\u001b[39m \u001b[33m{\u001b[39m\n\u001b[90m36:     \u001b[94mlet\u001b[39m \u001b[37mb\u001b[39m \u001b[93m=\u001b[39m \u001b[37mx\u001b[39m \u001b[93m+\u001b[39m \u001b[37my\u001b[39m\n\u001b[90m37:     \u001b[31mreturn\u001b[39m \u001b[37ma\u001b[39m \u001b[93m+\u001b[39m \u001b[92m\"Hello, \"\u001b[39m \u001b[93m+\u001b[39m \u001b[91mthis\u001b[39m\u001b[32m.\u001b[39m\u001b[37mgreeting\u001b[39m\u001b[90m;\u001b[39m\n\u001b[90m38:   \u001b[33m}\u001b[39m\n"
  },
  {
    "path": "test/fixtures/cli_output/test.dir.txt",
    "content": "\n76% similar\n\nin: test/fixtures/system/test-es.js\n\n10: function diag(x, y) {\n11:   return sqrt(square(x) + square(y));\n12: }\n\n14: function dude(x, y) {\n15:   return sqrt(square(x ^ 2) + square(y));\n16: }\n\n83% similar\n\nin: test/fixtures/system/test.js\n\n64: function (a, b) {\n65:   const dx = a.x - b.x;\n66:   const dy = a.y - b.y;\n67:   return Math.sqrt(dx * dx + dy * dy);\n68: }\n\n71: function (an, ab) {\n72:   const dx = an.x - ab.x;\n73:   const dy = an.y - ab.y;\n74:   return Math.sqrt(dx * dx + dy * dy);\n75: }\n\n89% similar\n\nin: test/fixtures/system/test.js\n\n28: class FooBazzzz {\n29:   constructor() {\n30:   }\n31:   static get area() {\n32:     console.log('a');\n33:     console.log('b');\n34:     console.log('c');\n35:     console.log('c');\n36:     console.log('c');\n37:   }\n38: }\n\n41: class FooBarrr {\n42:   constructor() {\n43:   }\n44:   static get area() {\n45:     console.log('a');\n46:     console.log('b');\n47:     console.log('c');\n48:     console.log('c');\n49:     console.log('c');\n50:   }\n51: }\n\n93% similar\n\nin: test/fixtures/system/test.copy.js\n\n2: (a, b) => {\n3:   console.log();\n4:   if (!a) {\n5:     console.log(a);\n6:   }\n7: }\n\nin: test/fixtures/system/test.js\n\n2: (a, b) => {\n3:   console.log(b);\n4:   if (a) {\n5:     console.log(a);\n6:   }\n7: }\n\n93% similar\n\nin: test/fixtures/system/test.js\n\n2: (a, b) => {\n3:   console.log(b);\n4:   if (a) {\n5:     console.log(a);\n6:   }\n7: }\n\n10: (a, b) => {\n11:   console.log();\n12:   if (!a) {\n13:     console.log(a);\n14:   }\n15: }\n\n100% similar\n\nin: test/fixtures/system/test.copy.js\n\n2: (a, b) => {\n3:   console.log();\n4:   if (!a) {\n5:     console.log(a);\n6:   }\n7: }\n\nin: test/fixtures/system/test.js\n\n10: (a, b) => {\n11:   console.log();\n12:   if (!a) {\n13:     console.log(a);\n14:   }\n15: }\n\n100% similar\n\nin: test/fixtures/system/test.js\n\n32: function () {\n33:   console.log('a');\n34:   console.log('b');\n35:   console.log('c');\n36:   console.log('c');\n37:   console.log('c');\n38: }\n\n45: function () {\n46:   console.log('a');\n47:   console.log('b');\n48:   console.log('c');\n49:   console.log('c');\n50:   console.log('c');\n51: }\n\n87% similar\n\nin: test/fixtures/system/test.ts\n\n21: class Greeter {\n22:   greeting: string;\n23:   constructor(message: string) {\n24:     this.greeting = message;\n25:   }\n26:   static greet(a, y, x) {\n27:     let b = y + x\n28:     return a + \"Hello, \" + this.greeting;\n29:   }\n30: }\n\n32: class FooGreeter {\n33:   constructor(message: string) {\n34:     this.greeting = message;\n35:   }\n36:   static greet(a, y, x) {\n37:     let b = x + y\n38:     return a + \"Hello, \" + this.greeting;\n39:   }\n40: }\n\n100% similar\n\nin: test/fixtures/system/test.ts\n\n26: static greet(a, y, x) {\n27:     let b = y + x\n28:     return a + \"Hello, \" + this.greeting;\n29:   }\n\n36: static greet(a, y, x) {\n37:     let b = x + y\n38:     return a + \"Hello, \" + this.greeting;\n39:   }\n"
  },
  {
    "path": "test/fixtures/cli_output/test.js.txt",
    "content": "\n83% similar\n\nin: test/fixtures/system/test.js\n\n64: function (a, b) {\n65:   const dx = a.x - b.x;\n66:   const dy = a.y - b.y;\n67:   return Math.sqrt(dx * dx + dy * dy);\n68: }\n\n71: function (an, ab) {\n72:   const dx = an.x - ab.x;\n73:   const dy = an.y - ab.y;\n74:   return Math.sqrt(dx * dx + dy * dy);\n75: }\n\n89% similar\n\nin: test/fixtures/system/test.js\n\n28: class FooBazzzz {\n29:   constructor() {\n30:   }\n31:   static get area() {\n32:     console.log('a');\n33:     console.log('b');\n34:     console.log('c');\n35:     console.log('c');\n36:     console.log('c');\n37:   }\n38: }\n\n41: class FooBarrr {\n42:   constructor() {\n43:   }\n44:   static get area() {\n45:     console.log('a');\n46:     console.log('b');\n47:     console.log('c');\n48:     console.log('c');\n49:     console.log('c');\n50:   }\n51: }\n\n93% similar\n\nin: test/fixtures/system/test.js\n\n2: (a, b) => {\n3:   console.log(b);\n4:   if (a) {\n5:     console.log(a);\n6:   }\n7: }\n\n10: (a, b) => {\n11:   console.log();\n12:   if (!a) {\n13:     console.log(a);\n14:   }\n15: }\n\n100% similar\n\nin: test/fixtures/system/test.js\n\n32: function () {\n33:   console.log('a');\n34:   console.log('b');\n35:   console.log('c');\n36:   console.log('c');\n37:   console.log('c');\n38: }\n\n45: function () {\n46:   console.log('a');\n47:   console.log('b');\n48:   console.log('c');\n49:   console.log('c');\n50:   console.log('c');\n51: }\n"
  },
  {
    "path": "test/fixtures/cli_output/test.ngram.js.txt",
    "content": "\n89% similar\n\nin: test/fixtures/system/test.js\n\n28: class FooBazzzz {\n29:   constructor() {\n30:   }\n31:   static get area() {\n32:     console.log('a');\n33:     console.log('b');\n34:     console.log('c');\n35:     console.log('c');\n36:     console.log('c');\n37:   }\n38: }\n\n41: class FooBarrr {\n42:   constructor() {\n43:   }\n44:   static get area() {\n45:     console.log('a');\n46:     console.log('b');\n47:     console.log('c');\n48:     console.log('c');\n49:     console.log('c');\n50:   }\n51: }\n\n100% similar\n\nin: test/fixtures/system/test.js\n\n32: function () {\n33:   console.log('a');\n34:   console.log('b');\n35:   console.log('c');\n36:   console.log('c');\n37:   console.log('c');\n38: }\n\n45: function () {\n46:   console.log('a');\n47:   console.log('b');\n48:   console.log('c');\n49:   console.log('c');\n50:   console.log('c');\n51: }\n"
  },
  {
    "path": "test/fixtures/cli_output/test.similarity.js.txt",
    "content": "\n100% similar\n\nin: test/fixtures/system/test.js\n\n32: function () {\n33:   console.log('a');\n34:   console.log('b');\n35:   console.log('c');\n36:   console.log('c');\n37:   console.log('c');\n38: }\n\n45: function () {\n46:   console.log('a');\n47:   console.log('b');\n48:   console.log('c');\n49:   console.log('c');\n50:   console.log('c');\n51: }\n"
  },
  {
    "path": "test/fixtures/cli_output/test.token.js.txt",
    "content": "\n89% similar\n\nin: test/fixtures/system/test.js\n\n28: class FooBazzzz {\n29:   constructor() {\n30:   }\n31:   static get area() {\n32:     console.log('a');\n33:     console.log('b');\n34:     console.log('c');\n35:     console.log('c');\n36:     console.log('c');\n37:   }\n38: }\n\n41: class FooBarrr {\n42:   constructor() {\n43:   }\n44:   static get area() {\n45:     console.log('a');\n46:     console.log('b');\n47:     console.log('c');\n48:     console.log('c');\n49:     console.log('c');\n50:   }\n51: }\n"
  },
  {
    "path": "test/fixtures/cli_output/test.ts.txt",
    "content": "\n87% similar\n\nin: test/fixtures/system/test.ts\n\n21: class Greeter {\n22:   greeting: string;\n23:   constructor(message: string) {\n24:     this.greeting = message;\n25:   }\n26:   static greet(a, y, x) {\n27:     let b = y + x\n28:     return a + \"Hello, \" + this.greeting;\n29:   }\n30: }\n\n32: class FooGreeter {\n33:   constructor(message: string) {\n34:     this.greeting = message;\n35:   }\n36:   static greet(a, y, x) {\n37:     let b = x + y\n38:     return a + \"Hello, \" + this.greeting;\n39:   }\n40: }\n\n100% similar\n\nin: test/fixtures/system/test.ts\n\n26: static greet(a, y, x) {\n27:     let b = y + x\n28:     return a + \"Hello, \" + this.greeting;\n29:   }\n\n36: static greet(a, y, x) {\n37:     let b = x + y\n38:     return a + \"Hello, \" + this.greeting;\n39:   }\n"
  },
  {
    "path": "test/fixtures/system/test-es.js",
    "content": "import { readFile } from \"fs\"\nimport * as path from \"path\";\n\nexport const sqrt = Math.sqrt;\n\nexport function square(x) {\n    return x * x;\n}\nexport function diag(x, y) {\n    return sqrt(square(x) + square(y));\n}\n\nexport function dude(x, y) {\n    return sqrt(square(x^2) + square(y));\n}\n"
  },
  {
    "path": "test/fixtures/system/test.copy.js",
    "content": "const foo_two = (a, b) => {\n  console.log()\n\n  if (!a) {\n    console.log(a)\n  }\n}\n"
  },
  {
    "path": "test/fixtures/system/test.js",
    "content": "const foo = (a, b) => {\n  console.log(b)\n\n  if (a) {\n    console.log(a)\n  }\n}\n\nconst foo_two = (a, b) => {\n  console.log()\n\n  if (!a) {\n    console.log(a)\n  }\n}\n\nconst bar = () => true && \"val\"\n\nfunction baz() {}\n\nfunction dude() {\n  return function haha() {\n    console.log(\"hi!\")\n  }\n}\n\nclass FooBazzzz {\n  constructor() {\n  }\n\n  static get area() {\n    console.log('a')\n    console.log('b')\n    console.log('c')\n    console.log('c')\n    console.log('c')\n  }\n}\n\nclass FooBarrr {\n  constructor() {\n  }\n\n  static get area() {\n    console.log('a')\n    console.log('b')\n    console.log('c')\n    console.log('c')\n    console.log('c')\n  }\n}\n\nclass Rectangle {\n  constructor(height, width) {\n    this.height = height;\n    this.width = width;\n  }\n\n  get area() {\n    return this.calcArea();\n  }\n\n  static distance(a, b) {\n    const dx = a.x - b.x;\n    const dy = a.y - b.y;\n\n    return Math.sqrt(dx*dx + dy*dy);\n  }\n\n  static foobar(an, ab) {\n    const dx = an.x - ab.x;\n    const dy = an.y - ab.y;\n\n    return Math.sqrt(dx*dx + dy*dy);\n  }\n}\n"
  },
  {
    "path": "test/fixtures/system/test.ts",
    "content": "const foo = (a : string, b : number) : number => {\n  console.log(b)\n\n  if (!a && !b) {\n    console.log(a)\n  } else {\n    return 1\n  }\n}\n\nvar f = function () {\n}\n\nfunction some_method = (x) => (a) => console.log(\"DS\")\n\nmodule haha {\n  function Huz () {}\n}\n\nclass Greeter {\n  greeting: string;\n  constructor(message: string) {\n    this.greeting = message;\n  }\n  static greet(a, y, x) {\n    let b = y + x\n    return a + \"Hello, \" + this.greeting;\n  }\n}\n\nclass FooGreeter {\n  constructor(message: string) {\n    this.greeting = message;\n  }\n  static greet(a, y, x) {\n    let b = x + y\n    return a + \"Hello, \" + this.greeting;\n  }\n}\n\nlet greeter = new Greeter(\"world\");\nlet foobar = function (x : number, s : any) : number[] {\n  let a = [1, 2]\n  let s = new Huz(function (t, r) {});\n  a.forEach((i) => {\n    console.log(i)\n  })\n  return a\n}\n"
  },
  {
    "path": "test/helpers/sinon_chai.coffee",
    "content": "sinon = require \"sinon\"\nchai = require \"chai\"\nsinonChai = require \"sinon-chai\"\n\nchai.use sinonChai\n    .use chai.should\n    .should()\n"
  },
  {
    "path": "test/helpers/system.coffee",
    "content": "os = require \"os\"\npath = require \"path\"\nchild_process = require \"child_process\"\nchai = require \"chai\"\non_win = os.platform() == \"win32\"\nexpect = chai.expect\n\nSYNT_BIN = path.join(__dirname, \"..\", \"..\", \"bin\", \"synt\")\n\nexec = (args, cb, stdio) ->\n  cmd = undefined\n\n  cmd = \"#{SYNT_BIN} #{args}\"\n\n  cli_args = cmd.split(\" \")\n  proc = child_process.spawn(\n    \"node\",\n    cli_args,\n    stdio: stdio,\n    env: process.env)\n\n  out = \"\"\n  err = \"\"\n  error = undefined\n  cb_called = undefined\n\n  proc.stdout.on \"data\", (d) -> out += d\n  proc.stderr.on \"data\", (d) -> err += d\n\n  proc.on \"error\", (e) ->\n    unless cb_called\n      cb_called = true\n      if on_win\n        out = new Buffer.from(out).toString(\"utf-8\").replace(/\\r\\n/g, \"\\n\")\n      else\n        out = new Buffer.from(out).toString(\"utf-8\")\n      cb(\n        e,\n        out,\n        new Buffer.from(err).toString(\"utf-8\"))\n\n  proc.on \"close\", (code) ->\n    unless cb_called\n      cb_called = true\n      if on_win\n        out = new Buffer.from(out).toString(\"utf-8\").replace(/\\r\\n/g, \"\\n\")\n      else\n        out = new Buffer.from(out).toString(\"utf-8\")\n      cb(\n        { code: code },\n        out,\n        new Buffer.from(err).toString(\"utf-8\"))\n\n  proc\n\nmodule.exports = exec: exec\n"
  },
  {
    "path": "test/mocha.opts",
    "content": "--compilers coffee:coffee-script/register\n-R dot\n-t 5000\n-s 3000\n"
  },
  {
    "path": "test/spec/index.coffee",
    "content": "chai = require \"chai\"\nlibrary = require \"./../../lib\"\nexpect = chai.expect\n\ndescribe \"unit :: library\", ->\n  describe \"when required\", ->\n    it \"exports the library\", ->\n      expect(library).to.have.property(\"compare\")\n      expect(library).to.have.property(\"print\")\n      expect(library).to.have.property(\"DEFAULT_NGRAM_LENGTH\")\n      expect(library).to.have.property(\"DEFAULT_THRESHOLD\")\n      expect(library).to.have.property(\"DEFAULT_TOKEN_LENGTH\")\n"
  },
  {
    "path": "test/spec/similar/ngram.coffee",
    "content": "sinon_chai = require \"./../../helpers/sinon_chai\"\nchai = require \"chai\"\nngram = require \"./../../../lib/similar/ngram\"\nexpect = chai.expect\n\ndescribe \"unit :: ngram\", ->\n  describe \"generating ngrams\", ->\n    list = [\"1\", \"2\", \"3\", \"4\"]\n\n    it \"defaults to 1 if larger than array length\", ->\n      expect(ngram.generate list, 200)\n        .to.eql [\"1\", \"2\", \"3\", \"4\"]\n\n    it \"can generate a unigram by default\", ->\n      expect(ngram.generate list)\n        .to.eql [\"1\", \"2\", \"3\", \"4\"]\n\n    it \"can generate a unigram\", ->\n      expect(ngram.generate list, 1)\n        .to.eql [\"1\", \"2\", \"3\", \"4\"]\n\n    it \"can generate a bigram\", ->\n      expect(ngram.generate list, 2)\n        .to.eql [\"12\", \"23\", \"34\"]\n\n    it \"can generate a trigram\", ->\n      expect(ngram.generate list, 3)\n        .to.eql [\"123\", \"234\"]\n"
  },
  {
    "path": "test/spec/similar.coffee",
    "content": "sinon_chai = require \"./../helpers/sinon_chai\"\nchai = require \"chai\"\nsimilar = require \"./../../lib/similar\"\nexpect = chai.expect\n\ndescribe \"unit :: similar\", ->\n  describe \"when no args/opts are provided\", ->\n    it \"does not die\", ->\n      similar.compare()\n"
  },
  {
    "path": "test/spec/system.coffee",
    "content": "fs = require \"fs\"\nos = require \"os\"\npath = require \"path\"\nchai = require \"chai\"\npkg = require \"./../../package\"\nsystem = require \"./../helpers/system\"\non_win = os.platform() == \"win32\"\nexpect = chai.expect\n\nFIXTURES = path.join __dirname, \"..\", \"fixtures\"\nSYSTEM = path.join FIXTURES, \"system\"\nFILE_JS = path.join SYSTEM, \"test.js\"\nFILE_JS_ES = path.join SYSTEM, \"test-es.js\"\nFILE_TS = path.join SYSTEM, \"test.ts\"\n\nCLI_OUTPUT_TEST_JS = path\n  .join FIXTURES, \"cli_output\", \"test.js.txt\"\nCLI_OUTPUT_TEST_ES_MODULES = path\n  .join FIXTURES, \"cli_output\", \"test-es.js.txt\"\nCLI_OUTPUT_TEST_ES_MODULES_FAIL = path\n  .join FIXTURES, \"cli_output\", \"test-es-fail.js.txt\"\nCLI_OUTPUT_TEST_JS_COLOR = path\n  .join FIXTURES, \"cli_output\", \"test.js.color.txt\"\nCLI_OUTPUT_TEST_JS_SIM = path\n  .join FIXTURES, \"cli_output\", \"test.similarity.js.txt\"\nCLI_OUTPUT_TEST_JS_NGRAM = path\n  .join FIXTURES, \"cli_output\", \"test.ngram.js.txt\"\nCLI_OUTPUT_TEST_JS_TOKEN = path\n  .join FIXTURES, \"cli_output\", \"test.token.js.txt\"\nCLI_OUTPUT_TEST_TS = path\n  .join FIXTURES, \"cli_output\", \"test.ts.txt\"\nCLI_OUTPUT_TEST_JS_TS_DIR = path\n  .join FIXTURES, \"cli_output\", \"test.dir.txt\"\nCLI_OUTPUT_TEST_JS_TS_DIR_COLOR = path\n  .join FIXTURES, \"cli_output\", \"test.dir.color.txt\"\n\ncli_output = (path) ->\n  if on_win\n    fs.readFileSync(path)\n      .toString()\n      .replace(/\\r\\n/g, \"\\n\")\n      .replace(/\\//g, \"\\\\\")\n  else\n    fs.readFileSync(path)\n      .toString()\n\n# TODO: consider testing more in depth for false positives\n#       -> currently these tests cover a lot of it indirectly\n\ndescribe \"system :: cli\", ->\n  describe \"javascript\", ->\n    it \"can compare similar functions and classes\", (done) ->\n      cmd = \"analyze -n #{FILE_JS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS)\n          expect(error.code).to.eql 0\n          done()\n\n    describe \"es modules\", ->\n      describe \"when estype is not set (module by default)\", ->\n        it \"parses the code as expected\", (done) ->\n          cmd = \"analyze -n #{FILE_JS_ES}\"\n\n          system.exec cmd,\n            (error, stdout, stderr) ->\n              expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_ES_MODULES)\n              expect(error.code).to.eql 0\n              done()\n\n      describe \"when estype is set as script\", ->\n        it \"fails to parse the code\", (done) ->\n          cmd = \"analyze -n -a 6 -t script #{FILE_JS_ES}\"\n\n          system.exec cmd,\n            (error, stdout, stderr) ->\n              expect(stderr).to.match /espree/i\n              expect(stderr).to.match /'import' and 'export' may appear only with/i\n              expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_ES_MODULES_FAIL)\n              expect(error.code).to.eql 1\n              done()\n\n    describe \"when a file fails to parse\", ->\n      it \"also shows the filename\", (done) ->\n        cmd = \"analyze -n -t script #{FILE_JS_ES}\"\n\n        system.exec cmd,\n          (error, stdout, stderr) ->\n            if on_win\n              expect(stderr)\n                .to.match /Error: in test\\\\fixtures\\\\system\\\\test\\-es\\.js/gi\n            else\n              expect(stderr)\n                .to.match new RegExp(\"Error: in test/fixtures/system/test-es.js\")\n\n            expect(stderr).to.match /'import' and 'export' may appear only with/i\n            expect(stderr).match /espree/i\n            expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_ES_MODULES_FAIL)\n            expect(error.code).to.eql 1\n            done()\n\n  describe \"typescript\", ->\n    it \"can compare similar functions and classes\", (done) ->\n      cmd = \"analyze -n #{FILE_TS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_TS)\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can exit with a non zero code\", (done) ->\n      cmd = \"analyze -e -n #{FILE_TS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_TS)\n          expect(error.code).to.eql 1\n          done()\n\n  describe \"in general\", ->\n    it \"can print help\", (done) ->\n      system.exec \"--help\",\n        (error, stdout, stderr) ->\n          expect(stdout).to.match /options:/i\n          expect(stdout).to.match /examples:/i\n          expect(stdout).to.match /commands:/i\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can print command specific help\", (done) ->\n      system.exec \"analyze -h\",\n        (error, stdout, stderr) ->\n          expect(stdout).to.match /analyze\\|a/\n          expect(stdout).to.match /\\-s/\n          expect(stdout).to.match /\\-n/\n          expect(stdout).to.match /\\-m/\n          expect(error.code).to.eql 0\n          done()\n\n    it \"prints the version\", (done) ->\n      cmd = \"-V\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.match new RegExp pkg.version\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can set analyze sim threshold\", (done) ->\n      cmd = \"analyze -s 95 -n #{FILE_JS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS_SIM)\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can set ngram level\", (done) ->\n      cmd = \"analyze -g 10 -n #{FILE_JS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS_NGRAM)\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can set token level\", (done) ->\n      cmd = \"analyze -m 50 -n #{FILE_JS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS_TOKEN)\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can set non zero exit status\", (done) ->\n      cmd = \"analyze -e -m 50 -n #{FILE_JS}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS_TOKEN)\n          expect(error.code).to.eql 1\n          done()\n\n    it \"can output in colors\", (done) ->\n      cmd = \"analyze #{SYSTEM}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS_TS_DIR_COLOR)\n          expect(error.code).to.eql 0\n          done()\n\n    it \"can compare via a dir\", (done) ->\n      cmd = \"analyze -n #{SYSTEM}\"\n\n      system.exec cmd,\n        (error, stdout, stderr) ->\n          expect(stdout).to.eql(cli_output CLI_OUTPUT_TEST_JS_TS_DIR)\n          expect(error.code).to.eql 0\n          done()\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"target\": \"es6\",\n    \"moduleResolution\": \"node\",\n    \"forceConsistentCasingInFileNames\": true,\n    \"noEmitOnError\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"noImplicitAny\": true,\n    \"noImplicitReturns\": true,\n    \"noImplicitThis\": true,\n    \"noUnusedLocals\": true,\n    \"removeComments\": true,\n    \"outDir\": \"lib\",\n    \"rootDir\": \"src\",\n    \"typeRoots\": [\n      \"src/@types\"\n    ]\n  },\n  \"exclude\": [\n    \"node_modules\",\n    \"test\"\n  ]\n}\n"
  }
]