⚒️ Vangware curried functional utils.
Collection of curried functional utils made entirely in TypeScript. Compatible with all modern JS environments:
This package can be installed as a dependency or used directly.
In JS or deno:
import { isObject } from "https://cdn.skypack.dev/@vangware/utils?dts";
Or in HTML:
<script type="module" src="https://cdn.skypack.dev/@vangware/utils"></script>
First:
npm i @vangware/utils
And then:
import { isObject } from "@vangware/utils";
Documentation can be found HERE. It is auto-generated with typedoc based on the JSDocs and the types in the source. Shouldn't be necessary to read this, code editors like VSCode integrate the documentation in the UI.
Changelog can be found HERE.
Test coverage can be found HERE.
Type of items in the ArrayLike or Iterable.
2-Tuple to represent decimals [coefficient, exponent]
Array of Entries (Entry
type).
Source object to which the entities belong to.
Entity tuple [key, object[key]]
.
Source object to which the entity belongs to.
Types that evaluates to false
in JS.
Tuple generated by arrayFilterTuple, which contains matching and non matching values.
Type of the items being filtered.
Type of the matching items.
Filterer function.
Type of the items in the source array.
Type of filtered items.
Object with the following shape:
{
[groupName]: [...valuesOfGroupName]
}
Type of the items in the source array.
Grouper function.
Type of the items in the source array.
Guarded filterer function.
Type of the items in the source array.
Type of filtered items.
Readonly Record
wrapper.
Possible values of the given Record.
Key type of given Record.
Mapper function.
Type of the items in the source array.
Type of the output (same as the input by default).
Union of null
and undefined
.
Excludes only if it doesn't return never
. Fallback to Exclusion
.
Type to apply exclusion on.
Exclusion object.
Valid radix values (from 2 to 36).
Reducer function.
Type of the items in the source array.
Type of the output (same as the input by default).
Sorter function.
Object with the following shape:
{
[searchString]: "replacingString"
}
Generic type to check if value is not Falsy (evaluates to true
in JS).
Actual type (if not truthy).
Possible types returned by typeof
.
Unguarded filter function.
Type of the items in the source array.
Takes an item
and inserts it at the beginning of given source array.
Takes an item
and inserts it at the end of given source
array.
Takes an item
and replaces the first one with it in the given source array.
Takes an item
and replaces the last with it in the given source
array.
Takes an end
and applies a slice
to source
array from the start of the
source
to the given end
.
Check if given entity
is an instance of BigInt
.
Check if given entity
is an instance of Boolean
.
Check if given entity
is an instance of Date
.
Check if given entity
is an instance of Function
.
Check if entity
is an instance of Number
.
Check if entity
is an instance of RegExp
.
Check if entity
is an instance of String
.
Check if entity
is an instance of Symbol
.
Check if given entity
is an instance of undefined
.
Parses a number to a decimal string.
Parses a number to a hexadecimal string.
Parses a string to a decimal value.
Parses a string to a hexadecimal value.
Curried wrapper for Array.prototype.every
.
Type of items in source array.
Type of predicated items.
Function predicate to test every item.
Curried function with predicate
in context.
Takes a positive filterer
and applies it to given source
array.
Type of items in source array.
Type of filtered items.
Filterer function.
Curried function with filter
set in context.
Takes a negative filterer
and applies it to given source
array.
Type of items in source array.
Type of filtered items.
Filterer out function.
Curried function with filter
set in context.
Takes a filterer
and applies it to a source
array returning a
[matching, nonMatching]
tuple.
Type of items in source array.
Type of filtered items.
Filterer function.
Curried function with filter
in context.
Curried wrapper for Array.prototype.flat
.
Recursion depth type.
The maximum recursion depth.
Curried function with depth
in context.
Given an ArrayLike
or Iterable
, return an array.
Type of items in source array.
Source value (must be an ArrayLike
or Iterable
).
Frozen array made with given ArrayLike
or Iterable
.
Takes grouper
and applies it to given source
array.
Type of items in source array.
Grouper function.
Curried function with grouper
in context.
Takes an index
and an item
and makes a copy of given source
array with
that new item
in the given index
.
Index to insert item.
Curried function with item
in context.
Curried wrapper for Array.prototype.join
.
Value separator.
Curried function with separator
in context.
Takes a mapper
function and applies it to given source
array.
Type of the items in the source array.
Type of the output (same as the input by default).
Mapper function function.
Curried function with mapper
in context.
Takes a reducer
and an initialValue
and applies it to source
array.
Type of the items in the source array.
Type of the output (an array of Input
by default).
Curried function with reducer
in context.
Takes an index
and an item
and replaces the source
array item in that
index
with the taken item
.
Index to start replace item.
Curried function with item
in context.
Takes a source
array and reverse the order of its items.
Type of the items in the source array.
Source array to be reversed.
Copy of source with values in reversed order.
Takes a start
and end
and applies a slice
to source
array from given
start
to given end
.
Slice start.
Curried function with start
in context.
Takes a start
and applies a slice
to source
array from given start
to the end of the source
.
Slice start.
Curried function with start
in context.
Curried wrapper for Array.prototype.some
.
Type of items in source array.
Type of predicated items.
Function predicate to test until some item of the type.
Curried function with predicate
in context.
Takes a sorter
function and applies it to given source
array.
Type of the items in the source array.
Sorter function function.
Curried function with sorter
in context.
Takes a addend1
and addend2
and returns the addition of those values.
Second addend DecimalTuple
of the addition.
Curried function with addend1
set in context.
Takes a divisor
and dividend
and returns the division of those values.
Curried function with divisor
set in context.
Takes a multiplier
and multiplicand
and returns the multiplication result
of those factors.
Curried function with multiplier
set in context.
Takes a subtrahend
and minuend
and returns the subtraction of those
values.
Curried function with subtrahend
set in context.
Takes a source
DecimalTuple [coefficient, exponent] and returns a number.
Number generated from the source coefficient and exponent.
Given and expected
value and an actual
value, returns true
if those
values are deeply equal, or false
if not.
Expected value to compare.
Given a compare
function, an expected
value and an actual
value,
returns true
if those values are equal based on the compare
output,
or false
if not.
Comparison function.
Given and expected
value and an actual
value, returns true
if those
values are dates and equal, or false
if not.
Expected value to compare.
Given a compare
function, an expected
value and an actual
value,
returns true
if those values are equal based on the compare
output,
or false
if not.
Comparison function.
Given and expected
value and an actual
value, returns true
if those
values are regular expressions and equal, or false
if not.
Expected value to compare.
Given and expected
value and an actual
value, returns true
if those
values are equal, or false
if not.
Expected value to compare.
Takes a source
function and returns a copy with negated output.
Argument type of the given function
Source function which output will be negated.
Source function with negated output.
Takes a constructor
and checks if given entity
is an instance of it.
Expected type.
Constructor used to check.
Curried function with constructor
in context.
Check if given entity
is an instance of Array
.
Actual type of the given entity.
Type of items in given entity.
Entity to check.
Check if given entity
is falsy (0, NaN, "", false, or nullish).
Actual type of the given entity.
Entity to check.
Check if entity
is null
.
Actual type of the entity.
Entity to check.
Check if entity
is undefined
or null
.
Actual type of the entity.
Entity to check.
Check if entity
is an instance of Object
(null
is omitted).
Actual type of the entity.
Entity to check.
Check if entity
value is an instance of Promise
.
Value of the promise.
Actual type of the entity.
Entity to check.
Check if given entity
is truthy (so not 0, NaN, "", false, or nullish).
Actual type of the given entity.
Entity to check.
Takes a type
string and checks if given entity
is of that typeof
.
Expected type.
Type to check (from typeof
).
Curried function with type
in context.
Takes a JSON string and parses it safely using a Promise.
Expected type if the parse is successful.
String value to parse.
Promise which resolves to an object of type Output
.
Takes an object and stringify to JSON safely using a Promise.
Type of source object.
Source object.
Promise which resolves to a string or rejects with errors.
Takes a addend1
and addend2
and returns the precise addition of those
values (uses DecimalTuple
internally).
Second addend of the addition.
Curried function with addend1
set in context.
Takes a minimum
and maximum
and returns a boolean if source
number
is between them.
Minimum boundary.
Curried function with minimum
set in context.
Takes a minimum
and maximum
and applies them to a given source
number.
Minimum boundary.
Curried function with minimum
set in context.
Takes a divisor
and dividend
and returns the precise division of those
values (uses DecimalTuple
internally).
Divisor of the division.
Curried function with divisor
set in context.
Takes a source
float number and returns a DecimalTuple
.
Source number to be parsed into a DecimalTuple.
DecimalTuple [coefficient, exponent].
Takes a multiplier
and multiplicand
and returns the precise
multiplication of those factors (uses DecimalTuple
internally).
Multiplier of the multiplication.
Curried function with multiplier
set in context.
Takes a subtrahend
and minuend
and returns the precise subtraction of
those values (uses DecimalTuple
internally).
Subtrahend of the subtraction.
Curried function with subtrahend
set in context.
Takes a source
number and returns a DecimalTuple [coefficient, exponent].
Source number to be parsed into a DecimalTuple.
DecimalTuple [coefficient, exponent].
Wrapper of Number.prototype.toString
with mandatory radix.
A value between 2 and 36 that specifies the base of the number.
Curried function with radix
in context.
Takes a source
object and returns an entries array.
Source object type.
Source object.
Array of entries of the given source object.
Takes a source
entries array and returns an object.
Expected object type.
Source entries array.
Object resulting of given entries.
Get value of given property for given source object.
Type of the property.
Name of property.
Curried function with property
in context.
Takes a mapper
function and applies it to given source
object using
objectEntries
and objectFromEntries
.
Type of the input object.
Type of the output object.
Curried function with mapper
in context.
Set value of given property in given source object.
Type of the property.
Name of property.
Curried function with property
in context.
Takes StringReplaceMap
object and runs a replaceAll of given object keys
with it's values in the source
string.
Replace map for the string.
Curried function with replaceMap
in context.
Takes a regular expression and a string and returns a RegExpMatchArray
.
Curried function with regularExpression
in context.
Wrapper of parseInt
with mandatory radix.
A value between 2 and 36 that specifies the base of the number.
Curried function with radix
in context.
Takes a source string and returns that string reversed.
String to be reversed.
Reversed string.
Takes a regular expression and a string and returns true if it matches.
Curried function with regularExpression
in context.
Generated using TypeDoc
ArrayLike or Iterable alias.