Namespace Arrays

These array functions do not change the input data, unless noted.

Import example:

import { Arrays } from 'https://unpkg.com/ixfx/dist/data.js';

For arrays of numbers:

  • minMaxAvg: Find smallest, largest and average
  • See also Numbers module for working with numbers in general.

Randomisation

  • randomIndex: Return a random array index
  • randomElement: Return a random value
  • randomPluck: Remove a random element from an array, returning it and the new array
  • shuffle: Returns a randomly-sorted copy of arra

Comparing

  • contains: compare overlap of arrays
  • isEqual: true if two arrays contain same values at same locations
  • unique: Returns values from two arrays, without duplicates.

Iterating

Finding/accessing

  • cycle: every time function is called, the next item from array is returned
  • filterBetween: Same as Array.filter but only looks within a specified index range
  • filterAB: Like array.filter, but returns two arrays. One containing values that the predicate gives true, another for _false.
  • sample: Returns a new array with a random sampling of input
  • until: Returns items from input until predicate returns true

Sort

Duplicates

Changing the shape

  • chunks: Chunk into sub-arrays
  • ensureLength: Returns a copy of array with designated length, either padding it out or truncating as necessary
  • groupBy: Groups data into a new Map
  • flatten
  • filterBetween: Like array.filter, but only checks within given range
  • interleave: Flattens several arrays into one, interleaving their values.
  • remove: Remove an item by index
  • pairwiseReduce: Reducer that operates in pairwise fashion
  • mergeByKey+: Merges two arrays left-to-right, using a reconcile function
  • without: Returns an array with specified value omitted
  • zip: Groups together elements from several arrays based on their index

Index

Type Aliases

Functions