Methods
(static) first(arraynon-null) → {T}
Returns the first element of the array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<T> | The array |
- Source:
Example
import { first } from 'main-fns';
const numbers = [3, 1, 5];
console.log(first(numbers)); // 3
(static) last(arraynon-null) → {T}
Returns the last element of the array
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<T> | The array |
- Source:
Example
import { last } from 'main-fns';
const numbers = [3, 1, 5];
console.log(last(numbers)); // 5
(static) orderBy(keynon-null, arraynon-null) → {Array.<T>}
Returns the the array ordered by key
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The key |
array |
Array.<T> | The array |
- Source:
Example
import { orderBy } from 'main-fns';
const users = [
{ id: 2, name: 'Nabby'},
{ id: 3, name: 'Ivan'}
];
console.log(orderBy('name', users)); // [{ id: 3, name: 'Ivan'}, { id: 2, name: 'Nabby'}]
console.log(orderBy('id', users)); // [{ id: 2, name: 'Nabby'}, { id: 3, name: 'Ivan'}]
(static) reverse(arraynon-null) → {Array.<T>}
Returns the array reversed
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<T> | The array |
- Source: