Skip to content

Instantly share code, notes, and snippets.

@Constellation
Created October 29, 2014 09:49
Show Gist options
  • Select an option

  • Save Constellation/0d973073bae4c980598c to your computer and use it in GitHub Desktop.

Select an option

Save Constellation/0d973073bae4c980598c to your computer and use it in GitHub Desktop.
object.forEachMethod = function(fn){
if (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++){
fn.call(prototype, prototype[methods[i]], methods[i]);
}
for (var key in prototype) fn.call(prototype, prototype[key], key)
};
// Listing non-enumerable methods here. But there's no "contains" before
// https://github.com/mootools/mootools-core/commit/521471f5c0617edc12c680cdad8346c3eb95776a
...('Array', Array, [
'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'
]) ...
// Now, 'contains' is not enumerated.
Array.forEachMethod(function(method, name){
Elements.implement(name, method);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment