import * as fun from "https://deno.land/x/fun@v.2.0.0-alpha.11/array.ts";
This file contains a collection of utilities and algebraic structure implemenuations for ReadonlyArray in JavaScript.
Variables
The canonical implementation of Alt for ReadonlyArray. It contains the methods alt and map. | |
The canonical implementation of Applicative for ReadonlyArray. It contains the methods of, ap, and map. | |
The canonical implementation of Apply for ReadonlyArray. It contains the methods ap and map. | |
The canonical implementation of Chain for ReadonlyArray. It contains the methods of, map, and chain. | |
The canonical implementation of Filterable for ReadonlyArray. It contains the methods filter, filterMap, partition, and partitionMap. | |
The canonical implementation of Foldable for ReadonlyArray. It contains the method reduce. | |
The canonical implementation of Functor for ReadonlyArray. It contains the method map. | |
The canonical implementation of Monad for ReadonlyArray. It contains the methods of, ap, map, join, and chain. | |
The canonical implementation of Traversable for ReadonlyArray. It contains the methods map, reduce, and traverse. |
Functions
UNSAFE This operation mutates a standard Array by pushing onto it. This function is intended for internal use only and thus has no api guaruntees. | |
UNSAFE This operation creates a new array from ua with the value deleted at the given index. The deletiong index must be tested as in bounds before calling this function. This function is intended for internal use only and thus has no api guaruntees. | |
UNSAFE This operation creates a new array from ua with the value a inserted at the given index. The insertion index must be tested as in bounds before calling this function. This function is intended for internal use only and thus has no api guaruntees. | |
UNSAFE This operation mutates a standard Array by adding all elements from a second array to it. This function is intended for internal use only and thus has no api guaruntees. | |
UNSAFE This operation muuates a standard Array by unshifting onto it. This function is intended for internal use only and thus has no api guaruntees. | |
UNSAFE This operation mutates a standard Array by pushing onto it. This function is intended for internal use only and thus has no api guaruntees. | |
UNSAFE This operation creates a new array from ua with the value a changed at the given index. The insertion index must be tested as in bounds before calling this function. This function is intended for internal use only and thus has no api guaruntees. | |
f alt | Given two arrays first and second, if first is empty the return second, otherwise return first. |
f ap | Given an array of functions ReadonlyArray<A -> I> and a ReadonlyArray apply every function in the function array to every value in the ReadonlyArray. This implementation loops first over the functions, and then over the values, so the order of results will be [fn1(val1), fn2(val1), fn3(val1), ..., fn1(val2), fn2(val2), ... fn1(valN), ... fnN(valN)]. |
Create a new array by appending an item to the end of an existing array. | |
Create a NonEmptyArray from a variadic number of arguments. | |
Given an Ord over A, create a binary search function for a sorted ReadonlyArray that returns the array index that the new value should be inserted at in order to maintain a sorted array. | |
Given a function A -> ReadonlyArray and a ReadonlyArray apply the function to every value in the array and combine all results, returning a ReadonlyArray. | |
Given two arrays first and second, join them into a new array effectively doing [...first, ...second]. | |
Delete the value in an array at the given index. If the index is out of bounds then no change is made. | |
Create an empty array of type A (defaulting to never). | |
Given a Predicate or Refinement, apply the predicate or refinement to every value in an array, removing (and refining) the elements that the predicate or refinement return false for. | |
Filter and map over an ReadonlyArray in the same step. This function applies the predicate to each value in an array. If the predicate returns Some, then the inner I is added to the output array. | |
Given an instance Eq create a Eq<ReadonlyArray>. | |
Create an instance of Monoid<ReadonlyArray> given a type A. This instance uses array concat and empty as the instance methods for the Monoid. | |
Given an instance Ord create a Ord<ReadonlyArray>. | |
Create a Free semigroup over a type A using Array.concat. | |
Create an instance of Show for ReadonlyArray given an instance of Show for A. | |
Create a new array by inserting a value into an array at an index. If the index is out of range of the existing array then no change is made. | |
Create a new array by inserting a value into an array at an index. If the index is out of range of the existing array then no change is made. | |
This predicate over ReadonlyArray returns true when called with an empty array, otherwise it returns false. | |
A Refinement<ReadonlyArray, NonEmptyArray>, returning true if called with an array that has at least one item. | |
Given an index and a ReadonlyArray, return true if the index is valid for the given array. This tests whether index is between 0 and arr.length inclusive. | |
f join | Given an array of arrays, flatten all inner arrays into a single external array. |
Lookup the value in an array at the given index. If the index is out of bounds this function returns none. | |
f map | Apply the function fai: (A, index) => I to every element in the array ua. |
Create a new array by modifying a value of an array at an index. If the index is out of range of the existing array then no change is made. | |
Create a new array by modifying a value of an array at an index. If the index is out of range of the existing array then no change is made. | |
f of | Create a NonEmptyArray conuaining the value A. |
Given an Ord construct a curried insert function that inserts values into a new array in a sorted fashion. Internally this uses binarySearch to find the insertion index of any inserted items. Since the returned function will always insert this function will always return a new array. | |
Partition a ReadonlyArray into two ReadonlyArrays using a predicate or refinement to do the sorting. If the predicate or refinement returns true for a value, the value is pushed into the first array in a Pair, otherwise it is pushed into the second array in a pair. | |
Partition and map over a ReadonlyArray in the same loop. Given a predicate A => Either<J, I>, this function passes each element in an array into the predicate. If the predicate returns Right then the inner I is pushed into the first array in a pair. If the predicate returns Left then the inner J is pushed into the second array in a pair. | |
Create a new array by prepending an item to the head of an existing array. | |
Create a range of numbers with count values, starting at start (default 0) and stepping by step (default 1). | |
Reduce an array from left to right, accumulating into a type O via the function foao: (O, A, index) => O and an initial value O. | |
Sequence over an array of type V, inverting the relationship between V and ReadonlyArray. This function also keeps the indexed types of in each V at covariant position 0. In other words sequence over [Option, Option] becomes Option<[number, string]>. | |
f sort | Returns a new array conuaining elements of |
Traverse a ReadonlyArray using an Applicative over V and a mapping function A => V. | |
Create a new array by replacing a value of an array at an index. If the index is out of range of the existing array then no change is made. | |
Create a new array by replacing a value of an array at an index. If the index is out of range of the existing array then no change is made. | |
f zip | Collect the values of many arrays into an array of tuples. Each tuple contains an element from each of the input arrays at a shared index. The number of tuples in the returned array will match the minimum length of the input arrays. ie. If any input array is empty, then the output array will be empty. |
Interfaces
Specifies ReadonlyArray as a Higher Kinded Type, with covariant parameter A corresponding to the 0th index of any substitutions. |
Type Aliases
This type can be used as a placeholder for an array of any type. | |
This type alias represents a ReadonlyArray conuaining at least one value at the head. | |
This type alias extracts the inner type of a ReadonlyArray. |