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

feature-matrix

v0.3.7

Published

A library for displaying a product's browser version requirements based on the underlying features

Downloads

20

Readme

FeatureMatrix

This is a work in progress!

The repo and documentation are still a work in progress and aren't at version 1 yet. We'll improve this over time.

What is FeatureMatrix?

FeatureMatrix is a JavaScript library for rendering feature support matrices that look like this:

(TODO: put a screenshot here)

Rather than having to explicitly define the browsers that are supported by particular features, FeatureMatrix dynamically queries the caniuse dataset to determine what browsers are supported. Features can:

  • Require support for web standards
  • Require the prescence of the Flash Player
  • Blacklist browsers
  • Whitelist browsers

Blacklisting/whitelisting is provided as a fallback for cases where there's no alternative (for example, if a browser is marked as supporting the web standards you require but there's a bug that's breaking things).

Getting FeatureMatrix

FeatureMatrix is available on npm as feature-matrix.

Usage

In your requirements file:

{
    "features": {
        "a-feature": {
            "humanReadableName": "An Amazing Feature",
            "requiredBrowserFeatures": [
                "caniuse:svg",
                "caniuse:webgl"
            ]
        },
        "another-feature": {
            "humanReadableName": "A Legacy Feature",
            "requiredBrowserPlugins": [
                "Flash 9+"
            ],
            "blacklist": [
                "IE 6-7"
            ]
        }
    }
}

In your JS:

// 'path/to/requirements.json' could also be an Object containing the requirements
FeatureMatrix.loadRequirements('path/to/requirements.json', function (err, reqs) {
    if (err) {
        handleError(err);
    } else {
        var fm = new FeatureMatrix('#mountpoint', reqs);
    }
});

Customising strings

All strings (including those used to indicate success/failure) can be changed using an options argument to the FeatureMatrix constructor. The plugin requirement text is configured using a function that returns the requirement string for that plugin to provide maximum flexibility.

FeatureMatrix.loadRequirements('path/to/requirements.json', function (err, reqs) {
    // TODO: you should add error checking here
    var fm = new FeatureMatrix('#mountpoint', reqs, {
        supportedText: 'yes',
        unsupportedText: 'no',
        unknownText: '???',
        featureColumnLabel: 'Capability',

        // this is a lot nicer if you have ES6 arrow functions and template strings
        pluginRequirementGenerator: function (plugin, version) {
            return 'Requires the installation of ' + plugin + ' ' + version;
        }
    });
});