New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

feature-matrix

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feature-matrix

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

  • 0.3.0
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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;
        }
    });
});

FAQs

Package last updated on 18 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc