All Projects → Financial-Times → Polyfill Library

Financial-Times / Polyfill Library

Licence: mit
NodeJS module to create polyfill bundles tailored to individual user-agents.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Polyfill Library

fromentries
Object.fromEntries() ponyfill (in 6 lines)
Stars: ✭ 62 (-84.65%)
Mutual labels:  polyfill
Formdata
HTML5 `FormData` polyfill for Browsers.
Stars: ✭ 292 (-27.72%)
Mutual labels:  polyfill
Css3 Mediaqueries Js
CSS3 Media Queries Shim
Stars: ✭ 333 (-17.57%)
Mutual labels:  polyfill
Gapotchenko.FX
.NET polyfill to the future. A versatile RAD framework for .NET platform.
Stars: ✭ 23 (-94.31%)
Mutual labels:  polyfill
Abortcontroller Polyfill
Polyfill for the AbortController DOM API and abortable fetch (stub that calls catch, doesn't actually abort request).
Stars: ✭ 273 (-32.43%)
Mutual labels:  polyfill
Ie8
some damn DOM fix for this damned browser
Stars: ✭ 297 (-26.49%)
Mutual labels:  polyfill
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (-91.58%)
Mutual labels:  polyfill
Polyfill Ctype
This component provides a partial, native PHP implementation for the Ctype extension.
Stars: ✭ 3,774 (+834.16%)
Mutual labels:  polyfill
Bootstrap Ie8
Bootstrap 4 for IE8 and IE9
Stars: ✭ 278 (-31.19%)
Mutual labels:  polyfill
Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+835.4%)
Mutual labels:  polyfill
rangefix
Workaround for browser bugs in Range.prototype.getClientRects and Range.prototype.getBoundingClientRect.
Stars: ✭ 35 (-91.34%)
Mutual labels:  polyfill
React Native Drawer Layout
A platform-agnostic drawer layout for react-native
Stars: ✭ 258 (-36.14%)
Mutual labels:  polyfill
Standardized Audio Context
A cross-browser wrapper for the Web Audio API which aims to closely follow the standard.
Stars: ✭ 300 (-25.74%)
Mutual labels:  polyfill
web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation
Stars: ✭ 198 (-50.99%)
Mutual labels:  polyfill
Loading Attribute Polyfill
Fast and lightweight dependency-free vanilla JavaScript polyfill for native lazy loading / the awesome loading='lazy'-attribute.
Stars: ✭ 335 (-17.08%)
Mutual labels:  polyfill
webvr-polyfill-dpdb
An up-to-date Device Parameter Database for the WebVR Polyfill
Stars: ✭ 29 (-92.82%)
Mutual labels:  polyfill
Url Polyfill
Polyfill URL and URLSearchParams to match last ES7 specifications
Stars: ✭ 294 (-27.23%)
Mutual labels:  polyfill
Avif.js
AVIF polyfill for the browser
Stars: ✭ 399 (-1.24%)
Mutual labels:  polyfill
Fakeindexeddb
A pure JS in-memory implementation of the IndexedDB API
Stars: ✭ 373 (-7.67%)
Mutual labels:  polyfill
Polyfill Php70
This component provides features unavailable in releases prior to PHP 7.0.
Stars: ✭ 3,270 (+709.41%)
Mutual labels:  polyfill

Polyfill-library · license PRs Welcome

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.

  • @param {String} featureName - The name of a polyfill whose metadata should be returned.

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.

  • @param {object} opts - Valid keys are uaString, minify, unknown, excludes, rum and features.
  • @param {Boolean} [opts.minify=true] - Whether to return the minified or raw implementation of the polyfills.
  • @param {'ignore'|'polyfill'} [opts.unknown='polyfill'] - Whether to return all polyfills or no polyfills if the user-agent is unknown or unsupported.
  • @param {Object} [opts.features={}] - Which features should be returned if the user-agent does not support them natively.
  • @param {Array<String>} [opts.excludes=[]] - Which features should be excluded from the returned object.
  • @param {String} [opts.uaString=''] - The user-agent string to check each feature against.
  • @param {Boolean} [opts.rum=false] - Whether to include a script that reports anonymous usage data in the polyfill bundle.

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.

  • @param {object} opts - Valid keys are uaString, minify, unknown, excludes, rum and features.
  • @param {Boolean} [opts.minify=true] - Whether to return the minified or raw implementation of the polyfills.
  • @param {'ignore'|'polyfill'} [opts.unknown='polyfill'] - Whether to return all polyfills or no polyfills if the user-agent is unknown or unsupported.
  • @param {Object} [opts.features={}] - Which features should be returned if the user-agent does not support them natively.
  • @param {Array<String>} [opts.excludes=[]] - Which features should be excluded from the returned object.
  • @param {String} [opts.uaString=''] - The user-agent string to check each feature against.
  • @param {Boolean} [opts.rum=false] - Whether to include a script that reports anonymous usage data in the polyfill bundle.

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

polyfillLibrary.getPolyfillString(opts)

Create a polyfill bundle.

  • @param {object} opts - Valid keys are uaString, minify, unknown, excludes, rum and features.
  • @param {Boolean} [opts.minify=true] - Whether to return the minified or raw implementation of the polyfills.
  • @param {'ignore'|'polyfill'} [opts.unknown='polyfill'] - Whether to return all polyfills or no polyfills if the user-agent is unknown or unsupported.
  • @param {Object} [opts.features={}] - Which features should be returned if the user-agent does not support them natively.
  • @param {Array<String>} [opts.excludes=[]] - Which features should be excluded from the returned object.
  • @param {String} [opts.uaString=''] - The user-agent string to check each feature against.
  • @param {Boolean} [opts.rum=false] - Whether to include a script that reports anonymous usage data in the polyfill bundle.
  • @param {Boolean} [opts.stream=false] - Whether to return a stream or a string of the 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].