项目作者: Berkmann18

项目描述 :
LightHouse average calculator
高级语言: JavaScript
项目地址: git://github.com/Berkmann18/lh-avg.git
创建时间: 2020-04-23T17:08:58Z
项目社区:https://github.com/Berkmann18/lh-avg

开源协议:Apache License 2.0

下载



lh-avg




LightHouse Average calculator

NPM

Node.js CI

All Contributors


license
downloads
codecov
Known Vulnerabilities
Responsible Disclosure Policy
Commitizen friendly
GitHub code size in bytes
BCH compliance
Codacy Badge
semantic-release

Install

  1. npm i --save lh-avg

Usage

CLI

  1. Usage: cli [options] <scoreStrings...>
  2. LightHouse average calculator
  3. Options:
  4. -V, --version output the version number
  5. -p, --percentage Return the result(s) in percentage form
  6. -f, --format <format> Return the result(s) in a specific format (json, csv, md, html), default: text
  7. -s, --split Split the string by metric
  8. -d, --diff Shows the difference between the first row and subsequent ones
  9. -n, --names <names> Add names to each results
  10. -c, --config <config> Use the configuration from the specified path
  11. -m, --multi <multi> Show multiple results (EXPERIMENTAL, please the config option for this)
  12. -h, --help display help for command

Configuration

The CLI will look for configuration files following the cosmiconfig approach:

  1. lh-avg property in package.json
  2. .lh-avgrc (using JSON or YAML syntax)
  3. .lh-avgrc.json
  4. .lh-avgrc.yaml/.lh-avgrc.yml/.lh-avgrc.js
  5. lh-avg.config.js

It will first read the configuration (if it finds one) then look at the CLI options (which overrides the relevant configuration options).

Note: If it encounters a broken/invalid JSON configuration file, it will try to fix it and save the changes to the file itself. It won’t be able to do the same for YAML files!

Example

  1. {
  2. "format": "md",
  3. "split": true,
  4. "percentage": true,
  5. "inputs": [
  6. "86/100/79/100/(1, 1, 6)",
  7. "90/100/79/100/(1, 2, 6)"
  8. ],
  9. "diff": true,
  10. "names": ["`master`", "`pr`"],
  11. "multi": {}
  12. }

Imports

  1. import average from 'lh-avg';
  2. // Or
  3. const average = require('lh-avg').default;

Example

  1. import average from 'lh-avg';
  2. const lightHouseScores = ['14 / 100 / 98 / 100 / (1, 0, 6)'];
  3. console.log(average(lightHouseScores));
  4. /* {
  5. perf: 0.14,
  6. a11y: 1,
  7. bp: 0.98,
  8. seo: 1,
  9. pwa: { fnr: 0.3333333333333333, ins: 0, po: 0.8571428571428571 },
  10. average: 0.6157823129251702
  11. } */
  12. console.log(average(lightHouseScores, { asPercentage: true }));
  13. /* {
  14. perf: '14%',
  15. a11y: '100%',
  16. bp: '98%',
  17. seo: '100%',
  18. pwa: { fnr: '33.33%', ins: '0%', po: '85.71%' },
  19. average: '61.58%'
  20. } */

For more documentation, please check ./doc/index.html.

Contributing

Please consult CONTRIBUTING for guidelines on contributing to this project.

Author

lh-avg © Berkmann18, Released under the Apache-2.0 License.

Contributors ✨

Thanks goes to these wonderful people (emoji key):






Maximilian Berkmann

💻 📖 💡 🤔 🚇 🚧 📦 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!