Data.ArrayBuffer.Typed
- Package
- purescript-arraybuffer
- Repository
- purescript-contrib/purescript-arraybuffer
This module represents the functional bindings to JavaScript's TypedArray
and other
objects. See MDN's spec for details.
Creation
whole
,remainder
, andpart
are functions for building a typed array accessible interface on top of an existingArrayBuffer
empty
andfromArray
are functions for creating pure typed arrays
Modification
fill
,set
, andsetTyped
are functions for assigning values from external sourcesmap
andtraverse
allow you to create a new array from the existing values in anothercopyWithin
allows you to set values to the array that exist in other parts of the arrayfilter
creates a new array without the values that don't pass a predicatereverse
modifies an existing array in-place, with all values reversedsort
modifies an existing array in-place, with all values sorted
Access
elem
,all
, andany
are functions for testing the contents of an arrayunsafeAt
,hasIndex
, andat
are used to get values from an array, with an indexfoldr
,foldrM
,foldr1
,foldr1M
,foldl
,foldlM
,foldl1
,foldl1M
all can reduce an arrayfind
andfindIndex
are searching functions via a predicateindexOf
andlastIndexOf
are searching functions via equalityslice
returns a new typed array with a new copied underlyingArrayBuffer
subArray
returns a new typed array view of the sameArrayBuffer
toString
prints to a CSV,join
allows you to supply the delimitertoArray
returns an array of numeric values
#buffer Source
buffer :: forall a. ArrayView a -> ArrayBuffer
ArrayBuffer
being mapped by the typed array.
#byteOffset Source
byteOffset :: forall a. ArrayView a -> ByteOffset
Represents the offset of this view from the start of its ArrayBuffer
.
#byteLength Source
byteLength :: forall a. ArrayView a -> ByteLength
Represents the length of this typed array, in bytes.
#TypedArray Source
class TypedArray :: ArrayViewType -> Type -> Constraint
class (BinaryValue a t) <= TypedArray (a :: ArrayViewType) (t :: Type) | a -> t where
Members
create :: forall x. EffectFn3 x (Nullable ByteOffset) (Nullable ByteLength) (ArrayView a)
Instances
#whole Source
whole :: forall a t. TypedArray a t => ArrayBuffer -> Effect (ArrayView a)
View mapping the whole ArrayBuffer
.
#remainder Source
remainder :: forall a b t. TypedArray a t => BytesPerType b => ArrayBuffer -> Index -> Effect (ArrayView a)
View mapping the rest of an ArrayBuffer
after an index.
#part Source
part :: forall a t. TypedArray a t => BytesPerType a => ArrayBuffer -> Index -> Length -> Effect (ArrayView a)
View mapping a region of the ArrayBuffer
.
#empty Source
empty :: forall a t. TypedArray a t => Length -> Effect (ArrayView a)
Creates an empty typed array, where each value is assigned 0.
#fromArray Source
fromArray :: forall a t. TypedArray a t => Array t -> Effect (ArrayView a)
Creates a typed array from an input array of values, to be binary serialized.
#copyWithin Source
copyWithin :: forall a. ArrayView a -> Index -> Index -> Maybe Index -> Effect Unit
Internally copy values - see MDN's spec for details.
#map Source
map :: forall a t. TypedArray a t => (t -> t) -> ArrayView a -> ArrayView a
Maps a new value over the typed array, creating a new ArrayBuffer
and
typed array as well.
#mapWithIndex Source
mapWithIndex :: forall a t. TypedArray a t => (Index -> t -> t) -> ArrayView a -> ArrayView a
Apply a function to each element in an array, supplying a generated zero-based index integer along with the element, creating a typed array with the new elements.
#traverseWithIndex Source
traverseWithIndex :: forall a t. TypedArray a t => (Index -> t -> Effect t) -> ArrayView a -> Effect (ArrayView a)
Traverses over each value, returning a new one.
#traverseWithIndex_ Source
traverseWithIndex_ :: forall a t. TypedArray a t => (Index -> t -> Effect Unit) -> ArrayView a -> Effect Unit
Traverses over each value.
#filterWithIndex Source
filterWithIndex :: forall a t. TypedArray a t => (Index -> t -> Boolean) -> ArrayView a -> Effect (ArrayView a)
Returns a new typed array with all values that pass the predicate. The predicate function receives the index and the element.
#allWithIndex Source
allWithIndex :: forall a t. TypedArray a t => (Index -> t -> Boolean) -> ArrayView a -> Effect Boolean
Test a predicate to pass on all values. The predicate function receives the index and the element.
#anyWithIndex Source
anyWithIndex :: forall a t. TypedArray a t => (Index -> t -> Boolean) -> ArrayView a -> Effect Boolean
Test a predicate (that receives also an index) to pass on any value.
#foldl Source
foldl :: forall a b t. TypedArray a t => (b -> t -> b) -> b -> ArrayView a -> Effect b
Fold a list from the left, accumulating the result using the specified function.
#foldl1 Source
foldl1 :: forall a t. Partial => TypedArray a t => (t -> t -> t) -> ArrayView a -> Effect t
Folding from the left. Assumes the typed array is non-empty.
#reduceRight Source
reduceRight :: forall a t b. TypedArray a t => (t -> b -> Index -> Effect b) -> b -> ArrayView a -> Effect b
Folding from the right.
#reduceRight1 Source
reduceRight1 :: forall a t. Partial => TypedArray a t => (t -> t -> Index -> Effect t) -> ArrayView a -> Effect t
Folding from the right. Assumes the typed array is non-empty.
#foldr Source
foldr :: forall a b t. TypedArray a t => (t -> b -> b) -> b -> ArrayView a -> Effect b
Fold a list from the right, accumulating the result using the specified function.
#foldr1 Source
foldr1 :: forall a t. Partial => TypedArray a t => (t -> t -> t) -> ArrayView a -> Effect t
Folding from the right. Assumes the typed array is non-empty.
#foldlWithIndex Source
foldlWithIndex :: forall a b t. TypedArray a t => (Index -> b -> t -> b) -> b -> ArrayView a -> Effect b
Fold a list from the left, accumulating the result using the supplied function. The accumulating function receives the index, the accumulated value and the element.
#foldrWithIndex Source
foldrWithIndex :: forall a b t. TypedArray a t => (Index -> t -> b -> b) -> b -> ArrayView a -> Effect b
Fold a list from the right, accumulating the result using the supplied function. The accumulating function receives the index, the element and the accumulated value.
#findWithIndex Source
findWithIndex :: forall a t. TypedArray a t => (Index -> t -> Boolean) -> ArrayView a -> Effect (Maybe t)
Returns the first value satisfying the predicate. The predicate receives the index and the element at that index.
#lastIndexOf Source
lastIndexOf :: forall a t. TypedArray a t => t -> Maybe Index -> ArrayView a -> Effect (Maybe Index)
Returns the first index of the element, if it exists, from the right.
#toString Source
toString :: forall a. ArrayView a -> Effect String
Prints array to a comma-separated string - see MDN's spec for details.