# polyfills

> user-agent-based polyfill combinator

Latest version **2.1.1** (published 2014-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install polyfills
pnpm add polyfills
yarn add polyfills
bun add polyfills
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2014-12-21 |
| First published | 2014-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 106 |
| Author | Jonathan Ong |
| Maintainers | jongleberry, swatinem |
| Keywords | polyfill, polyfills, combinator, user-agent, useragent, bundle, js, javascript |

## Links

- npm: https://www.npmjs.com/package/polyfills
- Repository: https://github.com/polyfills/polyfills
- Issues: https://github.com/polyfills/polyfills/issues
- npm.io page: https://npm.io/package/polyfills

## Dependencies (5)

- [mnfy](https://npm.io/package/mnfy.md) 3
- [lru-cache](https://npm.io/package/lru-cache.md) 2
- [requisition](https://npm.io/package/requisition.md) 1
- [polyfills-db](https://npm.io/package/polyfills-db.md) 3
- [native-or-bluebird](https://npm.io/package/native-or-bluebird.md) 1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.1.1 (latest) — 2014-12-21
- 2.1.0 — 2014-12-21
- 2.0.0 — 2014-12-21
- 1.13.0 — 2014-12-21
- 1.12.1 — 2014-12-11
- 1.12.0 — 2014-12-05
- 1.11.1 — 2014-12-01
- 1.11.0 — 2014-12-01
- 1.10.0 — 2014-12-01
- 1.9.7 — 2014-12-01
- 1.9.6 — 2014-11-28
- 1.9.5 — 2014-11-28
- 1.9.4 — 2014-11-15
- 1.9.3 — 2014-10-28
- 1.9.2 — 2014-10-28
- … 30 more at https://npm.io/package/polyfills/versions

## README

# Polyfills

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![Dependency Status][david-image]][david-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]
[![Gittip][gittip-image]][gittip-url]

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.
- Returned a bundle of all the minified polyfills.

## Installation

```bash
npm install polyfills
```

## Usage

```js
var polyfills = require('polyfills')
var polyfill = polyfills(options)
var js = polyfill(<useragent>)
```

### polyfills.load.then( => )

The first `.update()` instance.
Wait until the polyfills are loaded before using this library.

### polyfills.update().then( => )

Reload all the polyfills from the source.

### var polyfill = polyfills([options])

The options are:

- `include` - which polyfills to include.
  This is an __inclusive__ list.
  The names are included in [polyfills/db](https://github.com/polyfills/db/blob/master/lib/polyfills.js).
- `exclude` - conversely, you can exclude specific polyfills.

### var js = polyfill(useragent)

Bundle a polyfill for a useragent.

```js
app.use(function (req, res, next) {
  var js = polyfill(req.headers['user-agent')
  res.type('js')
  res.send(js)
})
```

## Adding polyfills

Checkout [polyfills/db](https://github.com/polyfills/db).

[npm-image]: https://img.shields.io/npm/v/polyfills.svg?style=flat-square
[npm-url]: https://npmjs.org/package/polyfills
[github-tag]: http://img.shields.io/github/tag/polyfills/polyfills.svg?style=flat-square
[github-url]: https://github.com/polyfills/polyfills/tags
[travis-image]: https://img.shields.io/travis/polyfills/polyfills.svg?style=flat-square
[travis-url]: https://travis-ci.org/polyfills/polyfills
[coveralls-image]: https://img.shields.io/coveralls/polyfills/polyfills.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/polyfills/polyfills?branch=master
[david-image]: http://img.shields.io/david/polyfills/polyfills.svg?style=flat-square
[david-url]: https://david-dm.org/polyfills/polyfills
[license-image]: http://img.shields.io/npm/l/polyfills.svg?style=flat-square
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/polyfills.svg?style=flat-square
[downloads-url]: https://npmjs.org/package/polyfills
[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square
[gittip-url]: https://www.gittip.com/jonathanong/

---
_Source: https://npm.io/package/polyfills · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
