/** * Object utilities. Use this module by importing from `@sirpepe/shed/object`. */ import type { QueryPath } from "./types"; /** * Returns an unusable object that throws when accessed in any way. */ export declare function trap(message: string | ((trap: keyof ProxyHandler) => string), ErrorConstructor?: new (reason?: string, cause?: Error) => Error): T; /** * Returns a new object created from the input object, but without the keys in * `toOmit`. Essentially the runtime-variant of TypeScript's `Omit` type * and the inverse of `picked()`. */ export declare function omitted, K extends keyof T>(obj: T, ...toOmit: K[]): Omit; /** * Returns a function that returns a new object created from its input object, * but without the keys in `toOmit`. Essentially a factory function for * functions that call `omitted()`. */ export declare function omitter, K extends keyof T>(...toOmit: K[]): (obj: T) => Omit; /** * Returns a new object created from the input object, but with only the keys in * `toKeep`. Essentially the runtime-variant of TypeScript's `Pick` type * and the inverse of `omitted()`. */ export declare function picked, K extends keyof T>(obj: T, ...toKeep: K[]): Pick; /** * Returns a function that returns a new object created from its input object, * but with only the keys in `toKeep`. Essentially a factory function for * functions that call `picked()`. */ export declare function picker, K extends keyof T>(...toKeep: K[]): (obj: T) => Pick; /** * Returns a predicate that checks if its input object's "prop" field contains a * value equal to "value". */ export declare function where(prop: K, value: T[K]): (obj: T) => boolean; /** * Returns a predicate that checks if its input object's "prop" field contains a * value not equal to "value". */ export declare function whereNot(prop: K, value: T[K]): (obj: T) => boolean; /** * Returns a getter function that returns every object's "prop" value. */ export declare function select(prop: K): (obj: T) => T[K]; export declare function hasPath(obj: T, path: "."): true; export declare function hasPath(obj: object, path: string): boolean; export declare function getPath(obj: T, path: "."): T; export declare function getPath(obj: T, path: P): QueryPath; export declare function setPath(obj: T, path: ".", value: T): void; export declare function setPath(obj: T, path: P, val: QueryPath): void;