Skip to content

Commit

Permalink
keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
azproduction committed Feb 23, 2014
1 parent c644d60 commit 5494266
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Autopolyfiller
# Autopolyfiller — Precise polyfills

[![NPM Version](https://badge.fury.io/js/autopolyfiller.png)]
(https://npmjs.org/package/autopolyfiller)
Expand Down
48 changes: 34 additions & 14 deletions example_assets/index.browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ AutoPolyFiller.prototype = {
}

return code;
}).join('\n');
}).join('');
}
};

Expand Down Expand Up @@ -397,7 +397,7 @@ exports.test = function (ast) {
arguments: []
}*/
return statements.reduce(function (polyfils, statement) {
if (statement.callee && statement.callee.name in constructors) {
if (statement.callee && constructors.hasOwnProperty(statement.callee.name)) {
polyfils.push(statement.callee.name);
}
return polyfils;
Expand Down Expand Up @@ -455,7 +455,7 @@ var functionMethods = {
};

function addTo(name, polyfils) {
var type = methods[name];
var type = methods.hasOwnProperty(name) ? methods[name] : void 0;
if (type) {
polyfils.push(type + '.prototype.' + name);
}
Expand Down Expand Up @@ -653,7 +653,7 @@ var expressions = {
objectName = statement.callee && statement.callee.object && statement.callee.object.name;

// in case of .call() .apply() or .bind() change static method name and object name
if (functionMethods[staticMethodName]) {
if (functionMethods.hasOwnProperty(staticMethodName)) {
staticMethodName = statement.callee &&
statement.callee.object &&
statement.callee.object.property &&
Expand All @@ -665,7 +665,9 @@ var expressions = {
statement.callee.object.object.name;
}

var polyFillName = statics[objectName] && statics[objectName][staticMethodName];
var polyFillName = statics.hasOwnProperty(objectName) &&
statics[objectName].hasOwnProperty(staticMethodName) &&
statics[objectName][staticMethodName];

if (polyFillName) {
polyfils.push(polyFillName);
Expand All @@ -686,7 +688,9 @@ var expressions = {
var staticMethodName = statement.property && statement.property.name,
objectName = statement.object && statement.object.name;

var polyFillName = statics[objectName] && statics[objectName][staticMethodName];
var polyFillName = statics.hasOwnProperty(objectName) &&
statics[objectName].hasOwnProperty(staticMethodName) &&
statics[objectName][staticMethodName];

if (polyFillName) {
polyfils.push(polyFillName);
Expand All @@ -700,11 +704,7 @@ exports.test = function (ast) {
var statements = astQuery('__.__(_$)', ast).concat(astQuery('__.__', ast));

return statements.reduce(function (polyfils, statement) {
if (statement.type in expressions) {
polyfils = expressions[statement.type](polyfils, statement);
}

return polyfils;
return expressions[statement.type](polyfils, statement);
}, []);
};

Expand Down Expand Up @@ -2548,6 +2548,13 @@ exports.test = function (ast) {
});
};

Browsers.withPrefix = function(value) {
if (!this.prefixesRegexp) {
this.prefixesRegexp = RegExp("" + (this.prefixes().join('|')));
}
return this.prefixesRegexp.test(value);
};

function Browsers(data, requirements) {
this.data = data;
this.selected = this.parse(requirements);
Expand Down Expand Up @@ -3041,8 +3048,8 @@ var substr = 'ab'.substr(-1) === 'b'
}
;

}).call(this,require("/Users/azproduction/Documents/my/autopolyfiller/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
},{"/Users/azproduction/Documents/my/autopolyfiller/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":15}],17:[function(require,module,exports){
}).call(this,require("/Volumes/DATA/Projects/autopolyfiller/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))
},{"/Volumes/DATA/Projects/autopolyfiller/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":15}],17:[function(require,module,exports){

/**
* Expose `debug()` as the module.
Expand All @@ -3062,6 +3069,8 @@ function debug(name) {
if (!debug.enabled(name)) return function(){};

return function(fmt){
fmt = coerce(fmt);

var curr = new Date;
var ms = curr - (debug[name] || curr);
debug[name] = curr;
Expand Down Expand Up @@ -3164,9 +3173,20 @@ debug.enabled = function(name) {
return false;
};

/**
* Coerce `val`.
*/

function coerce(val) {
if (val instanceof Error) return val.stack || val.message;
return val;
}

// persist

if (window.localStorage) debug.enable(localStorage.debug);
try {
if (window.localStorage) debug.enable(localStorage.debug);
} catch(e){}

},{}],18:[function(require,module,exports){
// Generated by LiveScript 1.2.0
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name" : "autopolyfiller",
"description" : "Like Autoprefixer, but for JavaScript polyfills",
"keywords": ["polyfill", "polyfills", "dom", "ecmascript", "ecmascript5", "ecmascript6", "postprocessor"],
"version" : "1.0.2",
"author" : "Mikhail Davydov <i@azproduction.ru>",
"contributors" : [
Expand Down

0 comments on commit 5494266

Please sign in to comment.