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

vitals.until npm version

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

until

A shortcut for iterating over object maps, arrays, or cycles until an end value is returned.

Examples

Params

  1. end *
A value that ends the iteration if returned by the iteratee.
  1. source !(Object|function|Array|number|string)=
If the source is defined the iteration will also stop as follows (per source type):
  - object source: Ends after all properties are visited.
  - array source:  Ends after all indexes are visited.
  - number source: Ends after the count of cycles equals the source.
  - string source: Converted to an array source using one of the following values as 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 boolean

This method will return true if the iteratee returns the end value or false if the iteratee does not.

until.object

A shortcut for iterating over object maps until an end value is returned or all properties are visited.

Examples

Params

  1. end *
A value that ends the iteration if returned by the iteratee.
  1. obj (!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=

Returns boolean

If the iteration is terminated by the end value this method will return true. Otherwise if all the properties are visited this method will return false.

until.array

A shortcut for iterating over array-like objects until an end value is returned or all indexed values are visited.

Examples

Params

  1. end *
A value that ends the iteration if returned by the iteratee.
  1. source (!Object|function|string)
If source is a string it is converted to an array source using one of the following values as 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 (see [vitals.copy.array](https://github.com/imaginate/vitals/wiki/vitals.copy#copyarray)) 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=

Returns boolean

If the iteration is terminated by the end value this method will return true. Otherwise if all the indexed values are visited this method will return false.

until.cycle

A shortcut for invoking an action until an end value is returned or the number of cycles is reached.

Examples

Params

  1. end *
A value that ends the iteration if returned by the iteratee.
  1. count number
The number of cycles.
  1. action function(number=)
  2. thisArg Object=

Returns boolean

If the iteration is terminated by the end value this method will return true. Otherwise if the number of cycles is reached this method will return false.

-- Happy Developing,

Algorithm IV Logo

Clone this wiki locally