Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

any

Checks if the given object is present and it is not empty (contains at least one entry).

Type signature

<T>(xs?: GenericObject<T>) => boolean

Examples

any({ a: 1, b: 2, c: 3 });
// ⇒ true
any({ });
// ⇒ false
any(null);
// ⇒ false
any(undefined);
// ⇒ false

Questions

  • How to check if an object is not empty?
  • How to check if an object contains some values?
  • How to check if an object is not null or undefined?

apply

Applies the given parameters to the given dictionary of functions.

Type signature

<T>(fs: {
    [index: string]: (...xs: T[]) => T;
}) => (...xs: T[]) => GenericObject<T>

Examples

const lower = text => text.toLowerCase();
const upper = text => text.toUpperCase();

apply({ lower, upper })("TeSt");
// ⇒ { lower: "test", upper: "TEST" }

Questions

  • How to apply a value over an object of functions?

empty

Empty object.

Type signature

GenericObject<unknown>;
export default empty

Examples

empty;
// ⇒ {}

Questions

  • How to get an empty object?

entries

Lists key-value pairs (entries) present in the given object.

Type signature

ObjectEntries

Examples

entries({ a: 1, b: 2, c: 3 });
// ⇒ [["a", 1], ["b", 2], ["c", 3]]

Questions

  • How to get entries of an object?
  • How to get an array of key-value pairs of an object?

enumerable

Creates a 1 to 1 mapping of the given values as an object.

Type signature

(...xs: string[]) => object

Examples

enumerable('TEST', 'X', 'Y');
// ⇒ { TEST: 'TEST', X: 'X', Y: 'Y' }

Questions

  • How to create an object of the same keys and values?

equals

Checks if two objects are deeply equal.

Type signature

(a: unknown, b: unknown) => boolean;
export default equalsDeep

Examples

equals({ a: 1 }, { a: 1 });
// ⇒ true
equals({ b: [1, 2] }, { b: [1, 2] });
// ⇒ true

Questions

  • How to check if two objects are equal?
  • How to check deep object equality?

every

Test if every element passes the given predicate.

Type signature

<T>(f: (value: T, key: string, context: object) => boolean) => (xs: GenericObject<T>) => boolean

Examples

every(x => x >= 0)({ x: 5, y: 3, z: 0 });
// ⇒ true
every(x => x > 0)({ x: 5, y: 3, z: 0 });
// ⇒ false

Questions

  • How to check if every entry in an object passes a given predicate?

filter

Filters the given object with the given predicate.

Type signature

<T>(f: (value: T, key: string, context: object) => boolean) => (xs: GenericObject<T>) => GenericObject<T>

Examples

filter(x => x % 2 !== 0)({ a: 1, b: 2, c: 3 });
// ⇒ { a: 1, c: 3 }

Questions

  • How to filter an object?

find

Searches the given object by the given predicate and returns the found value or undefined.

Type signature

<T>(predicate: (value: T, key: string, context: object) => boolean) => (xs: GenericObject<T>) => T | undefined

Examples

find(({ x }) => x % 2 === 0)({ a: { x: 1 }, b: { x: 2 }, c: { x: 3 } });
// ⇒ { x: 2 }

Questions

  • How to find the value of an object by a predicate function?

findEntry

Searches the given object by the given predicate and returns the found entry or undefined.

Type signature

<T>(predicate: (value: T, key: string, context: GenericObject<T>) => boolean) => (xs: GenericObject<T>) => [string, T] | undefined

Examples

findEntry(({ x }) => x % 2 === 0)({ a: { x: 1 }, b: { x: 2 }, c: { x: 3 } });
// ⇒ ["b", { x: 2 }]

Questions

  • How to find an entry of an object by a predicate function?

findKey

Searches the given object by the given predicate and returns the found key or undefined.

Type signature

<T>(predicate: (value: T, key: string, context: object) => boolean) => (xs: GenericObject<T>) => string | undefined

Examples

findKey(({ x }) => x % 2 === 0)({ a: { x: 1 }, b: { x: 2 }, c: { x: 3 } });
// ⇒ "b"

Questions

  • How to find a key of an object by a predicate function?

first

Returns the first value in the given object. Follows the default object iteration order.

Type signature

<T>(xs: GenericObject<T>) => T | undefined

Examples

first({ a: 1, b: 2, c: 3 });
// ⇒ 1

Questions

  • How to get the first value of an object?

flatMapValues

Flat maps the values of the given object.

Type signature

<T, TResult>(f: (value: T, key: string, context: GenericObject<T>) => TResult[]) => (xs: GenericObject<T>) => TResult[]

Examples

flatMapValues(x => [x, x * 2])({ a: 1, b: 2, c: 3 });
// ⇒ [1, 2, 2, 4, 3, 6]

Questions

  • How to flat map an object?

fromEntries

Creates an object from an array of key-value pairs (entries).

