UNPKG

@freeword/meta

Version:

Meta package for Freeword: exports all core types, constants, and utilities from the src/ directory.

99 lines 5.33 kB
type Fieldname = string; type Bag<VT> = Record<string, VT>; type AnyBag = Bag<any>; /** Assign a **non-enumerable**, writable, configurable property to an object * See also {@link setNormalProp} and {@link decorate} * @param obj - The object to decorate * @param key - The key to decorate the object with * @param value - The value to decorate the object with * @returns The value */ export declare function adorn<VT>(obj: object, key: string, value: VT): VT; /** Assign an enumerable, writable, configurable property to an object * See also {@link adorn} and {@link decorate} * @param obj - The object to decorate * @param key - The key to decorate the object with * @param value - The value to decorate the object with * @returns The value */ export declare function setNormalProp<VT>(obj: object, key: string, value: VT): VT; export declare function setNormalProps<OT extends Record<string, any>, VT extends Record<string, any>>(obj: OT, vals: VT): OT & VT; export declare function setHiddenProps<OT extends Record<string, any>, VT extends Record<string, any>>(obj: OT, vals: VT): OT & VT; /** Assign non-enumerable, writable, configurable properties to an object * See also {@link adorn} and {@link decorate} * @param obj - The object to decorate * @param vals - The values to decorate the object with * @returns The decorated object */ export declare function decorate<OT extends Record<string, any>, VT extends Record<string, any>>(obj: OT, vals: VT): OT & VT; /** Get the own properties of an object * * @param obj - The object to get the own properties of * @returns The own properties of the object; empty object if nil */ export declare function ownProps(obj: object | null | undefined): Bag<TypedPropertyDescriptor<any>>; /** Get the own property names of an object * * @param obj - The object to get the own property names of * @returns The own property names of the object; empty array if nil */ export declare function ownPropnames(obj: object | null | undefined): string[]; /** Get the property names of the **first parent prototype** of an object * * @param obj - The object to get the prototype property names of * @returns The prototype property names of the object; empty array if nil */ export declare function protoPropnames(obj: object | null | undefined): string[]; /** Get the property descriptor of a property of the **first parent prototype** of an object * * @param obj - The object to get the property descriptor of * @param propname - The name of the property to get the descriptor of * @returns The property descriptor of the property; undefined if not found */ export declare function protoProp<VT>(obj: object, propname: Fieldname): TypedPropertyDescriptor<VT> | undefined; /** Get the property descriptor of a property of an object * * @param obj - The object to get the property descriptor of * @param propname - The name of the property to get the descriptor of * @returns The property descriptor of the property; undefined if not found */ export declare function ownProp<VT>(obj: object, propname: Fieldname): TypedPropertyDescriptor<VT> | undefined; /** Get the first property descriptor found ascending the prototype chain * for a given property name * * @param obj - The object to get the property descriptor of * @param propname - The name of the property to get the descriptor of * @param depth - The depth of the prototype chain to search * @returns The property descriptor of the property; undefined if not found */ export declare function getProp<VT>(obj: object, propname: Fieldname, depth?: number): TypedPropertyDescriptor<VT> | undefined; export declare function bagsize(bag: AnyBag | any[]): number; export declare function scrubNil<VT>(vals: (VT | undefined)[]): NonNullable<VT>[]; export declare function scrubNil<VT>(vals: VT): { [KT in keyof VT]: NonNullable<VT[KT]>; }; export declare function scrubVoid<VT>(vals: (VT | undefined)[]): NonNullable<VT>[]; export declare function scrubVoid<VT>(vals: VT): { [KT in keyof VT]: NonNullable<VT[KT]>; }; /** Returns `true` for null, undefined, empty string, {}, and [], empty map, empty set, empty buffer. Returns **`false`** for zero 0, false, and NaN * Boolean and Number values are never void: `false`, `0`, `-0`, `+-` and `Nan` are all non-void, * @param obj - The object to check * @returns true if the object is void, false otherwise */ export declare function isVoid(obj: any): boolean; /** Returns `true` for null, undefined, empty string. * Returns **`false`** for everything else -- * meaning zero 0, false, NaN, +0, -0, {}, [], * and other empty values are non-blank * @param obj - The object to check * @returns true if the object is blank, false otherwise */ export declare function isBlank(obj: any): boolean; export declare function arrayish(arr: any): boolean; export declare function isAnyIterable(obj: any): boolean; export declare function baggish<RT extends AnyBag>(obj: any): obj is RT; export declare function objectish<RT extends AnyBag | Map<any, any>>(obj: any): obj is RT; export declare function arrayOrBag(objOrArr: any): boolean; export {}; //# sourceMappingURL=PropUtils.d.ts.map