for-each.js 367 B

123456789101112
  1. "use strict";
  2. var forOf = require("es6-iterator/for-of")
  3. , isIterable = require("es6-iterator/is-iterable")
  4. , iterable = require("./validate")
  5. , forEach = Array.prototype.forEach;
  6. module.exports = function (target, cb/*, thisArg*/) {
  7. if (isIterable(iterable(target))) forOf(target, cb, arguments[2]);
  8. else forEach.call(target, cb, arguments[2]);
  9. };