[
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n    env: {\n        node: true,\n        commonjs: true,\n        es2021: true,\n    },\n    extends: [\n        \"eslint:recommended\",\n        \"plugin:@typescript-eslint/recommended\",\n        \"plugin:import/recommended\",\n        \"plugin:import/typescript\",\n    ],\n    parser: \"@typescript-eslint/parser\",\n    parserOptions: {\n        ecmaVersion: 2015,\n    },\n    plugins: [\"@typescript-eslint\", \"import\"],\n    settings: {\n        \"import/parsers\": {\n            \"@typescript-eslint/parser\": [\".ts\", \".tsx\"],\n        },\n    },\n    rules: {\n        \"import/order\": [\n            \"error\",\n            {\n                \"alphabetize\": { order: \"asc\", caseInsensitive: true },\n                \"groups\": [\"builtin\", \"external\", \"internal\", \"parent\", \"sibling\", \"index\"],\n                \"newlines-between\": \"always\",\n            },\n        ],\n    },\n};\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Deploy to Heroku\n\non:\n    push:\n        branches:\n            - master\n\njobs:\n    deploy:\n        runs-on: ubuntu-latest\n        steps:\n            - name: Checkout master\n              uses: actions/checkout@v2\n              with:\n                  ref: master\n\n            - name: Push to Heroku\n              run: |\n                  git fetch origin master --unshallow\n                  git push https://heroku:${{ secrets.HEROKU_API_KEY }}@git.heroku.com/pagespeed-insights.git master\n"
  },
  {
    "path": ".github/workflows/pagespeed.yml",
    "content": "name: Get Pagespeed results\non:\n  # schedule:\n    # * is a special character in YAML so you have to quote this string\n    # - cron:  '0 0 * * *' # 00:00 UTC\n  # Allows you to run this workflow manually from the Actions tab\n  workflow_dispatch:\n\njobs:\n  getpsresults:\n    env:\n      HOST: your_website_url\n      PSURL: https://pagespeed-insights.herokuapp.com\n      PSRDESKTOP: psresultdesktop\n      PSRMOBILE: psresultmobile\n      RESULTSFOLDER: reports\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v2 # This is a premade github action\n      with:\n        persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token\n        fetch-depth: 0 # otherwise, you will failed to push refs to dest repo\n    - name: Create local changes\n      run: | # Have to be sure a folder is present if not, make it\n          mkdir -p ${RESULTSFOLDER}\n          curl \"${PSURL}/?url=${HOST}\" > ./${RESULTSFOLDER}/${PSRDESKTOP}.svg\n          curl \"${PSURL}/?url=${HOST}&strategy=mobile\" > ./${RESULTSFOLDER}/${PSRMOBILE}.svg\n    - name: Commit files \n      run: |\n        git add .\n        git config --local user.email \"actions@github.com\"\n        git config --local user.name \"github-actions[bot]\"\n        git diff --quiet && git diff --staged --quiet || git commit -am \"Updated Pagespeed results\"\n    - name: Push changes\n      uses: ad-m/github-push-action@master # This is a premade github action\n      with:\n        github_token: ${{ secrets.GITHUB_TOKEN }}\n        branch: ${{ github.ref }}\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nkey.txt\n.env\ndist/"
  },
  {
    "path": ".prettierignore",
    "content": "assets\n*.md"
  },
  {
    "path": ".prettierrc",
    "content": "{\n    \"endOfLine\": \"lf\",\n    \"semi\": true,\n    \"singleQuote\": false,\n    \"tabWidth\": 4,\n    \"printWidth\": 120,\n    \"trailingComma\": \"es5\",\n    \"quoteProps\": \"consistent\"\n}\n"
  },
  {
    "path": ".vscode/extensions.json",
    "content": "{\n    \"recommendations\": [\"dbaeumer.vscode-eslint\", \"esbenp.prettier-vscode\"]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n    \"files.watcherExclude\": {\n        \"**/.git/objects/**\": true,\n        \"**/.git/subtree-cache/**\": true,\n        \"**/node_modules/*/**\": true,\n        \"**/.hg/store/**\": true\n    },\n    \"files.exclude\": {\n        \"**/.git\": true,\n        \"**/.svn\": true,\n        \"**/.hg\": true,\n        \"**/CVS\": true,\n        \"**/.DS_Store\": true,\n        \"**/node_modules\": true,\n        \"**/Thumbs.db\": true\n    },\n    \"editor.formatOnSave\": true,\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "<p align=\"center\">\n\t<img src=\"./assets/banner.svg\" width=\"800px\">\n</p>\n\n<h1 align='center'>PageSpeed Insights for README</h1>\n\n\n> Embed your website's pagespeed score to your readme\n\n\n### About PageSpeed Insights\nPageSpeed Insights analyzes the content of a web page, then generates suggestions to make that page faster. [Learn more](https://developers.google.com/speed/docs/insights/about/).\n\n\n## Info\n\n### Guages\n<p align=\"center\">\n\t<img width=\"800px\" src=\"./assets/guages.svg\">\n</p>\n\n### PWA\n<p align=\"center\">\n\t<img width=\"800px\" src=\"./assets/pwa.svg\">\n</p>\n\n## API and Usage\n\n__Important note: Do not embed url to readme, instead embed generated svg__\n- It takes time to perform audits of website. So embedding it directly in readme would not render due to server timeout. Instead you must first visit and download the svg from the api (by simply visiting api url with desired parameters). And then embed that svg to your README files.\n- Typically it takes 10-15 seconds to obtain the results from pagespeed api\n- Some servers don't allow (eg. google.com) or delay (eg. cloudflare) pagespeed crawler, so it may result in unexpected results.\n- The result may fluctuate slightly sometimes.\n\n### API url\nThe api is called from `https://pagespeed-insights.herokuapp.com`\n\n### Simple usage\nIn simple form it will return result for all categories for desktop version of your website. Replace `your_website_url` with your website's url\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url\n```\nFor example\n```md\nhttps://pagespeed-insights.herokuapp.com?url=https://ankurparihar.github.io\n```\n\n### Theme\nDefault result is theme-agnostic i.e. looks good in both light and dark environment. But you can force one of two additional themes that are `light` and `dark`.\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url&theme=dark\n```\n\n### Strategy\nStrategy specifies the type of device your website is audited for. You can specify `strategy` as either `mobile` or `desktop`. If none is specified `desktop` is chosen\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url&strategy=mobile\n```\n\n### Category\nThere are 5 categories (in order)\n| Category Name | param |\n|-------------|---------------|\n| Performance | `performance` |\n| Accessibility | `accessibility` |\n| Best Practices | `best-practices` |\n| SEO | `seo` |\n| Progressive Web App | `pwa` |\n\nIf not specified, all the categories are evaluated. But you can specify only categories which you want to evaluate. The `category` parameter is comma-separated category indicators.\n\nExamples:\n\n#### Only performance\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url&categories=performance\n```\n\n#### All but PWA\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url&categories=performance,accessibility,best-practices,seo\n```\n\n#### Ordering\n\nOrder of categories is preserved\n\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url&categories=seo,performance,accessibility\n```\n\n### Options\nAdditional options you can specify in query parameter\n| Name (default) | Description |\n|------|-------------|\n| `perfTestCount (1)` | Specify how many times __performance__ test to run |\n\n<!-- \n### Accuracy\n\nPerformance is volatile so you can request up to 3 performance tests to retrieve more precise results\n```md\nhttps://pagespeed-insights.herokuapp.com?url=your_website_url&tests=30\n``` -->\n\n### Embedding into readme\nAfter downloading svg you can embed into readme as following\n- markdown method\n```\n![alt text](path/to/svg \"tooltip text\")\n```\n- html method\n```html\n<p align=\"center\">\t<!-- (optional) center align -->\n    <img src=\"/path/to/svg\" width=\"XXXpx\">\n</p>\n```\n\n### Keep results updated with action workflow\n- [pagespeed.yml](.github/workflows/pagespeed.yml)\n\n### Example\n- [ankurparihar.github.io](https://github.com/ankurparihar/ankurparihar.github.io#readme)"
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"readme-pagespeed-insights\",\n    \"version\": \"1.0.2\",\n    \"description\": \"GitHub README compatible PageSpeed Insights of your website\",\n    \"main\": \"dist/app.js\",\n    \"dependencies\": {\n        \"dotenv\": \"^10.0.0\",\n        \"express\": \"^4.17.1\",\n        \"node-fetch\": \"^2.6.0\",\n        \"url\": \"^0.11.0\"\n    },\n    \"devDependencies\": {\n        \"@types/express\": \"^4.17.13\",\n        \"@types/node\": \"^17.0.21\",\n        \"@types/node-fetch\": \"^2.6.1\",\n        \"@typescript-eslint/eslint-plugin\": \"^5.12.1\",\n        \"@typescript-eslint/parser\": \"^5.12.1\",\n        \"eslint\": \"^8.9.0\",\n        \"eslint-import-resolver-typescript\": \"^2.5.0\",\n        \"eslint-plugin-import\": \"^2.25.4\",\n        \"prettier\": \"^2.5.1\",\n        \"typescript\": \"^4.5.5\"\n    },\n    \"scripts\": {\n        \"build\": \"tsc\",\n        \"start\": \"node dist/app.js\",\n        \"format\": \"prettier --write \\\"**/*.{js,ts}\\\"\",\n        \"lint\": \"eslint --ext .ts --ignore-path .gitignore .\",\n        \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n    },\n    \"author\": \"Ankur Parihar\",\n    \"license\": \"ISC\",\n    \"engines\": {\n        \"node\": \"14.x\"\n    }\n}\n"
  },
  {
    "path": "src/app.ts",
    "content": "import \"dotenv/config\";\n\nimport { parse as parseURL } from \"url\";\n\nimport express from \"express\";\n\nimport constants from \"./constants\";\nimport { urlOptions } from \"./interfaces/options\";\nimport runTests from \"./psi-runner\";\nimport buildSVG from \"./svg\";\nimport { getSingleQueryParam } from \"./utils/url\";\nimport { removeDuplicates } from \"./utils/utils\";\n\nconst app = express();\nconst port = process.env.PORT || 3000;\n\napp.listen(port, () => {\n    console.log(`lighthouse-stats-app listening at PORT ${port}`);\n});\n\nconst processURL = (\n    url: string\n): urlOptions & {\n    error?: string;\n} => {\n    const queryObject = parseURL(url, true).query;\n    const SITE_URL = getSingleQueryParam(queryObject.url);\n\n    if (!SITE_URL) {\n        return {\n            error: \"`url` not specified\",\n        };\n    }\n\n    const strategy = getSingleQueryParam(queryObject.strategy) || constants.STRATEGY_DESKTOP;\n    const theme = getSingleQueryParam(queryObject.theme) || constants.THEME_AGNOSTIC;\n    const perfTestCount = getSingleQueryParam(queryObject.perfTestCount) || \"1\";\n    const perfCount = parseInt(perfTestCount);\n\n    if (isNaN(perfCount)) {\n        return {\n            error: \"perfCount param should be a number\",\n        };\n    } else if (perfCount <= 0) {\n        return {\n            error: \"perfCount param should be > 0\",\n        };\n    } else if (perfCount > constants.MAX_PERF_TEST_COUNT) {\n        return {\n            error: `perfCount cannot exceed ${constants.MAX_PERF_TEST_COUNT}`,\n        };\n    }\n\n    const defaultCategories = [\n        constants.CAT_PERF,\n        constants.CAT_A11Y,\n        constants.CAT_BEST,\n        constants.CAT_SEO,\n        constants.CAT_PWA,\n    ];\n    let categories = defaultCategories;\n\n    if (queryObject.categories) {\n        try {\n            categories = getSingleQueryParam(queryObject.categories).split(\",\");\n            // remove duplicates\n            categories = removeDuplicates(categories);\n            // check for invalid categories\n            const invalidCategories = categories.filter((category) => defaultCategories.indexOf(category) === -1);\n            if (invalidCategories.length > 0) {\n                return {\n                    error: `Invalid categories: ${JSON.stringify(invalidCategories)}`,\n                };\n            }\n        } catch (error) {\n            return {\n                error: \"Invalid `categories`, unable to parse\",\n            };\n        }\n    }\n\n    return {\n        SITE_URL,\n        strategy,\n        categories,\n        theme,\n        perfCount,\n    };\n};\n\napp.get(\"/\", async (req, res) => {\n    const { SITE_URL, strategy, categories, theme, perfCount, error } = processURL(req.url);\n\n    if (error) {\n        res.status(400).send(error);\n    }\n\n    const options = { performance: { iterations: perfCount } };\n    const scores = await runTests(SITE_URL, categories, strategy, options);\n\n    const svg = buildSVG(\n        theme,\n        categories.map((category) => ({ category, score: scores[category] }))\n    );\n\n    res.setHeader(\"Content-Type\", \"image/svg+xml\");\n    res.send(svg);\n});\n"
  },
  {
    "path": "src/constants.ts",
    "content": "// TODO: Deep freeze\nexport default {\n    API_KEY: process.env.API_KEY,\n    PAGESPEED_API_URL: `https://www.googleapis.com/pagespeedonline/v5/runPagespeed`, //?url=${queryObject.url}&key=${API_KEY}&strategy=${strategy}&`;\n\n    // categories\n    CAT_PERF: \"performance\",\n    CAT_A11Y: \"accessibility\",\n    CAT_BEST: \"best-practices\",\n    CAT_SEO: \"seo\",\n    CAT_PWA: \"pwa\",\n\n    // theme\n    THEME_LIGHT: \"light\",\n    THEME_DARK: \"dark\",\n    THEME_AGNOSTIC: \"agnostic\",\n\n    // strategy\n    STRATEGY_MOBILE: \"mobile\",\n    STRATEGY_DESKTOP: \"desktop\",\n\n    // misc\n    MAX_PERF_TEST_COUNT: 3,\n};\n"
  },
  {
    "path": "src/interfaces/options.ts",
    "content": "interface urlOptions {\n    SITE_URL?: string;\n    strategy?: string;\n    categories?: string[];\n    theme?: string;\n    perfCount?: number;\n}\n\nexport { urlOptions };\n"
  },
  {
    "path": "src/psi-runner.ts",
    "content": "import constants from \"./constants\";\nimport { perfTest, pwaTest, simpleTest } from \"./tests\";\n\n/**\n * Run lighthouse tests using pagespeed API and return the scores\n * @returns scores\n */\nconst runTests = async (url: string, categories: string[], strategy: string, options: { [x: string]: any }) => {\n    const results = {};\n\n    await Promise.all(\n        categories.map((category) => {\n            switch (category) {\n                case constants.CAT_PWA:\n                    return pwaTest(url, strategy);\n                case constants.CAT_PERF:\n                    return perfTest(url, strategy, options[category].iterations);\n                default:\n                    return simpleTest(url, category, strategy);\n            }\n        })\n    ).then((scores) => {\n        categories.forEach((category, index) => {\n            results[category] = scores[index];\n        });\n    });\n    // TODO: catch error\n    return results;\n};\n\nexport default runTests;\n"
  },
  {
    "path": "src/svg.ts",
    "content": "import constants from \"./constants\";\n\nconst guageClass = (score: number) => {\n    if (score >= 90) {\n        return \"guage-green\";\n    } else if (score >= 50) {\n        return \"guage-orange\";\n    } else if (score >= 0) {\n        return \"guage-red\";\n    }\n    return \"guage-undefined\";\n};\n\nconst getSimpleGuage = (label: string, score: number, offset: any) => {\n    return `<svg class=\"guage-div guage-perf ${guageClass(score)}\"\n\t\t\t\tviewBox=\"0 0 200 200\" width=\"200\" height=\"200\" x=\"${offset}\" y=\"0\">\n\t\t<circle class=\"gauge-base\" r=\"56\" cx=\"100\" cy=\"60\" stroke-width=\"8\"></circle>\n\t\t<circle class=\"gauge-arc guage-arc-1\" r=\"56\" cx=\"100\" cy=\"60\" stroke-width=\"8\" style=\"stroke-dasharray: ${\n            score >= 0 ? (score * 351.858) / 100 : 351.858\n        }, 351.858;\"></circle>\n\t\t<text class=\"guage-text\" x=\"100px\" y=\"60px\" alignment-baseline=\"central\" dominant-baseline=\"central\" text-anchor=\"middle\">${\n            score >= 0 ? score : \"NA\"\n        }</text>\n\t\t<text class=\"guage-title\" x=\"100px\" y=\"160px\" alignment-baseline=\"central\" dominant-baseline=\"central\" text-anchor=\"middle\">${label}</text>\n\t</svg>`;\n};\n\nconst getPWAGuage = (score: number, offset: any) => {\n    return `<svg class=\"guage-div guage-pwa\" viewBox=\"0 0 200 200\" width=\"200\" height=\"200\" x=\"${offset}\" y=\"0\">\n\t\t<svg viewBox=\"0 0 60 60\" width=\"112\" height=\"112\" x=\"44\" y=\"4\">\n\t\t\t<defs>\n\t\t\t\t<linearGradient id=\"lh-gauge--pwa__check-circle__gradient-0\" x1=\"50%\" y1=\"0%\" x2=\"50%\" y2=\"100%\">\n\t\t\t\t\t<stop stop-color=\"#00C852\" offset=\"0%\"></stop>\n\t\t\t\t\t<stop stop-color=\"#009688\" offset=\"100%\"></stop>\n\t\t\t\t</linearGradient>\n\t\t\t\t<linearGradient id=\"lh-gauge--pwa__installable__shadow-gradient-0\" x1=\"76.056%\" x2=\"24.111%\" y1=\"82.995%\" y2=\"24.735%\">\n\t\t\t\t\t<stop stop-color=\"#A5D6A7\" offset=\"0%\"></stop>\n\t\t\t\t\t<stop stop-color=\"#80CBC4\" offset=\"100%\"></stop>\n\t\t\t\t</linearGradient>\n\t\t\t\t<linearGradient id=\"lh-gauge--pwa__fast-reliable__shadow-gradient-0\" x1=\"76.056%\" y1=\"82.995%\" x2=\"25.678%\" y2=\"26.493%\">\n\t\t\t\t\t<stop stop-color=\"#64B5F6\" offset=\"0%\"></stop>\n\t\t\t\t\t<stop stop-color=\"#2979FF\" offset=\"100%\"></stop>\n\t\t\t\t</linearGradient>\n\n\t\t\t\t<g id=\"lh-gauge--pwa__fast-reliable-badge-0\">\n\t\t\t\t\t<circle fill=\"#FFFFFF\" cx=\"10\" cy=\"10\" r=\"10\"></circle>\n\t\t\t\t\t<path fill=\"#304FFE\" d=\"M10 3.58l5.25 2.34v3.5c0 3.23-2.24 6.26-5.25 7-3.01-.74-5.25-3.77-5.25-7v-3.5L10 3.58zm-.47 10.74l2.76-4.83.03-.07c.04-.08 0-.24-.22-.24h-1.64l.47-3.26h-.47l-2.7 4.77c-.02.01.05-.1-.04.05-.09.16-.1.31.18.31h1.63l-.47 3.27h.47z\"></path>\n\t\t\t\t</g>\n\t\t\t\t<g id=\"lh-gauge--pwa__installable-badge-0\">\n\t\t\t\t\t<circle fill=\"#FFFFFF\" cx=\"10\" cy=\"10\" r=\"10\"></circle>\n\t\t\t\t\t<path fill=\"#009688\" d=\"M10 4.167A5.835 5.835 0 0 0 4.167 10 5.835 5.835 0 0 0 10 15.833 5.835 5.835 0 0 0 15.833 10 5.835 5.835 0 0 0 10 4.167zm2.917 6.416h-2.334v2.334H9.417v-2.334H7.083V9.417h2.334V7.083h1.166v2.334h2.334v1.166z\"></path>\n\t\t\t\t</g>\n\t\t\t</defs>\n\t\t\t<g stroke=\"none\" fill-rule=\"nonzero\">\n\t\t\t\t<!-- Background and PWA logo (color by default) -->\n\t\t\t\t<circle class=\"lh-gauge--pwa__disc\" cx=\"30\" cy=\"30\" r=\"30\"></circle>\n\t\t\t\t<g class=\"lh-gauge--pwa__logo\">\n\t\t\t\t\t<path ${\n                        score === 7 ? 'class=\"lh-gauge--pwa__logo--secondary-color\"' : \"\"\n                    } d=\"M35.66 19.39l.7-1.75h2L37.4 15 38.6 12l3.4 9h-2.51l-.58-1.61z\"></path>\n\t\t\t\t\t<path ${\n                        score === 7 ? 'class=\"lh-gauge--pwa__logo--primary-color\"' : \"\"\n                    } d=\"M33.52 21l3.65-9h-2.42l-2.5 5.82L30.5 12h-1.86l-1.9 5.82-1.35-2.65-1.21 3.72L25.4 21h2.38l1.72-5.2 1.64 5.2z\"></path>\n\t\t\t\t\t<path ${\n                        score === 7 ? 'class=\"lh-gauge--pwa__logo--secondary-color\"' : \"\"\n                    } fill-rule=\"nonzero\" d=\"M20.3 17.91h1.48c.45 0 .85-.05 1.2-.15l.39-1.18 1.07-3.3a2.64 2.64 0 0 0-.28-.37c-.55-.6-1.36-.91-2.42-.91H18v9h2.3V17.9zm1.96-3.84c.22.22.33.5.33.87 0 .36-.1.65-.29.87-.2.23-.59.35-1.15.35h-.86v-2.41h.87c.52 0 .89.1 1.1.32z\"></path>\n\t\t\t\t</g>\n\t\t\t\t<!-- No badges. -->\n\t\t\t\t<rect class=\"lh-gauge--pwa__component lh-gauge--pwa__na-line ${\n                    score === 0 ? \"lh-gauge--pwa__visible\" : \"lh-gauge--pwa__invisible\"\n                }\" fill=\"#FFFFFF\" x=\"20\" y=\"32\" width=\"20\" height=\"4\" rx=\"2\"></rect>\n\t\t\t\t<!-- Just fast and reliable. -->\n\t\t\t\t<g class=\"lh-gauge--pwa__component lh-gauge--pwa__fast-reliable-badge ${\n                    score === 1 ? \"lh-gauge--pwa__visible\" : \"lh-gauge--pwa__invisible\"\n                }\" transform=\"translate(20, 29)\">\n\t\t\t\t\t<path fill=\"url(#lh-gauge--pwa__fast-reliable__shadow-gradient-0)\" d=\"M33.63 19.49A30 30 0 0 1 16.2 30.36L3 17.14 17.14 3l16.49 16.49z\"></path>\n\t\t\t\t\t<use href=\"#lh-gauge--pwa__fast-reliable-badge-0\"></use>\n\t\t\t\t</g>\n\t\t\t\t<!-- Just installable. -->\n\t\t\t\t<g class=\"lh-gauge--pwa__component lh-gauge--pwa__installable-badge ${\n                    score === 2 ? \"lh-gauge--pwa__visible\" : \"lh-gauge--pwa__invisible\"\n                }\" transform=\"translate(20, 29)\">\n\t\t\t\t\t<path fill=\"url(#lh-gauge--pwa__installable__shadow-gradient-0)\" d=\"M33.629 19.487c-4.272 5.453-10.391 9.39-17.415 10.869L3 17.142 17.142 3 33.63 19.487z\"></path>\n\t\t\t\t\t<use href=\"#lh-gauge--pwa__installable-badge-0\"></use>\n\t\t\t\t</g>\n\t\t\t\t<!-- Fast and reliable and installable. -->\n\t\t\t\t<g class=\"lh-gauge--pwa__component lh-gauge--pwa__fast-reliable-installable-badges ${\n                    score === 3 ? \"lh-gauge--pwa__visible\" : \"lh-gauge--pwa__invisible\"\n                }\">\n\t\t\t\t\t<g transform=\"translate(8, 29)\">\t\t\t\t\t\t<!-- fast and reliable -->\n\t\t\t\t\t\t<path fill=\"url(#lh-gauge--pwa__fast-reliable__shadow-gradient-0)\" d=\"M16.321 30.463L3 17.143 17.142 3l22.365 22.365A29.864 29.864 0 0 1 22 31c-1.942 0-3.84-.184-5.679-.537z\"></path>\n\t\t\t\t\t\t<use href=\"#lh-gauge--pwa__fast-reliable-badge-0\"></use>\n\t\t\t\t\t</g>\n\t\t\t\t\t<g transform=\"translate(32, 29)\">\t\t\t\t\t\t<!-- installable -->\n\t\t\t\t\t\t<path fill=\"url(#lh-gauge--pwa__installable__shadow-gradient-0)\" d=\"M25.982 11.84a30.107 30.107 0 0 1-13.08 15.203L3 17.143 17.142 3l8.84 8.84z\"></path>\n\t\t\t\t\t\t<use href=\"#lh-gauge--pwa__installable-badge-0\"></use>\n\t\t\t\t\t</g>\n\t\t\t\t</g>\n\t\t\t\t<!-- Full PWA. -->\n\t\t\t\t<g class=\"lh-gauge--pwa__component lh-gauge--pwa__check-circle ${\n                    score === 7 ? \"lh-gauge--pwa__visible\" : \"lh-gauge--pwa__invisible\"\n                }\" transform=\"translate(18, 28)\">\n\t\t\t\t\t<circle fill=\"#FFFFFF\" cx=\"12\" cy=\"12\" r=\"12\"></circle>\n\t\t\t\t\t<path fill=\"url(#lh-gauge--pwa__check-circle__gradient-0)\" d=\"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z\"></path>\n\t\t\t\t</g>\n\t\t\t</g>\n\t\t</svg>\n\t\t<text class=\"guage-title\" y=\"160px\" alignment-baseline=\"central\" dominant-baseline=\"central\" text-anchor=\"middle\">\n\t\t\t<tspan x=\"100px\" dy=\"-6px\">Progressive</tspan>\n\t\t\t<tspan x=\"100px\" dy=\"30px\">Web App</tspan>\n\t\t</text>\n\t</svg>`;\n};\n\nconst lableMaps = {\n    \"performance\": \"Performance\",\n    \"accessibility\": \"Accessibility\",\n    \"best-practices\": \"Best Practices\",\n    \"seo\": \"SEO\",\n};\n\nconst getGuageSVG = (category: string, score: number, offset: number) => {\n    switch (category) {\n        case constants.CAT_PWA:\n            return getPWAGuage(score, offset);\n        case constants.CAT_PERF:\n        case constants.CAT_A11Y:\n        case constants.CAT_BEST:\n        case constants.CAT_SEO:\n            return getSimpleGuage(lableMaps[category], score, offset);\n        default:\n            return getSimpleGuage(\"NA\", 0, offset);\n    }\n};\n\n/**\n * Build thematic SVG from given scores\n * @returns\n */\nconst buildSVG = (theme: string = constants.THEME_AGNOSTIC, scores: { category: string; score: number }[]) => {\n    const offset = 500 - scores.length * 100;\n\n    const svg = `\n\t<svg class=\"theme--${theme}\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" fill=\"none\" width=\"1000\" height=\"330\">\n\t\t<style>\n\t\t\t.gauge-base {\n\t\t\t\topacity: 0.1\n\t\t\t}\n\n\t\t\t.gauge-arc {\n\t\t\t\tfill: none;\n\t\t\t\tanimation-delay: 250ms;\n\t\t\t\tstroke-linecap: round;\n\t\t\t\ttransform: rotate(-90deg);\n\t\t\t\ttransform-origin: 100px 60px;\n\t\t\t\tanimation: load-gauge 1s ease forwards\n\t\t\t}\n\n\t\t\t.guage-text {\n\t\t\t\tfont-size: 40px;\n\t\t\t\tfont-family: monospace;\n\t\t\t\ttext-align: center\n\t\t\t}\n\n\t\t\t.guage-red {\n\t\t\t\tcolor: #ff4e42;\n\t\t\t\tfill: #ff4e42;\n\t\t\t\tstroke: #ff4e42\n\t\t\t}\n\t\t\t.guage-orange {\n\t\t\t\tcolor: #ffa400;\n\t\t\t\tfill: #ffa400;\n\t\t\t\tstroke: #ffa400\n\t\t\t}\n\t\t\t.guage-green {\n\t\t\t\tcolor: #0cce6b;\n\t\t\t\tfill: #0cce6b;\n\t\t\t\tstroke: #0cce6b\n\t\t\t}\n\t\t\t.theme--agnostic .guage-undefined {\n\t\t\t\tcolor: #5c5c5c;\n\t\t\t\tfill: #5c5c5c;\n\t\t\t\tstroke: #5c5c5c\n\t\t\t}\n\t\t\t.theme--light .guage-undefined {\n\t\t\t\tcolor: #1e1e1e;\n\t\t\t\tfill: #1e1e1e;\n\t\t\t\tstroke: #1e1e1e\n\t\t\t}\n\t\t\t.theme--dark .guage-undefined {\n\t\t\t\tcolor: #f5f5f5;\n\t\t\t\tfill: #f5f5f5;\n\t\t\t\tstroke: #f5f5f5\n\t\t\t}\n\n\t\t\t.guage-title {\n\t\t\t\tstroke: none;\n\t\t\t\tfont-size: 26px;\n\t\t\t\tline-height: 26px;\n\t\t\t\tfont-family: Roboto, Halvetica, Arial, sans-serif\n\t\t\t}\n\t\t\t.metric.guage-title {\n\t\t\t\tfont-family: 'Courier New', Courier, monospace\n\t\t\t}\n\t\t\t.theme--agnostic .guage-title {\n\t\t\t\tcolor: #737373;\n\t\t\t\tfill: #737373\n\t\t\t}\n\t\t\t.theme--light .guage-title {\n\t\t\t\tcolor: #212121;\n\t\t\t\tfill: #212121\n\t\t\t}\n\t\t\t.theme--dark .guage-title {\n\t\t\t\tcolor: #f5f5f5;\n\t\t\t\tfill: #f5f5f5\n\t\t\t}\n\n\t\t\t@keyframes load-gauge {\n\t\t\t\tfrom {\n\t\t\t\t\tstroke-dasharray: 0 352.858\n\t\t\t\t}\n\t\t\t}\n\t\t\t.lh-gauge--pwa__disc {\n\t\t\t\tfill: #e0e0e0\n\t\t\t}\n\t\t\t.lh-gauge--pwa__logo {\n\t\t\t\tposition: relative;\n\t\t\t\tfill: #b0b0b0\n\t\t\t}\n\t\t\t.lh-gauge--pwa__invisible {\n\t\t\t\tdisplay: none\n\t\t\t}\n\t\t\t.lh-gauge--pwa__visible {\n\t\t\t\tdisplay: inline\n\t\t\t}\n\t\t\t.guage-invisible {\n\t\t\t\tdisplay: none\n\t\t\t}\n\t\t\t.lh-gauge--pwa__logo--primary-color {\n\t\t\t\tfill: #304ffe\n\t\t\t}\n\t\t\t.theme--agnostic .lh-gauge--pwa__logo--secondary-color {\n\t\t\t\tfill: #787878\n\t\t\t}\n\t\t\t.theme--light .lh-gauge--pwa__logo--secondary-color {\n\t\t\t\tfill: #3d3d3d\n\t\t\t}\n\t\t\t.theme--dark .lh-gauge--pwa__logo--secondary-color {\n\t\t\t\tfill: #d8b6b6\n\t\t\t}\n\t\t\t.theme--light #svg_2 {\n\t\t\t\tstroke: #00000022\n\t\t\t}\n\t\t\t.theme--agnostic #svg_2 {\n\t\t\t\tstroke: #616161\n\t\t\t}\n\t\t\t.theme--light #svg_2 {\n\t\t\t\tstroke: #00000022\n\t\t\t}\n\t\t\t.theme--dark #svg_2 {\n\t\t\t\tstroke: #f5f5f566\n\t\t\t}\n\t\t</style>\n\t\t${scores.map(({ category, score }, i) => getGuageSVG(category, score, offset + i * 200))}\n\t\t<svg width=\"604\" height=\"76\" x=\"200\" y=\"250\">\n\t\t\t<g>\n\t\t\t\t<rect fill=\"none\" id=\"canvas_background\" height=\"80\" width=\"604\" y=\"-1\" x=\"-1\"/>\n\t\t\t\t<g display=\"none\" overflow=\"visible\" y=\"0\" x=\"0\" height=\"100%\" width=\"100%\" id=\"canvasGrid\">\n\t\t\t\t\t<rect fill=\"url(#gridpattern)\" stroke-width=\"0\" y=\"0\" x=\"0\" height=\"100%\" width=\"100%\"/>\n\t\t\t\t</g>\n\t\t\t</g>\n\t\t\t<g>\n\t\t\t\t<rect fill-opacity=\"0\" stroke-width=\"2\" rx=\"40\" id=\"svg_2\" height=\"72\" width=\"600\" y=\"1\" x=\"0\" fill=\"#000000\"/>\n\t\t\t\t<rect stroke=\"#000\" rx=\"8\" id=\"svg_3\" height=\"14\" width=\"48\" y=\"30\" x=\"35\" stroke-opacity=\"null\" stroke-width=\"0\" fill=\"#ff4e42\"/>\n\t\t\t\t<rect stroke=\"#000\" rx=\"6\" id=\"svg_4\" height=\"14\" width=\"48\" y=\"30\" x=\"220\" stroke-opacity=\"null\" stroke-width=\"0\" fill=\"#ffa400\"/>\n\t\t\t\t<rect stroke=\"#000\" rx=\"6\" id=\"svg_5\" height=\"14\" width=\"48\" y=\"30\" x=\"410\" stroke-opacity=\"null\" stroke-width=\"0\" fill=\"#0cce6b\"/>\n\t\t\t\t<text class=\"metric guage-title\" xml:space=\"preserve\" text-anchor=\"start\" font-size=\"26\" id=\"svg_6\" y=\"45\" x=\"100\" stroke-opacity=\"null\" stroke-width=\"0\" stroke=\"#000\">0-49</text>\n\t\t\t\t<text class=\"metric guage-title\" xml:space=\"preserve\" text-anchor=\"start\" font-size=\"26\" id=\"svg_7\" y=\"45\" x=\"280\" stroke-opacity=\"null\" stroke-width=\"0\" stroke=\"#000\">50-89</text>\n\t\t\t\t<text class=\"metric guage-title\" xml:space=\"preserve\" text-anchor=\"start\" font-size=\"26\" id=\"svg_8\" y=\"45\" x=\"470\" stroke-opacity=\"null\" stroke-width=\"0\" stroke=\"#000\">90-100</text>\n\t\t\t</g>\n\t\t</svg>\n\t</svg>`;\n    return svg;\n};\n\nexport default buildSVG;\n"
  },
  {
    "path": "src/tests/index.ts",
    "content": "import perfTest from \"./performance\";\nimport pwaTest from \"./pwa\";\nimport simpleTest from \"./simpleTest\";\n\nexport { simpleTest, perfTest, pwaTest };\n"
  },
  {
    "path": "src/tests/performance.ts",
    "content": "import fetch from \"node-fetch\";\n\nimport constants from \"../constants\";\n\nconst { PAGESPEED_API_URL, API_KEY, CAT_PERF } = constants;\n\n/**\n * Performance test which requires multiple iterations to get better results\n * @returns score\n */\nconst perfTest = async (url: string, strategy: string, iterations = 1) => {\n    const category = CAT_PERF;\n    const queryURL = `${PAGESPEED_API_URL}?url=${url}&strategy=${strategy}&category=${category}&key=${API_KEY}`;\n    try {\n        const responses = await Promise.all(new Array(iterations).fill(0).map(() => fetch(queryURL)));\n        const jsons = await Promise.all(responses.map((response) => response.json()));\n        // Todo invalid json handling\n        const scores = jsons.map((json) => json.lighthouseResult.categories[category].score * 100);\n        return Math.round(scores.reduce((prev, curr) => prev + curr) / scores.length);\n    } catch (error) {\n        return -1;\n    }\n};\n\nexport default perfTest;\n"
  },
  {
    "path": "src/tests/pwa.ts",
    "content": "import fetch from \"node-fetch\";\n\nimport constants from \"../constants\";\n\nconst { PAGESPEED_API_URL, API_KEY, CAT_PWA } = constants;\n\n/**\n * Test to get PWA score\n * @returns score\n */\nconst pwaTest = async (url: string, strategy: string) => {\n    try {\n        const response = await fetch(\n            `${PAGESPEED_API_URL}?url=${url}&strategy=${strategy}&category=${CAT_PWA}&key=${API_KEY}`\n        );\n        const json = await response.json();\n        const { lighthouseResult } = json;\n        let fast_reliable = 0;\n        let fast_reliable_total = 0;\n        let installable = 0;\n        let installable_total = 0;\n        let optimized = 0;\n        let optimized_total = 0;\n        lighthouseResult.categories.pwa.auditRefs.forEach((auditRef) => {\n            const audit = lighthouseResult.audits[auditRef.id];\n            if (audit.scoreDisplayMode === \"binary\" || audit.scoreDisplayMode === \"numeric\") {\n                if (auditRef.group === \"pwa-fast-reliable\") {\n                    fast_reliable_total++;\n                    if (audit && audit.score >= 0.9) {\n                        fast_reliable++;\n                    }\n                } else if (auditRef.group === \"pwa-installable\") {\n                    installable_total++;\n                    if (audit && audit.score >= 0.9) {\n                        installable++;\n                    }\n                } else if (auditRef.group === \"pwa-optimized\") {\n                    optimized_total++;\n                    if (audit && audit.score >= 0.9) {\n                        optimized++;\n                    }\n                }\n            }\n        });\n        let score = 0;\n        if (fast_reliable === fast_reliable_total) score |= 1;\n        if (installable === installable_total) score |= 2;\n        if (optimized === optimized_total) score |= 4;\n        return score;\n    } catch (error) {\n        return -1;\n    }\n};\n\nexport default pwaTest;\n"
  },
  {
    "path": "src/tests/simpleTest.ts",
    "content": "import fetch from \"node-fetch\";\n\nimport constants from \"../constants\";\n\nconst { PAGESPEED_API_URL, API_KEY } = constants;\n\n/**\n * Basic test which requires single API call\n * @returns score\n */\nconst simpleTest = async (url: string, category: string, strategy: string) => {\n    const queryURL = `${PAGESPEED_API_URL}?url=${url}&strategy=${strategy}&category=${category}&key=${API_KEY}`;\n    try {\n        const response = await fetch(queryURL);\n        const json = await response.json();\n        const score = json.lighthouseResult.categories[category].score * 100;\n        return score;\n    } catch (error) {\n        return -1;\n    }\n};\n\nexport default simpleTest;\n"
  },
  {
    "path": "src/utils/url.ts",
    "content": "/**\n * Get single query parameter value from url\n */\nconst getSingleQueryParam = (queryParam: string | string[], arrayResolution = \"first\") => {\n    if (!queryParam) return;\n    if (Array.isArray(queryParam)) {\n        switch (arrayResolution) {\n            case \"first\":\n                return arrayResolution[0];\n            case \"last\":\n                return arrayResolution[arrayResolution.length - 1];\n            default:\n                return;\n        }\n    }\n    return queryParam;\n};\n\nexport { getSingleQueryParam };\n"
  },
  {
    "path": "src/utils/utils.ts",
    "content": "/**\n * Remove duplicates from array\n */\nconst removeDuplicates = <Type>(array: Type[]) => {\n    return array.filter((item, i) => array.indexOf(item) === i);\n};\n\nexport { removeDuplicates };\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"module\": \"commonjs\",\n        \"esModuleInterop\": true,\n        \"target\": \"es6\",\n        \"moduleResolution\": \"node\",\n        \"sourceMap\": false,\n        \"outDir\": \"dist\"\n    },\n    \"lib\": [\"es2015\"],\n    \"include\": [\"src/*.ts\"]\n}\n"
  }
]