Origami Frontend Components & Services

Readme: polyfill-library

NodeJS module to create polyfill bundles tailored to individual user-agents

Install

npm install polyfill-library --save

Usage

const polyfillLibrary = require('polyfill-library');

const polyfillBundle = polyfillLibrary.getPolyfillString({
    uaString: 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)',
    minify: true,
    features: {
        'es6': { flags: ['gated'] }
    }
}).then(function(bundleString) {
    console.log(bundleString);
});

API

polyfillLibrary.listAllPolyfills()

Get a list of all the polyfills which exist within the collection of polyfill sources.

Returns a Promise which resolves with an array of all the polyfills within the collection.

polyfillLibrary.describePolyfill(featureName)

Get the metadata for a specific polyfill within the collection of polyfill sources.

Returns a Promise which resolves with the metadata or with undefined if no metadata exists for the polyfill.

polyfillLibrary.getOptions(opts = {})

Create an options object for use with getPolyfills or getPolyfillString.

Returns an object which has merged opts with the defaults option values.

polyfillLibrary.getPolyfills(opts)

Given a set of features that should be polyfilled in 'opts.features' (with flags i.e. {<featurename>: {flags:Set[<flaglist>]}, ...}), determine which have a configuration valid for the given opts.uaString, and return a promise of set of canonical (unaliased) features (with flags) and polyfills.

Returns a Promise which resolves to an Object which contains the canonicalised feature definitions filtered for UA.

polyfillLibrary.getPolyfillString(opts)

Create a polyfill bundle.

Returns a polyfill bundle as either a utf-8 ReadStream or as a Promise of a utf-8 String.

Contributing

Development of polyfill-library happens on GitHub. Read below to learn how you can take part in contributing to Polyfill.io.

Contributing Guide

Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

# To test on BrowserStack you will need to have a BrowserStack account
# We test pull-requests using BrowserStack
npm run test-all-polyfills # Run the tests for all polyfills using BrowserStack
npm run test-polyfills -- --features=Array.from # Run the tests for Array.from
npm run test-polyfills -- --features=Array.from --browserstack # Run the tests for Array.from using BrowserStack

License

Polyfill-library is MIT licensed.

Status
active Origami v1 (Bower)
Switch component view

GitHub Repository