import type CamelizeFn from "./Camelize"; import type FromEntriesFn from "./FromEntries"; import type GetFn from "./Get"; import type MapValuesFn from "./MapValues"; import type MergeFn from "./Merge"; import type MergeRFn from "./MergeR"; import type OmitFn from "./Omit"; import type OmitByFn from "./OmitBy"; import type OmitWFn from "./OmitW"; import type PickFn from "./Pick"; import type SimpleMergeFn from "./SimpleMerge"; import type SimpleMergeRFn from "./SimpleMergeR"; import type SnakeizeFn from "./Snakeize"; import type SpreadFn from "./Spread"; import type TryGetFn from "./TryGet"; import type ValueOfFn from "./ValueOf"; import type { Fn1, PartialApply } from "../HKT"; import type { List } from "../List"; /*********** * Methods * ***********/ /** * Methods for `Obj`. */ export namespace Obj { /** * [Fn] Merge two objects together. Optional keys are considered. * * However, this can cause some performance issues and may break TS in rare cases, * so it is recommended to use {@link SimpleMerge} when you're sure that * the two objects have no optional properties. * * Sig: `(l: object, r: object) => object` * * @example * ```typescript * type A = { a: number; b?: string }; * type B = { a: boolean; c: string }; * type R = $; * // ^?: { a: boolean; b?: string; c: string } * ``` * * @see {@link SimpleMerge} */ export type Merge = MergeFn; /** * [Fn] The flipped version of {@link Merge}. * * Sig: `(r: object, l: object) => object` * * The `R` suffix (short for **R**ight or **R**everse) means that the arguments are flipped. * * @example * ```typescript * type A = { a: number; b?: string }; * type B = { a: boolean; c: string }; * type R = $; * // ^?: { a: boolean; b?: string; c: string } * ``` * * @see {@link Merge} */ export type MergeR = MergeRFn; /** * [Fn] Merge two objects together. Optional keys are considered. * * However, this can cause some performance issues and may break TS in rare cases, * so it is recommended to use {@link SimpleMergeWith} when you're sure that * the two objects have no optional properties. * * Sig: `(l: object) => object` * * @example * ```typescript * type A = { a: number; b?: string }; * type B = { a: boolean; c: string }; * type R = $, A>; * // ^?: { a: boolean; b?: string; c: string } * ``` * * @see {@link SimpleMergeWith} */ export type MergeWith = PartialApply; /** * [Fn] Simply merge two objects together without considering optional properties. * * It is recommended to use to optimize performance when you're sure that * the two objects have no optional properties, otherwise use {@link Merge}. * * Sig: `(l: object, r: object) => object` * * @example * ```typescript * type A = { a: number; b: string }; * type B = { a: boolean; c: string }; * type R = $; * // ^?: { a: boolean; b: string; c: string } * ``` * * @see {@link Merge} */ export type SimpleMerge = SimpleMergeFn; /** * [Fn] The flipped version of {@link SimpleMerge}. * * The `R` suffix (short for **R**ight or **R**everse) means that the arguments are flipped. * * Sig: `(r: object, l: object) => object` * * @example * ```typescript * type A = { a: number; b: string }; * type B = { a: boolean; c: string }; * type R = $; * // ^?: { a: boolean; b: string; c: string } * ``` */ export type SimpleMergeR = SimpleMergeRFn; /** * [Fn] Simply merge two objects together without considering optional properties. * * It is recommended to use to optimize performance when you're sure that * the two objects have no optional properties, otherwise use {@link MergeWith}. * * Sig: `(l: object) => object` * * @example * ```typescript * type A = { a: number; b: string }; * type B = { a: boolean; c: string }; * type R = $, A>; * // ^?: { a: boolean; b: string; c: string } * ``` * * @see {@link MergeWith} */ export type SimpleMergeWith = PartialApply; /** * [Fn] Spread a {@link List} of objects into one object. * * Sig: `(os: List) => object` */ export type Spread = SpreadFn; /** * [Fn] Omit properties from an object. * * Sig: `[k: K](o: { [P in K]: unknown }) => object` */ export type Omit = PartialApply; /** * [Fn] Less strict version of {@link Omit}.The **W** suffix (short for **W**idening) means that * the object type is widened to `object`. * * Sig: `[k: PropertyKey](o: object) => object` */ export type OmitW = PartialApply; /** * [Fn] Omit pairs from an object where the value satisfies the predicate. * * Sig: `[f: (x: T) => boolean](o: Record) => Record` */ export type OmitBy> = PartialApply; /** * Pick properties from an object. * * Sig: `[k: K](o: { [P in K]: unknown }) => object` */ export type Pick = PartialApply; /** * [Fn] Less strict version of {@link Pick}.The **W** suffix (short for **W**idening) means that * the object type is widened to `object`. * * Sig: `[k: PropertyKey](o: object) => object` */ export type PickW = PartialApply; export type ValueOf = ValueOfFn; export type Get = PartialApply; export type GetFrom = PartialApply; export type TryGet = PartialApply; export type TryGetFrom = PartialApply; /** * [Fn] Apply a function to each value in an object. * * Sig: `[f: (x: T => U)](o: Record) => Record` */ export type MapValues = PartialApply; export type Snakeize = SnakeizeFn; export type Camelize = CamelizeFn; } /****************** * Static members * ******************/ /** * [Fn] Convert a {@link List} (i.e., fixed-length tuple) of key-value pairs into an * object. * * Sig: `(entries: List) => Record` */ export type Obj$$FromEntries = FromEntriesFn;