A collection of which values will be tested by the predicate.
A function that for each collection item needs to return a boolean value. Similar to Javascript's filter().
Check if any element of the collection returns true
for the provided
predicate.
A collection of which values will be tested by the predicate.
A function that for each collection item needs to return a boolean value. Similar to Javascript's filter().
An async version of node's setTimeout
.
Time is specified in milliseconds.
Performs provided action specified number of times. An index of the iteration is passed to the action. If the action returns a value, the function will returns an array of returned values.
Number of times to call the action
.
A function called times
times. It can optionally receive
an iteration number in form of an index
argument (starts from 0
).
Can return a value.
An array of values returned by performed actions. If actions don't
return anything, the void[]
will be returned.
Pick random element of provided collection. Will return undefined
if
collection is empty or invalid.
Returns a random integer between min
and max
values. Both min
and max
are inclusive.
Create an array of null
elements. The array will contain specified number
of elements. If specified number is lesser or equal to 0
empty array will
be returned. Non-integer numbers will be rounded down.
Generated using TypeDoc
Checks if all elements of the collection return
true
for the provided predicate.Used on an array where all values match the predicate:
import { all } from '@hubhazard/core'; const collection = [6, 74, 43, 331, 20]; const result = all(collection, element => element > 5); // result equals true
Used on a set with at least one value not matching the predicate:
import { all } from '@hubhazard/core'; const collection = new Set([30, 21, 6, 100392]); const isEven = (value) => value % 2 === 0; const result = all(collection, isEven); // result equals false