prelude-js logoprelude-js

preludejs/General API

Complete API reference for preludejs/General

preludejs/General API Reference

Core

areSimilar ƒ

Performs a deep similarity check across arrays, objects, functions, and primitive values. Curried, so it can be partially applied.

function areSimilar(left: unknown, right: unknown): boolean
function areSimilar(left: unknown): (right: unknown) => boolean

Parameters

ParameterTypeDescription
leftunknown
rightunknown

Example

areSimilar({ foo: ['bar'] }, { foo: ['bar'] }) //=> true

deny ƒ

Negates the truthiness of a value.

function deny(value: unknown): boolean

Parameters

ParameterTypeDescription
valueunknown

Example

deny(0) //=> true

equals ƒ

Checks strict equality between two values.

function equals(left: unknown, right: unknown): boolean

Parameters

ParameterTypeDescription
leftunknown
rightunknown

Example

equals(2, 2) //=> true

fst ƒ

Returns the first value in a pair.

function fst<A, B>(pair: readonly [A, B]): A

Parameters

ParameterTypeDescription
pairreadonly [A, B]

Example

fst(['left', 'right']) //=> 'left'

id ƒ

Returns the supplied value unchanged.

function id<T>(value: T): T

Parameters

ParameterTypeDescription
valueT

Example

id('foo') //=> 'foo'

not ƒ

Negates the truthiness of a value using the canonical Prelude name.

function not(value: unknown): boolean

Parameters

ParameterTypeDescription
valueunknown

Example

not(true) //=> false

ofType ƒ

Checks whether a value matches the supplied runtime type name.

function ofType(type: string, value: unknown): boolean

Parameters

ParameterTypeDescription
typestring
valueunknown

Example

ofType('Array', []) //=> true

replicate ƒ

Builds a list of repeated copies of the supplied value.

function replicate<T>(n: number, value: T): T[]

Parameters

ParameterTypeDescription
nnumber
valueT

Example

replicate(3, 'a') //=> ['a', 'a', 'a']

snd ƒ

Returns the second value in a pair.

function snd<A, B>(pair: readonly [A, B]): B

Parameters

ParameterTypeDescription
pairreadonly [A, B]

Example

snd(['left', 'right']) //=> 'right'

typeOf ƒ

Returns the internal JavaScript type tag for a value.

function typeOf(value: unknown): string

Parameters

ParameterTypeDescription
valueunknown

Example

typeOf([]) //=> 'Array'

On this page