npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lh-avg

v1.9.6

Published

LightHouse average calculator

Downloads

8

Readme

NPM

Node.js CI

All Contributors

Install

npm i --save lh-avg

Usage

CLI

Usage: cli [options] <scoreStrings...>

LightHouse average calculator

Options:
  -V, --version          output the version number
  -p, --percentage       Return the result(s) in percentage form
  -f, --format <format>  Return the result(s) in a specific format (json, csv, md, html), default: text
  -s, --split            Split the string by metric
  -d, --diff             Shows the difference between the first row and subsequent ones
  -n, --names <names>    Add names to each results
  -c, --config <config>  Use the configuration from the specified path
  -m, --multi <multi>    Show multiple results (EXPERIMENTAL, please the config option for this)
  -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

{
  "format": "md",
  "split": true,
  "percentage": true,
  "inputs": [
    "86/100/79/100/(1, 1, 6)",
    "90/100/79/100/(1, 2, 6)"
  ],
  "diff": true,
  "names": ["`master`", "`pr`"],
  "multi": {}
}

Imports

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

Example

import average from 'lh-avg';

const lightHouseScores = ['14 / 100 / 98 / 100 / (1, 0, 6)'];

console.log(average(lightHouseScores));
/* {
  perf: 0.14,
  a11y: 1,
  bp: 0.98,
  seo: 1,
  pwa: { fnr: 0.3333333333333333, ins: 0, po: 0.8571428571428571 },
  average: 0.6157823129251702
} */

console.log(average(lightHouseScores, { asPercentage: true }));
/* {
  perf: '14%',
  a11y: '100%',
  bp: '98%',
  seo: '100%',
  pwa: { fnr: '33.33%', ins: '0%', po: '85.71%' },
  average: '61.58%'
} */

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):

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