import isPlainObject from './helpers/isPlainObject.js'; import type { AddEntries, DeepWiden, EntriesTuple, Entry, EntryToAdd, KeysParam, KeyTuple, KeyUnion, MergeArray, OmitKeys, PickKeys, SetToNever, TruthyObject, ValueTuple } from './helpers/utility-types.js'; import compare from './utils/compare.js'; import copy from './utils/copy.js'; import iterate from './utils/iterate.js'; /****************************************************************************** Types ******************************************************************************/ type CollapseType = { -readonly [K in keyof T]: T[K]; } & {}; /****************************************************************************** Functions ******************************************************************************/ /** * Return a new object by excluding certains keys from an object. */ declare function omit>(obj: T, keys: K): CollapseType>; /** * Return a new object by selecting a specific set of keys on an object. */ declare function pick>(obj: T, keys: K): CollapseType>; /** * Merge two object together and return a new type. */ declare function merge(a: T, b: U): CollapseType & U>; /** * Merge an array of objects together */ declare function mergeArray(arr: A): CollapseType>; /** * Append a single entry to an object. */ declare function addEntry(obj: T, entry: [K, V]): CollapseType>; /** * Append a single entry to an object. */ declare function addEntries(obj: T, entries: E): CollapseType>>; /** * Append one object to another, modifying the reference to the original * object. */ declare function append(obj: T, addOn: U): asserts obj is CollapseType; /** * Remove keys from an object and set the type to 'never'. */ declare function remove>(obj: T, keys: K): asserts obj is CollapseType>>; /** * Get a value on an object and return 'undefined' if not found. */ declare function index(obj: T, key: string | number): T[keyof T] | undefined; /** * Get a value on an object and return 'undefined' if not found. */ declare function safeIndex(obj: T, key: string | number): T[keyof T]; /** * Get a list of keys for which the value matches. */ declare function reverseIndex(obj: T, value: unknown): (keyof T)[]; /** * Get a key for a value only if you know the value is unique. */ declare function safeReverseIndex(obj: T, value: unknown): keyof T; /** * Validator function to check */ declare function isKey(obj: T, arg: PropertyKey): arg is keyof T; /** * Validator function to check */ declare function isValue(obj: T, arg: unknown): arg is T[keyof T]; /** * Similar to `isPlainObject` but narrows a plain-object even further to * exclude symbols. Note that when numbers are added as keys to objects they * are converted to strings so we don't have to check for those. */ declare function isDict(arg: unknown): arg is Record; /** * Get a type-safe array of the object keys. */ declare function keys(obj: T): KeyTuple; /** * Get a type-safe array of the object values */ declare function values(obj: T): ValueTuple; /** * Get a type-safe array of the object entries */ declare function entries(obj: T): EntriesTuple; /** * Get a type-safe array of the object e */ declare function firstEntry(obj: T): Entry; /****************************************************************************** Export ******************************************************************************/ declare const _default: { readonly omit: typeof omit; readonly pick: typeof pick; readonly merge: typeof merge; readonly mergeArray: typeof mergeArray; readonly append: typeof append; readonly addEntry: typeof addEntry; readonly addEntries: typeof addEntries; readonly index: typeof index; readonly remove: typeof remove; readonly safeIndex: typeof safeIndex; readonly reverseIndex: typeof reverseIndex; readonly safeReverseIndex: typeof safeReverseIndex; readonly is: typeof isPlainObject; readonly isKey: typeof isKey; readonly isValue: typeof isValue; readonly keys: typeof keys; readonly values: typeof values; readonly entries: typeof entries; readonly firstEntry: typeof firstEntry; readonly iterate: typeof iterate; readonly copy: typeof copy; readonly compare: typeof compare; readonly isDict: typeof isDict; }; export default _default;