autopolyfiller
Advanced tools
Comparing version 1.6.0 to 1.6.1
35
index.js
@@ -1,9 +0,10 @@ | ||
var acorn = require('acorn'), | ||
assert = require('assert'), | ||
scan = require('./lib/polyfill-scan'), | ||
reduce = require('./lib/polyfill-reduce'), | ||
wrap = require('./lib/polyfill-wrap'), | ||
code = require('./lib/polyfill-code'); | ||
var acorn = require('acorn'); | ||
var assert = require('assert'); | ||
var scan = require('./lib/polyfill-scan'); | ||
var reduce = require('./lib/polyfill-reduce'); | ||
var wrap = require('./lib/polyfill-wrap'); | ||
var minimatch = require('minimatch'); | ||
var code = require('./lib/polyfill-code'); | ||
var stablePolyfills = require('autopolyfiller-stable'); | ||
var polyfillNames = Object.keys(stablePolyfills.polyfill); | ||
@@ -85,4 +86,4 @@ /** | ||
add: function (code) { | ||
var polyfills = this._scan(code), | ||
polyfillsOfPolyfills = this._scanForPolyfillsOfPolyfills(polyfills); | ||
var polyfills = this._scan(code); | ||
var polyfillsOfPolyfills = this._scanForPolyfillsOfPolyfills(polyfills); | ||
@@ -126,2 +127,16 @@ this.include(polyfills.concat(polyfillsOfPolyfills)); | ||
// If any of the patterns contain '*', add all of the matching | ||
// polyfills | ||
.reduce(function (polyfills, polyfill) { | ||
if (polyfill.indexOf('*') > -1) { | ||
var matches = polyfillNames.filter(function (name) { | ||
return minimatch(name, polyfill); | ||
}); | ||
return polyfills.concat(matches); | ||
} | ||
polyfills.push(polyfill); | ||
return polyfills; | ||
}, []) | ||
// Filter ignored polyfills | ||
@@ -189,3 +204,3 @@ .filter(this._isPolyfillIncluded.bind(this)) | ||
function create() { | ||
var browsers = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; | ||
var browsers = arguments.length >= 1 ? [].slice.call(arguments, 0) : []; | ||
@@ -192,0 +207,0 @@ if (browsers.length === 1 && browsers[0] instanceof Array) { |
@@ -1,8 +0,8 @@ | ||
var Command = require('commander').Command, | ||
fs = require('fs'), | ||
mkdirp = require('mkdirp').sync, | ||
format = require('util').format, | ||
path = require('path'), | ||
globule = require('globule'), | ||
autopolyfiller = require('..'); | ||
var Command = require('commander').Command; | ||
var fs = require('fs'); | ||
var mkdirp = require('mkdirp').sync; | ||
var format = require('util').format; | ||
var path = require('path'); | ||
var globule = require('globule'); | ||
var autopolyfiller = require('..'); | ||
@@ -66,5 +66,5 @@ var noop = function () {}; | ||
createPolyFiller: function () { | ||
var browsers = this.program.browsers, | ||
excludedPolyfills = this.program.exclude, | ||
includedPolyfills = this.program.include; | ||
var browsers = this.program.browsers; | ||
var excludedPolyfills = this.program.exclude; | ||
var includedPolyfills = this.program.include; | ||
@@ -101,3 +101,8 @@ this.log((function () { | ||
.option('-p, --parser <parser>', 'specifies JavaScript parser (node module)', require, null) | ||
.option('-P, --parser-options <parser-options>', 'custom parser options (valid json object)', JSON.parse.bind(JSON), void 0) | ||
.option( | ||
'-P, --parser-options <parser-options>', | ||
'custom parser options (valid json object)', | ||
JSON.parse.bind(JSON), | ||
void 0 | ||
) | ||
.option('-v, --verbose', 'verbose output') | ||
@@ -154,4 +159,4 @@ .on('--help', function () { | ||
writePolyFills: function () { | ||
var output = this.program.output, | ||
polyfills = this.polyfiller.polyfills; | ||
var output = this.program.output; | ||
var polyfills = this.polyfiller.polyfills; | ||
@@ -158,0 +163,0 @@ this.log((function () { |
@@ -1,3 +0,3 @@ | ||
var extend = require('node.extend'), | ||
debug = require('debug')('polyfill:code'); | ||
var extend = require('node.extend'); | ||
var debug = require('debug')('polyfill:code'); | ||
@@ -4,0 +4,0 @@ var polyfillsCode = {}; |
@@ -1,4 +0,4 @@ | ||
var browserslist = require('browserslist'), | ||
debug = require('debug')('polyfill:reduce'), | ||
semver = require('semver'); | ||
var browserslist = require('browserslist'); | ||
var debug = require('debug')('polyfill:reduce'); | ||
var semver = require('semver'); | ||
@@ -9,9 +9,9 @@ var polyFillSets = {}; | ||
var browserMap = { | ||
'ie': 'Internet Explorer', | ||
'firefox': 'Firefox', | ||
'chrome': 'Chrome', | ||
'safari': 'Safari', | ||
'opera': 'Opera', | ||
'ios_saf': 'Safari iOS', | ||
'android': 'Android' | ||
ie: 'Internet Explorer', | ||
firefox: 'Firefox', | ||
chrome: 'Chrome', | ||
safari: 'Safari', | ||
opera: 'Opera', | ||
ios_saf: 'Safari iOS', | ||
android: 'Android' | ||
/*,'ie_mob': ''*/ | ||
@@ -18,0 +18,0 @@ }; |
/*! | ||
* polyfill-scan | ||
*/ | ||
var acorn = require('acorn'), | ||
debug = require('debug')('polyfill:scan'); | ||
var acorn = require('acorn'); | ||
var debug = require('debug')('polyfill:scan'); | ||
@@ -7,0 +7,0 @@ var matchers = []; |
@@ -1,3 +0,3 @@ | ||
var extend = require('node.extend'), | ||
debug = require('debug')('polyfill:wrap'); | ||
var extend = require('node.extend'); | ||
var debug = require('debug')('polyfill:wrap'); | ||
@@ -15,4 +15,4 @@ var polyfillsWrappers = {}; | ||
debug('wrapping code of `%s` using default wrapper', polyfillName); | ||
var parts = polyfillName.split('.'), | ||
expression = 'true'; | ||
var parts = polyfillName.split('.'); | ||
var expression = 'true'; | ||
@@ -19,0 +19,0 @@ if (parts.length === 1) { |
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"author": "Mikhail Davydov <i@azproduction.ru>", | ||
@@ -31,10 +31,11 @@ "contributors": [ | ||
"acorn": "~0.11.0", | ||
"autopolyfiller-stable": "~1.0.2", | ||
"browserslist": "~0.1.0", | ||
"commander": "~2.1.0", | ||
"debug": "~0.7.4", | ||
"node.extend": "~1.0.9", | ||
"commander": "~2.1.0", | ||
"globule": "0.2.0", | ||
"minimatch": "^2.0.7", | ||
"mkdirp": "~0.3.5", | ||
"semver": "~2.2.1", | ||
"autopolyfiller-stable": "~1.0.2" | ||
"node.extend": "~1.0.9", | ||
"semver": "~2.2.1" | ||
}, | ||
@@ -44,15 +45,15 @@ "devDependencies": { | ||
"browserify": "*", | ||
"chai": "*", | ||
"codeclimate-test-reporter": "~0.0.3", | ||
"coveralls": "*", | ||
"glob": "~3.2.9", | ||
"grasp-equery": "~0.2.0", | ||
"husky": "~0.5.1", | ||
"istanbul": "~0.2.11", | ||
"jscs": "^1.13.1", | ||
"jshint": "^2.7.0", | ||
"mocha": "~2.2.4", | ||
"mocha-istanbul": "*", | ||
"mock-utf8-stream": "*", | ||
"uglify-js": "*", | ||
"jshint": "2.1.3", | ||
"mocha": "~1.11.0", | ||
"jscs": "~1.4.5", | ||
"istanbul": "~0.2.11", | ||
"codeclimate-test-reporter": "~0.0.3", | ||
"chai": "*", | ||
"coveralls": "*", | ||
"husky": "~0.5.1" | ||
"uglify-js": "*" | ||
}, | ||
@@ -62,10 +63,15 @@ "bin": { | ||
}, | ||
"files": [ | ||
"bin/", | ||
"lib/", | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "jshint . && jscs . && mocha -R spec", | ||
"test": "npm run lint && mocha -R spec", | ||
"lint": "jshint . && jscs . ", | ||
"coverage": "istanbul cover node_modules/.bin/_mocha --report html -- -R spec", | ||
"coverage_push": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && cat ./coverage/lcov.info | codeclimate || true", | ||
"precommit": "npm test", | ||
"prepush": "npm test", | ||
"benchmark": "node ./benchmark/scan" | ||
} | ||
} |
# Autopolyfiller — Precise polyfills | ||
[![NPM Version](https://badge.fury.io/js/autopolyfiller.png)](https://npmjs.org/package/autopolyfiller) [![Build Status](https://travis-ci.org/azproduction/autopolyfiller.png?branch=master)](https://travis-ci.org/azproduction/autopolyfiller) [![Coverage Status](https://coveralls.io/repos/azproduction/autopolyfiller/badge.png?branch=master&)](https://coveralls.io/r/azproduction/autopolyfiller) [![Code Climate](https://codeclimate.com/github/azproduction/autopolyfiller.png)](https://codeclimate.com/github/azproduction/autopolyfiller) [![Dependency Status](https://gemnasium.com/azproduction/autopolyfiller.png)](https://gemnasium.com/azproduction/autopolyfiller) | ||
[![NPM Version](https://img.shields.io/npm/v/autopolyfiller.svg)](https://npmjs.org/package/autopolyfiller) [![Build Status](https://img.shields.io/travis/azproduction/autopolyfiller.svg)](https://travis-ci.org/azproduction/autopolyfiller) [![Coverage Status](https://img.shields.io/coveralls/azproduction/autopolyfiller.svg)](https://coveralls.io/r/azproduction/autopolyfiller) [![Code Climate](https://img.shields.io/codeclimate/github/azproduction/autopolyfiller.svg)](https://codeclimate.com/github/azproduction/autopolyfiller) [![Dependency Status](https://img.shields.io/gemnasium/azproduction/autopolyfiller.svg)](https://gemnasium.com/azproduction/autopolyfiller) | ||
@@ -25,3 +25,3 @@ This is like [Autoprefixer](https://github.com/ai/autoprefixer), but for JavaScript polyfills. It scans your code and applies only required polyfills. [Live example](http://azproduction.github.io/autopolyfiller). | ||
## Installation | ||
## Installation | ||
@@ -96,2 +96,4 @@ `autopolyfiller` can be installed using `npm`: | ||
.include(['String.prototype.trim']) | ||
// All Array polyfills | ||
.include(['Array.*']) | ||
.add('new My.Promise();') | ||
@@ -126,3 +128,3 @@ .polyfills; | ||
}, | ||
// Your polyfills code | ||
@@ -132,3 +134,3 @@ polyfill: { | ||
}, | ||
// This list means "apply this feature to the <list of browsers>" | ||
@@ -143,3 +145,3 @@ // For more examples see https://github.com/jonathantneal/polyfill/blob/master/agent.js.json | ||
}, | ||
// This is optional. By default autopolyfiller will use | ||
@@ -146,0 +148,0 @@ // polyfill's name to generate condition's code: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
184
1
1
30571
10
11
642
+ Addedminimatch@^2.0.7
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedminimatch@2.0.10(transitive)