Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polyfills

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyfills

user-agent-based polyfill combinator

  • 1.12.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
increased by13.95%
Maintainers
2
Weekly downloads
 
Created
Source

Polyfills

NPM version Build status Test coverage Dependency Status License Downloads Gittip

Create polyfill builds based on the client's browser and serve only what's needed. This allows you to write modern JavaScript without worrying too much (you should still do due diligence) about browser support as well as not penalizing modern browsers with unnecessary polyfills. See https://polyfills.github.io for more details.

Description

This library is merely the "logic" and does not handle any HTTP serving. It essentially does the following:

  • Parses user agent strings for <family> <major>.<minor>.<version> and creates polyfill bundles based on these variables.
  • Caches builds locally.
  • Creates minified and gzipped builds.
  • Returns metadata for the Content-Encoding, Content-Length and ETag headers.
  • Allows you to choose between which build you'd like and whether to read it or stream it.

It also stores nothing in memory, making it suitable for production usage within existing node apps.

Installation

npm install polyfills

Usage

var polyfill = Polyfills([options])

var polyfill = require('polyfills')()

Return a new instance of polyfill based on options.

  • include - which polyfills to include. This is an inclusive list. The names are included in polyfills/db.
  • exclude - conversely, you can exclude specific polyfills.

polyfill.clean()

Clean all the bundles from the cache.

polyfill(useragent).then( data => )

Build and cache the bundle. Returns data with:

  • name - the name of the build
  • hash - a sha256 sha sum of the JS file for ETag headers
  • polyfills[] - an array of all the polyfills' names used
  • length[extension] - the byte size of each build for Content-Length headers

The possible extensions are:

  • .json - where the metadata is stored
  • .js
  • .js.gz
  • .min.js
  • .min.js.gz

polyfill.read(name, ext, [encoding]).then( buf => )

Read a bundle.

var stream = polyfill.stream(name, ext)

Stream a bundle.

var filename = polyfill.pathOf(name, ext)

Get the filename of a bundle.

Adding polyfills

Checkout polyfills/db.

Keywords

FAQs

Package last updated on 05 Dec 2014

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