# gulp-polyfit

> collect polyfills marked in comments and generate the polyfill script

Latest version **1.0.0** (published 2017-04-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-polyfit
pnpm add gulp-polyfit
yarn add gulp-polyfit
bun add gulp-polyfit
```

## 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 | 1.0.0 |
| Published | 2017-04-04 |
| First published | 2017-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | tingyuan |
| Maintainers | tingyuan |
| Keywords | gulpplugin, polyfill, gulp, plugin |

## Links

- npm: https://www.npmjs.com/package/gulp-polyfit
- Repository: https://github.com/lovetingyuan/gulp-polyfit
- Homepage: https://github.com/lovetingyuan/gulp-polyfit#readme
- Issues: https://github.com/lovetingyuan/gulp-polyfit/issues
- npm.io page: https://npm.io/package/gulp-polyfit

## Dependencies (4)

- [acorn](https://npm.io/package/acorn.md) ^5.0.2
- [ty-step](https://npm.io/package/ty-step.md) ^1.0.1
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.8

## Recent versions

- 1.0.0 (latest) — 2017-04-04

## README

# gulp-polyfit
Generate the polyfill file by collecting the polyfill marks in the comment, thanks to https://polyfill.io

### install
`npm install gulp-polyfit --save-dev`

### usage
```javascript
var gulp = require('gulp')
var polyfit = require('gulp-polyfit')
gulp.task('polyfill', function() {
  return gulp.src('test.js')
    .pipe(polyfit({
      output: './', // output dir, default: './'
      minify: true, // default: true, minify the polyfill script
      features: [], // extra polyfill features
      filename: 'polyfill.min.js', // the polyfill file name, default: polyfill.min.js
      result: 'polyfill_list.json' // if specified, will output all the polyfills name
    }))
    .pipe(gulp.dest('./'))
})
```
test.js:
```javascript
/**
 * polyfill: Array.from,
 *     Number.parseInt, Number.isInteger
 */
function addInt() {
  var args = Array.from(arguments)
  // polyfill: Array.prototype.map, Array.prototype.filter
  return args.map(function(value) {
    return Number.parseInt(value, 10)
  }).filter(function(value) {
    return Number.isInteger(value)
  }).reduce(function(foo, bar) { // polyfill: Array.prototype.reduce
    return foo + bar
  })
}
console.log(addInt(1, 2, 3)) // result is 6
```
run `gulp polyfill`, and the polyfill_list.json will be:
```json
{
  "polyfills": [
    "Array.from",
    "Array.prototype.filter",
    "Array.prototype.map",
    "Array.prototype.reduce",
    "Number.isInteger",
    "Number.parseInt"
  ]
}
```

**the polyfill comment must start with `"polyfill:"` and separate the features by commas**

you can find all support features at https://polyfill.io/v2/docs/features/,

you can use `(LABjs)['https://github.com/getify/LABjs']` or `(yepnope.js)['https://github.com/SlexAxton/yepnope.js']` to load polyfills conditionally,

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