sindresorhus / ponyfill

🦄 Like polyfill but with pony pureness
1.23k stars 24 forks source link

Polyfill the Ponyfill #7

Closed jgermade closed 7 years ago

jgermade commented 7 years ago

Hi!

Regarding de definition of Ponyfill, does it include the use of the native function if exists?

Example ( find.js ):

module.exports = Array.prototype.find ? function (list, iteratee, this_arg) {
  return list.find(iteratee, this_arg);
} : function (list, iteratee, this_arg) {
  for( var i = 0, n = list.length ; i < n ; i++ ) {
    if( iteratee.call(this_arg, list[i], i) ) return list[i];
  }
};
sindresorhus commented 7 years ago

From the readme:

Ponyfills should never use the native API, even if available, as it might have slightly different behavior between environments, which can cause bugs.

:)