Function
Static Public Summary | ||
public |
Tests if a function holds true for all elements in an iterable. |
|
public |
Combines two iterables into one by pairing each element in the first with each element in the second. |
|
public |
Tests if a function holds true for any of the elements in an iterable. |
|
public |
Appends an object to the end of an iterable sequence. |
|
public |
Takes an iterable and returns a new iterable with all of the same elements but with a memory buffer. |
|
public |
Splits an iterable into chunks of a given size. |
|
public |
Concatenates two iterables into one. |
|
public |
Counts the number of elements in an iterable. |
|
public |
defaultComparison(i: *, j: *): * |
|
public |
dict(equality: *): {"get": *, "set": *} |
|
public |
distinctUntilChanged(e: Object=, xs: Object): Object Takes an iterable and returns a new one with adjacent duplicate elements removed. |
|
public |
Takes an iterable and returns a new one including only elements that satisfy a given predicate. |
|
public |
Returns the first element of an iterable that satisfies a given predicate. |
|
public |
Takes an iterable and returns a new one where each element is transformed using the given function. |
|
public |
Given an iterable returns a new iterable that repeats it forever. |
|
public |
Given an array, returns an iterable with equivalent elements. |
|
public |
fromGenerator(xs: Object): Object Given a generator function, returns an iterable with equivalent elements. |
|
public |
Returns an iterable of iterables split by the grouping function. |
|
public |
Returns the first element of an iterable. |
|
public |
Tests if a an iterable contains a given element. |
|
public |
indexed(xs: *) |
|
public |
intercalate(s: Object=, xs: Object): Object Puts a given item between each element in a sequence. |
|
public |
isIterable(xs: Object): Boolean Tests if a given object is an iterable |
|
public |
Joins all elements in an iterable using the given seperator. |
|
public |
Constructs an iterable from a fixed list of elements. |
|
public |
Returns the last element of an iterable that satisfies a given predicate. |
|
public |
Takes an iterable and returns a new one where each element is transformed using the given function. |
|
public |
Takes an iterable and returns the largest element, according to the given comparison. |
|
public |
Takes an iterable and returns the smallest element, according to the given comparison. |
|
public |
Tests if a function holds true for none of the elements in an iterable. |
|
public |
Returns the nth element of an iterable. |
|
public |
Takes an iterable and returns a new iterable that may only be iterated once. |
|
public |
Prepends an object to the start of an iterable sequence. |
|
public |
Creates an iterable of numbers from zero to the given limit. |
|
public |
Performs a reduction of an iterable, starting from a given state and reducer function. |
|
public |
Takes an iterable and returns a new iterable where the nth element has been skipped. |
|
public |
Repeats an iterable for the given number of times. |
|
public |
Given an iterable, returns a new iterable with the elements reversed. |
|
public |
Takes an iterable and returns a new iterable where the nth element has been set to a given value. |
|
public |
Returns the first element of an iterable that satisfies a given predicate. |
|
public |
Skips the first n elements of an iterable. |
|
public |
Skips elements from an iterable for as long as the elements satisfy a given condition. |
|
public |
Deep flattens an iterable and all of its nested iterables. |
|
public |
Given an iterable, returns a new iterable with the elements sorted. |
|
public |
sortedBy(f: *, c: *): * |
|
public |
sortedByDesc(f: *, c: *): * |
|
public |
Sums all elements in an iterable. |
|
public |
Returns an iterable of all elements except the first. |
|
public |
Takes the first n elements of an iterable. |
|
public |
Takes elements from an iterable for as long as the elements satisfy a given condition. |
|
public |
Takes an iterable and converts it into an array. |
|
public |
Takes an iterable and returns a new one with duplicate elements removed. |
|
public |
Takes an iterable and returns a new iterable where the nth element has been updated with the given function. |
|
public |
Combines two iterables into one by pairing elements. |
Static Public
public all(f: Function, xs: Object): boolean source
import {all} from '@njlr/seq'
Tests if a function holds true for all elements in an iterable. Always returns true for an empty iterable. This function is curried.
public allPairs(xs: Object, ys: Object): Object source
import {allPairs} from '@njlr/seq'
Combines two iterables into one by pairing each element in the first with each element in the second. Each pair is a two element array. This function creates very long sequences for long inputs. This function is curried.
public any(f: Function, xs: Object): boolean source
import {any} from '@njlr/seq'
Tests if a function holds true for any of the elements in an iterable. Always returns false for an empty iterable. This function is curried.
public append(x: Object, xs: Object): Object source
import {append} from '@njlr/seq'
Appends an object to the end of an iterable sequence. This function is curried.
public buffer(xs: Object): Object source
import {buffer} from '@njlr/seq'
Takes an iterable and returns a new iterable with all of the same elements but with a memory buffer. This can be used to prevent repeated computations.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public chunk(n: Number, xs: Object): Object source
import {chunk} from '@njlr/seq'
Splits an iterable into chunks of a given size. The last chunk may be less than the specified size. This function is curried.
public concat(ys: Object, xs: Object): Object source
import {concat} from '@njlr/seq'
Concatenates two iterables into one.
This function is curried.
public count(xs: Object): number source
import {count} from '@njlr/seq'
Counts the number of elements in an iterable.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public defaultComparison(i: *, j: *): * source
import {defaultComparison} from '@njlr/seq'
Params:
Name | Type | Attribute | Description |
i | * | ||
j | * |
Return:
* |
public dict(equality: *): {"get": *, "set": *} source
import {dict} from '@njlr/seq'
Params:
Name | Type | Attribute | Description |
equality | * |
|
Return:
{"get": *, "set": *} |
public distinctUntilChanged(e: Object=, xs: Object): Object source
import {distinctUntilChanged} from '@njlr/seq'
Takes an iterable and returns a new one with adjacent duplicate elements removed. The order of the iterable is maintained. This function is curried.
Params:
Name | Type | Attribute | Description |
e | Object= | The equality system to use. |
|
xs | Object | The iterable. |
public filter(f: Object, xs: Object): Object source
import {filter} from '@njlr/seq'
Takes an iterable and returns a new one including only elements that satisfy a given predicate.
The order of the iterable is maintained.
This function is curried.
public first(f: Object=, xs: Object): Object source
import {first} from '@njlr/seq'
Returns the first element of an iterable that satisfies a given predicate.
This function will throw an error if no satisfactory element is found.
This function is curried.
Params:
Name | Type | Attribute | Description |
f | Object= | The predicate, defaults to always true. |
|
xs | Object | The iterable. |
public flatMap(f: Object, xs: Object): Object source
import {flatMap} from '@njlr/seq'
Takes an iterable and returns a new one where each element is transformed using the given function.
Unlike map, the function is expected to return an iterable for each element. These iterables are concatenated.
The order of the iterable is maintained.
This function is curried.
public forever(xs: Object): Object source
import {forever} from '@njlr/seq'
Given an iterable returns a new iterable that repeats it forever. Take care, since the resulting iterable is infinite.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable to repeat. |
public fromArray(xs: Object): Object source
import {fromArray} from '@njlr/seq'
Given an array, returns an iterable with equivalent elements. You should not mutate the array used to create the iterable.
Params:
Name | Type | Attribute | Description |
xs | Object | The array. |
public fromGenerator(xs: Object): Object source
import {fromGenerator} from '@njlr/seq'
Given a generator function, returns an iterable with equivalent elements.
Params:
Name | Type | Attribute | Description |
xs | Object | The generator function. |
public groupBy(f: Object, equality: Object, xs: Object): Object source
import {groupBy} from '@njlr/seq'
Returns an iterable of iterables split by the grouping function. If the iterable is empty then an error is thrown. This function is partially curried.
public head(xs: Object): Object source
import {head} from '@njlr/seq'
Returns the first element of an iterable. If the iterable is empty then an error is thrown.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public includes(element: Object, equality: Object, xs: Object): boolean source
import {includes} from '@njlr/seq'
Tests if a an iterable contains a given element. Also takes an equality object as an optional argument. This function is partially curried.
public indexed(xs: *) source
import {indexed} from '@njlr/seq'
Params:
Name | Type | Attribute | Description |
xs | * |
public intercalate(s: Object=, xs: Object): Object source
import {intercalate} from '@njlr/seq'
Puts a given item between each element in a sequence.
Params:
Name | Type | Attribute | Description |
s | Object= | The seperator item. |
|
xs | Object | The iterable to intercalate. |
public isIterable(xs: Object): Boolean source
import {isIterable} from '@njlr/seq'
Tests if a given object is an iterable
Params:
Name | Type | Attribute | Description |
xs | Object | The object to test. |
public join(s: String=, xs: Object): String source
import {join} from '@njlr/seq'
Joins all elements in an iterable using the given seperator. If the iterable is empty then the empty string is returned.
Params:
Name | Type | Attribute | Description |
s | String= | The seperator string. |
|
xs | Object | The iterable to join. |
public just(elements: ...Object): Object source
import {just} from '@njlr/seq'
Constructs an iterable from a fixed list of elements. This function is variadic.
Params:
Name | Type | Attribute | Description |
elements | ...Object | The elements of the iterable. |
public last(f: Object=, xs: Object): Object source
import {last} from '@njlr/seq'
Returns the last element of an iterable that satisfies a given predicate.
This function will throw an error if no satisfactory element is found.
This function is curried.
Params:
Name | Type | Attribute | Description |
f | Object= | The predicate, defaults to always true. |
|
xs | Object | The iterable. |
public map(f: Object, xs: Object): Object source
import {map} from '@njlr/seq'
Takes an iterable and returns a new one where each element is transformed using the given function.
The order of the iterable is maintained.
This function is curried.
public max(c: Object=, xs: Object): Object source
import {max} from '@njlr/seq'
Takes an iterable and returns the largest element, according to the given comparison. This function is curried.
Params:
Name | Type | Attribute | Description |
c | Object= | The comparison. |
|
xs | Object | The iterable. |
public min(c: Object=, xs: Object): Object source
import {min} from '@njlr/seq'
Takes an iterable and returns the smallest element, according to the given comparison. This function is curried.
Params:
Name | Type | Attribute | Description |
c | Object= | The comparison. |
|
xs | Object | The iterable. |
public none(f: Function=, xs: Object): boolean source
import {none} from '@njlr/seq'
Tests if a function holds true for none of the elements in an iterable. Always returns true for an empty iterable. By default, this function returns false for an iterable with any elements. This function is curried.
Params:
Name | Type | Attribute | Description |
f | Function= | The condition to test for each element. |
|
xs | Object | The iterable. |
public nth(n: Number, xs: Object): Object source
import {nth} from '@njlr/seq'
Returns the nth element of an iterable.
This function will throw an error if the iterable is not long enough.
This function is curried.
public once(xs: Object): Object source
import {once} from '@njlr/seq'
Takes an iterable and returns a new iterable that may only be iterated once. This function is useful for debugging purposes.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public prepend(x: Object, xs: Object): Object source
import {prepend} from '@njlr/seq'
Prepends an object to the start of an iterable sequence. This function is curried.
public range(n: Number=): Object source
import {range} from '@njlr/seq'
Creates an iterable of numbers from zero to the given limit.
Params:
Name | Type | Attribute | Description |
n | Number= | The number to count to. |
public reduce(s: Object, f: Object, xs: Object): Object source
import {reduce} from '@njlr/seq'
Performs a reduction of an iterable, starting from a given state and reducer function. Note that this function must not be called on an infinite iterable. This function is partially curried.
public remove(n: Number, xs: Object): Object source
import {remove} from '@njlr/seq'
Takes an iterable and returns a new iterable where
the nth element has been skipped.
This function is curried.
public repeat(n: Number, xs: Object): Object source
import {repeat} from '@njlr/seq'
Repeats an iterable for the given number of times. This function is curried.
public reverse(xs: Object): Object source
import {reverse} from '@njlr/seq'
Given an iterable, returns a new iterable with the elements reversed. Note that this function must not be called on an infinite iterable.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public set(n: Number, value: Object, xs: Object): Object source
import {set} from '@njlr/seq'
Takes an iterable and returns a new iterable where
the nth element has been set to a given value.
This function is curried.
public single(f: Object=, xs: Object): Object source
import {single} from '@njlr/seq'
Returns the first element of an iterable that satisfies a given predicate.
This function will throw an error if no satisfactory element is found.
This function is curried.
Params:
Name | Type | Attribute | Description |
f | Object= | The predicate, defaults to always true. |
|
xs | Object | The iterable. |
public skip(n: Number, xs: Object): Object source
import {skip} from '@njlr/seq'
Skips the first n elements of an iterable. If there are fewer than n elements in an iterable, then an empty iterable will be returned. This function is curried.
public skipUntil(f: Object, xs: Object): Object source
import {skipUntil} from '@njlr/seq'
Skips elements from an iterable for as long as the elements satisfy a given condition. The first element that satisfies the condition will be included. This function is curried.
public smoosh(xs: Object): Object source
import {smoosh} from '@njlr/seq'
Deep flattens an iterable and all of its nested iterables. Strings are not considered iterables for this function.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public sorted(c: Object=, xs: Object): Object source
import {sorted} from '@njlr/seq'
Given an iterable, returns a new iterable with the elements sorted. Note that this function must not be called on an infinite iterable.
Params:
Name | Type | Attribute | Description |
c | Object= | The comparison function to use. |
|
xs | Object | The iterable. |
public sortedBy(f: *, c: *): * source
import {sortedBy} from '@njlr/seq'
Params:
Name | Type | Attribute | Description |
f | * | ||
c | * |
|
Return:
* |
public sortedByDesc(f: *, c: *): * source
import {sortedByDesc} from '@njlr/seq'
Params:
Name | Type | Attribute | Description |
f | * | ||
c | * |
|
Return:
* |
public sum(xs: Object): Number source
import {sum} from '@njlr/seq'
Sums all elements in an iterable. If the iterable is empty then zero is returned.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public tail(xs: Object): Object source
import {tail} from '@njlr/seq'
Returns an iterable of all elements except the first. If the iterable is empty then an error is thrown.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public take(n: Number, xs: Object): Object source
import {take} from '@njlr/seq'
Takes the first n elements of an iterable. If there are fewer than n elements in an iterable, then this has no effect. This function is curried.
public takeWhile(f: Object, xs: Object): Object source
import {takeWhile} from '@njlr/seq'
Takes elements from an iterable for as long as the elements satisfy a given condition. The first element that does satisfies the condition will not be included. This function is curried.
public toArray(xs: Object): Array source
import {toArray} from '@njlr/seq'
Takes an iterable and converts it into an array. This should only be called on finite iterables.
Params:
Name | Type | Attribute | Description |
xs | Object | The iterable. |
public unique(e: Object=, xs: Object): Object source
import {unique} from '@njlr/seq'
Takes an iterable and returns a new one with duplicate elements removed.
The order of the iterable is maintained.
This function is curried.
Params:
Name | Type | Attribute | Description |
e | Object= | The equality system to use. |
|
xs | Object | The iterable. |
public update(n: Number, f: Function, xs: Object): Object source
import {update} from '@njlr/seq'
Takes an iterable and returns a new iterable where
the nth element has been updated with the given function.
This function is curried.