API Docs for: 0.0.8-0
Show:

Array Class

Set of functions that deal with arrays.

Item Index

Methods

Methods

binaryFind

(
  • arr
  • compareFcn
)
Number static

Given a function which takes one argument and returns 1, 0, or -1, returns the first element which causes the given function to return 0.

Parameters:

Returns:

Number:

the index of the element that causes the given function to return 0, returns -1 if no such element exists

binaryIndexOf

(
  • arr
  • compareFcn
)
Number static

Given a function which takes one argument and returns 1, 0, or -1, returns the first element which causes the given function to return 0.

Parameters:

Returns:

Number:

the index of the element that causes the given function to return 0, returns -1 if no such element exists

find

(
  • arr
  • predicate
  • scope
)
Object static

Returns the first element in the given array that satisfies the given predicate. Returns null if no element in the given array satisfies the given predicate.

EXAMPLE
var array = [1, 2, 3, 4]
find(array, function(a_number) { return a_number === 2 }); -> 2
find(array, function(a_number) { return a_number === 5 }); -> null

Parameters:

  • arr Array

    Array to be searched

  • predicate Function

    a function that takes one argument and returns true if the argument satisfies some condition, and false otherwise.

  • scope Object

    ???

Returns:

Object:

first elemtn that satisfies the given preidcate; null if no such element is found

indexOf

(
  • arr
  • predicate
  • scope
)
Number static

Returns the index of the first element in the given array that satisfies the given predicate. Returns -1 if no element in the given array satisfies the predicate.

Parameters:

  • arr Array

    Array to be searched

  • predicate Function

    predicate a function that takes one argument and returns true if the

  • scope Object

    ???

Returns:

Number:

index of the first element that satisfied the predicate; -1 if no such element is found

unique

(
  • array
)
Array static

Returns an array that has only unique values (only the first element is kept).

Parameters:

  • array Array

    Array to be searched

Returns:

Array:

array that has only unique values