Skip to content
Adam Smith edited this page Mar 3, 2016 · 10 revisions

vitals.each npm version

Method Section Alias
each base
each.object base each.obj
each.array base each.arr
each.cycle base each.time

each

A shortcut for iterating over object maps, arrays, or cycles.

Examples

Params

  1. source !(Object|function|Array|number|string)
Details per type:
  - object source: Iterates over all properties in random order.
  - array source:  Iterates over all indexed properties from 0 to length.
  - number source: Iterates over all cycles.
  - string source: Converted to an array source using one of the following list of values for the separator (values listed in order of rank):
    - `", "`
    - `","`
    - `"|"`
    - `" "`
  1. iteratee function(*=, (string|number)=, !(Object|function)=)
It has the optional params - value, key/index, source. Note this method lazily clones the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  1. thisArg Object=
If defined the iteratee is bound to this value.

Returns (Object|function|Array|undefined)

each.object

A shortcut for iterating over object maps.

Examples

Params

  1. source !(Object|function)
  2. iteratee function(*=, string=, !(Object|function)=)
The iteratee must be a function with the optional params - value, key, source. Note this method lazily clones the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  1. thisArg Object=
If defined the iteratee is bound to this value.

Returns !(Object|function)

each.array

A shortcut for iterating over array-like objects.

Examples

Params

  1. source !(Object|function|string)
If source is a string it is converted to an array using one of the following list of values for the separator (values listed in order of rank):
  - `", "`
  - `","`
  - `"|"`
  - `" "`
  1. iteratee function(*=, number=, !Array=)
The iteratee must be a function with the optional params - value, index, source. Note this method lazily slices the source based on the iteratee's [length property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) (i.e. if you alter the source object within the iteratee ensure to define the iteratee's third param so you can safely assume all references to the source are its original values).
  1. thisArg Object=
If defined the iteratee is bound to this value.

Returns !(Object|function|Array)

each.cycle

A shortcut for iterating over a set number of cycles.

Examples

Params

  1. count number
  2. iteratee function(number=)
  3. thisArg Object=
If defined the iteratee is bound to this value.

Returns undefined

-- Happy Developing,

Algorithm IV Logo

Clone this wiki locally