Type signature

<T>(entries: [string, T][]) => Result<T>

Examples

fromEntries([["a", 1], ["b", 2], ["c", 3]]);
// ⇒ { a: 1, b: 2, c: 3 }

Questions

  • How to create an object from an array of key-value pairs?
  • How to create an object from an array of entries?

groupBy

Groups the given array of values by the given key selector.

Type signature

(selector: (x: unknown) => string) => (xs: unknown[]) => Result

Examples

groupBy(x => x % 2 == 0 ? "even" : "odd")([1, 2, 3, 4, 5, 6, 7]);
// ⇒ { even: [2, 4, 6], odd: [1, 3, 5, 7] }

Questions

  • How to group an array by a key function?

hasKey

Checks if the given key is present in the object.

Type signature

(key: string) => (xs?: unknown) => boolean

Examples

hasKey("c")({ a: 1, b: 2, c: 3 });
// ⇒ true

Questions

  • How to check if an object contains a given key?

last

Returns the last value in the given object. Follows the default object iteration order.

Type signature

<T>(xs: GenericObject<T>) => T | undefined

Examples

last({ a: 1, b: 2, c: 3 });
// ⇒ 3

Questions

  • How to get the last value of an object?

length

Returns the number of entries within the given object.

Type signature

<T>(xs: GenericObject<T>) => number

Examples

length({ a: 1, b: 2, c: 3 });
// ⇒ 3

Questions

  • How to check how many entries are in an object?

map

Maps the given object with the given function.

Type signature

<T, TResult>(f: (value: T, key: string, context: object) => TResult) => (xs: GenericObject<T>) => GenericObject<TResult>

Examples

map(x => x ** 2)({ a: 1, b: 2, c: 3 });
// ⇒ { a: 1, b: 4, c: 9 }

Questions

  • How to map an object?
  • How to transform an object?

mapEntries

Maps entries of the given object.

Type signature

<T, TResult>(f: (value: T, key: string, context: object) => TResult) => (xs: GenericObject<T>) => [string, TResult][]

Examples

mapEntries(x => x ** 2)({ a: 1, b: 2, c: 3 });
// ⇒ [["a", 1], ["b", 4], ["c", 9]]

Questions

  • How to map object entries?

mapKeys

Transforms the object keys with the given function.

Type signature

<T>(f: (value: T, key: string, context: object) => string) => (xs: GenericObject<T>) => GenericObject<T>

Examples

mapKeys((_, key) => key.toUpperCase())({ a: 1, b: 2, c: 3 });
// ⇒ { A: 1, B: 2, C: 3 }

Questions

  • How to map object keys?
  • How to transform object keys?

mapValues

Maps and returns an array of transformed object values.

Type signature

<T, TResult>(f: (value: T, key: string, context: object) => TResult) => (xs: GenericObject<T>) => TResult[]

Examples

mapValues(x => x ** 2)({ a: 1, b: 2, c: 3 });
// ⇒ [1, 4, 9]

Questions

  • How to map object values?

merge

Merges two objects deeply.

Type signature

(a: GenericObject, b: GenericObject) => GenericObject;
export default merge

Examples

merge({ a: 1, b: 3 }, {});
// ⇒ { a: 1, b: 3 }
merge({ a: 1, b: 3 }, { b: 7 });
// ⇒ { a: 1, b: 7 }
merge({ a: 1, b: 3 }, { b: { d: 8 } });
// ⇒ { a: 1, b: { d: 8 } }
merge({ a: 1, b: { c: 3 } }, { b: { d: 8 } });
// ⇒ { a: 1, b: { c: 3, d: 8 } }

Questions

  • How to merge two objects together?
  • How to deeply merge two objects?

none

Checks if the given object is empty.

Type signature

<T>(xs?: GenericObject<T>) => boolean

Examples

none({});
// ⇒ true
none(null);
// ⇒ true
none({ a: 1 });
// ⇒ false

Questions

  • How to check if an object is empty?
  • How to check if an object is null or undefined?

some

Test if any element passes the given predicate.

Type signature

<T>(f: (value: T, key: string, context: object) => boolean) => (xs: GenericObject<T>) => boolean

Examples

some(x => x >= 4)({ x: 5, y: 3, z: 0 });
// ⇒ true
some(x => x < 0)({ x: 5, y: 3, z: 0 });
// ⇒ false

Questions

  • How to check if any entry in an object passes a given predicate?

sort

Sorts the given object by a comparator.

Type signature

<T>(f: (a: T, b: T) => number) => (xs: GenericObject<T>) => GenericObject<T>

Examples

sort({ a: 3, b: 2, c: 3, d: -7, e: 13, f: 0, g: 8 });
// ⇒ {"d": -7,"f": 0,"b": 2,"a": 3,"c": 3,"g": 8,"e": 13}

Questions

  • How to sort an object?