/** * Defines a type for the property descriptors of an object. * * @since v1.5.8 */ type PropertyDescriptors = { [TProperty in keyof TObject]: TypedPropertyDescriptor; } & { [propertyKey: string]: PropertyDescriptor; }; /** * Defines an abstract class with object utilities. */ export declare abstract class Objects { /** * Contains an empty object. */ static readonly EMPTY: {}; /** * @constructor * * @private */ private constructor(); /** * Checks whether the specified objects deep equal. * * **Usage Examples:** * ```typescript * const o1 = {a: '55', b: 4, c: false}; * const o2 = {c: false, a: '55', b: 4}; * * console.log(Objects.deepEqual(o1, o2)); // true * ``` * * @param {Object} o1 Contains some object. * @param {Object} o2 Contains some other object. * @return {Boolean} whether the specified objects deep equal. * * **Note:** According to ES3 */ static deepEquals(o1: object, o2: object): boolean; /** * Gets the object entries. * * @param {Object} obj Contains some object. * @return {Iterator} the object entries as an array of key-value pair tuples. */ static entries(obj: T): Generator<(Extract | T[Extract])[], void, unknown>; /** * Checks whether the two specified objects strictly equal. * * **Usage Examples:** * ```typescript * const obj1 = { * a: 'string', * b: false, * c: 44, * }; * const obj2 = obj1; * console.log(Objects.equals(obj1, obj2)); // true * ``` * * @param {Object} a Contains some object. * @param {Object} b Contains some other object. * @return {Boolean} whether the two specified objects strictly equal. */ static equals(a: object, b: object): boolean; /** * Deserializes a JSON string i. e. parses it as an object. * * **Usage Examples:** * ```typescript * Objects.fromJson("{}"); // {} * Objects.fromJson('{"a":true}'); // {a: true} * Objects.fromJson('{"a":2,"b":"abc"}'); // {a: 2, b: "abc"} * ``` * * @param {String} json Contains some JSON string. * @return {T} a JavaScript value equivalent to the JSON string. * * @since v1.5.10 * * @see `JsonSerializer.deserialize()` */ static fromJson(json: string): T; /** * Gets the property descriptors of the specified object. * * @param {Object} obj Contains some object. * @return {PropertyDescriptors} the property descriptors of the specified * object. * * @since v1.5.8 */ static getPropertyDescriptors(obj: TObject): PropertyDescriptors; /** * Checks whether the given object has a property with the given name. * * @param {Object} obj Contains some object. * @param {String} key Contains some key. * @return {Boolean} whether the given object has a property with the * given key. */ static hasProperty(obj: T, key: string | number | symbol): key is keyof T; /** * Checks whether the given object is empty. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is empty. */ static isEmpty(obj: T | Record): obj is Record; /** * Checks whether the given object is empty. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is empty. */ static isEmpty(obj: T | Record): obj is Record; /** * Checks whether the given object is not empty. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is not empty. */ static isNotEmpty(obj: T): boolean; /** * Checks whether the given object is not empty. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is not empty. */ static isNotEmpty(obj: T): boolean; /** * Checks whether the given object is not null. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is not null. */ static isNotNull(obj?: T | null): obj is T; /** * Checks whether the given object is not null. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is not null. */ static isNotNull(obj?: T | null): obj is T; /** * Checks whether the given object is null. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is null. */ static isNull(obj?: T | null): obj is null; /** * Checks whether the given object is null. * * @param {Object} obj Contains some object. * @return {Boolean} whether the given object is null. */ static isNull(obj?: T | null): obj is null; /** * Checks whether the given value is an object. * * @param {*} value Contains some value. * @return {Boolean} whether the given value is an object. */ static isObject(value?: any): value is object; /** * Checks whether the specified value is a plain object. * * @param {*} value Contains some value. * @return {Boolean} whether the specified value is a plain object. * * @since v1.5.6 */ static isPlainObject(value?: any): value is Record; /** * Omits the object properties with the given keys. * * @param {Object} obj Contains some object. * @param {Array} keys Contains the keys of the object properties to * be omitted. * @return {Object} a truncated object. */ static omit(obj: T, ...keys: Keys): { [P in Exclude]: T[P]; }; /** * Picks the properties of the given object with the given keys. * * @param {Object} obj Contains some object. * @param {Array} keys Contains the keys of the object properties * to be picked. * @return {Boolean} the truncated object. */ static pick(obj: T, ...keys: K[]): Pick; /** * Makes the specified object iterable. * * @param {Object} obj Contains some object. * @return {Object} an iterable object. */ static toIterable(obj: T): Iterable<[Omit, T[keyof T]]>; /** * Serializes the specified object i. e. converts it to a JSON string. * * **Usage Examples:** * ```typescript * Objects.toJson({}); // "{}" * Objects.toJson({a: true}); // "{"a":true}" * Objects.toJson({a: 2, b: "abc"}); // "{"a":2,"b":"abc"}" * ``` * * @param {Object} obj Contains some object. * @return {String} the JSON string. * * @since v1.5.10 * * @see `JsonSerializer.serialize()` */ static toJson(obj?: TObject): string; /** * Converts an object to a map. * * @param {Object} obj Contains some object. * @return {Map} a map whose keys are the object property keys and * values are their values. */ static toMap(obj: T): Map; /** * Converts an object to a set. * * @param {Object} obj Contains some object. * @return {Set} a set composed of the object values. */ static toSet(obj: T): Set; /** * Gets the string representation of the specified object. * * **Usage Examples:** * ```typescript * Objects.toString(); // "[object Undefined]" * Objects.toString({}); // "[object Object]" * Objects.toString(["a"]); // "[object Array]" * Objects.toString(12345); // "[object Number]" * ``` * * @param {*} obj Contains some object. * @return {String} the string representation of the specified object. * * @since v1.5.8 */ static toString(obj?: any): string; } export type { PropertyDescriptors };