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) => booleanParameters
| Parameter | Type | Description |
|---|---|---|
left | unknown | |
right | unknown |
Example
areSimilar({ foo: ['bar'] }, { foo: ['bar'] }) //=> truedeny ƒ
Negates the truthiness of a value.
function deny(value: unknown): booleanParameters
| Parameter | Type | Description |
|---|---|---|
value | unknown |
Example
deny(0) //=> trueequals ƒ
Checks strict equality between two values.
function equals(left: unknown, right: unknown): booleanParameters
| Parameter | Type | Description |
|---|---|---|
left | unknown | |
right | unknown |
Example
equals(2, 2) //=> truefst ƒ
Returns the first value in a pair.
function fst<A, B>(pair: readonly [A, B]): AParameters
| Parameter | Type | Description |
|---|---|---|
pair | readonly [A, B] |
Example
fst(['left', 'right']) //=> 'left'id ƒ
Returns the supplied value unchanged.
function id<T>(value: T): TParameters
| Parameter | Type | Description |
|---|---|---|
value | T |
Example
id('foo') //=> 'foo'not ƒ
Negates the truthiness of a value using the canonical Prelude name.
function not(value: unknown): booleanParameters
| Parameter | Type | Description |
|---|---|---|
value | unknown |
Example
not(true) //=> falseofType ƒ
Checks whether a value matches the supplied runtime type name.
function ofType(type: string, value: unknown): booleanParameters
| Parameter | Type | Description |
|---|---|---|
type | string | |
value | unknown |
Example
ofType('Array', []) //=> truereplicate ƒ
Builds a list of repeated copies of the supplied value.
function replicate<T>(n: number, value: T): T[]Parameters
| Parameter | Type | Description |
|---|---|---|
n | number | |
value | T |
Example
replicate(3, 'a') //=> ['a', 'a', 'a']snd ƒ
Returns the second value in a pair.
function snd<A, B>(pair: readonly [A, B]): BParameters
| Parameter | Type | Description |
|---|---|---|
pair | readonly [A, B] |
Example
snd(['left', 'right']) //=> 'right'typeOf ƒ
Returns the internal JavaScript type tag for a value.
function typeOf(value: unknown): stringParameters
| Parameter | Type | Description |
|---|---|---|
value | unknown |
Example
typeOf([]) //=> 'Array'