index.js
function each(collection, iterator, context) {
  if (arguments.length === 1) {
    iterator = collection;
    collection = this;
  }

  var isArray = Array.isArray(collection || this)
    , length = collection.length
    , i = 0
    , value;

  if (context) {
    if (isArray) {
      for (; i < length; i++) {
        value = iterator.apply(collection[ i ], context);
        if (value === false) break;
      }
    } else {
      for (i in collection) {
        value = iterator.apply(collection[ i ], context);
        if (value === false) break;
      }
    }
  } else {
    if (isArray) {
      for (; i < length; i++) {
        value = iterator.call(collection[i], i, collection[i]);
        if (value === false) break;
      }
    } else {
      for (i in collection) {
        value = iterator.call(collection[i], i, collection[i]);
        if (value === false) break;
      }
    }
  }

  return this;
}
function each(collection, iterator, context) {
  if (arguments.length === 1) {
    iterator = collection;
    collection = this;
  }

  var isArray = Array.isArray(collection || this)
    , length = collection.length
    , i = 0
    , value;

  if (context) {
    if (isArray) {
      for (; i < length; i++) {
        value = iterator.apply(collection[ i ], context);
        if (value === false) break;
      }
    } else {
      for (i in collection) {
        value = iterator.apply(collection[ i ], context);
        if (value === false) break;
      }
    }
  } else {
    if (isArray) {
      for (; i < length; i++) {
        value = iterator.call(collection[i], i, collection[i]);
        if (value === false) break;
      }
    } else {
      for (i in collection) {
        value = iterator.call(collection[i], i, collection[i]);
        if (value === false) break;
      }
    }
  }

  return this;
}
function each ( collection , iterator , context ) { if ( arguments . length === 1 ) { iterator = collection ; collection = this ; } var isArray = Array . isArray ( collection || this ) , length = collection . length , i = 0 , value ; if ( context ) { if ( isArray ) { for ( ; i < length ; i ++ ) { value = iterator . apply ( collection [ i ] , context ) ; if ( value === false ) break ; } } else { for ( i in collection ) { value = iterator . apply ( collection [ i ] , context ) ; if ( value === false ) break ; } } } else { if ( isArray ) { for ( ; i < length ; i ++ ) { value = iterator . call ( collection [ i ] , i , collection [ i ] ) ; if ( value === false ) break ; } } else { for ( i in collection ) { value = iterator . call ( collection [ i ] , i , collection [ i ] ) ; if ( value === false ) break ; } } } return this ; }
Iterate over a collection. When you return false, it will stop the iteration.

@param {Mixed} collection Either an Array or Object.
@param {Function} iterator Function to be called for each item.
@param {Mixed} context The context for the iterator.
@api public
Iterate over a collection . When you return false it will stop the iteration .