jsm-utilities
Version:
A utilities library.
36 lines (35 loc) • 1.58 kB
TypeScript
import deepmerge from "deepmerge";
import { Assign, DeepRequired, Diff } from 'utility-types';
/**
* Merges two objects, with properties from the second object taking precedence over the first object.
* If a property is found on both objects, the property from the first object is returned.
* @param x - The first object to merge.
* @param y - The second object to merge.
* @param options - The options for merging.
* @returns The merged object.
*/
export declare const defaults: <T extends object, Y extends object = Partial<T>>(x: T, y: Y, options?: deepmerge.Options) => Assign<Diff<T, Y>, DeepRequired<Y>>;
/**
* Gets the item IDs from the new and old data.
* @param new_value - The new value.
* @param old_value - The old value.
* @returns The item IDs.
*/
export declare const getItemIdsFromOldAndNewData: <T extends string | string[] | null>(new_value?: T, old_value?: T) => T;
/**
* Checks if the current environment is development.
* @returns A boolean indicating if the current environment is development.
*/
export declare const isDevelopmentDev: () => boolean;
/**
* Checks if the current environment is production.
* @returns A boolean indicating if the current environment is production.
*/
export declare const isProductionDev: () => boolean;
/**
* Merges two objects deeply, excluding properties with null or undefined values.
* @param x - The first object to merge.
* @param y - The second object to merge.
* @returns The merged object.
*/
export declare function deepMergeUnlessNull<X extends object, Y extends object>(x: X, y: Y): X & Y;