UNPKG

ts-browser-helpers

Version:

A collection of utility classes, functions and decorators for javascript/typescript projects, for use in the browser.

51 lines 2.2 kB
/** * Primitive value compatible object interface. * * @category Primitive */ export interface PrimitiveValObject { clone(): this; equals(other: this | any): boolean; copy(other: this | any): void | this | any; _ui_isPrimitive?: boolean; _ui_primitiveClone?: false; _ui_primitiveCopy?: false; _ui_primitiveEquals?: false; } /** * Primitive value type. It can be a string, number, boolean, null, an object that implements the PrimitiveValObject interface, or an array of primitive values. * * note that arbitrary objects are not allowed, only arrays * * @category Primitive */ export type PrimitiveVal = string | number | boolean | null | PrimitiveValObject | PrimitiveVal[]; /** * Clones a primitive value or an object that implements the PrimitiveValObject interface. * @param a The primitive value to clone. * @returns A clone of the primitive value or the original value if it is not a primitive. * @category Primitive */ export declare function clonePrimitive<T extends PrimitiveVal>(a: T): T; /** * Checks if two primitive values are equal. * * @param a * @param b * @return true if the values are equal, false otherwise. * @category Primitive */ export declare function equalsPrimitive<T extends PrimitiveVal>(a: T, b: T): boolean; /** * Copies a primitive value or an object that implements the PrimitiveValObject interface. * If the target is an array, it will copy the values from the source array to the target array. * If the target is an object that implements the PrimitiveValObject interface, it will call the copy method on the target. * If the target is not an array or an object that implements the PrimitiveValObject interface, it will return a clone of the source value. * * @param a The target primitive value to copy to. * @param b The source primitive value to copy from. * @return The target primitive value after copying the source value to it, or a clone of the source value if the target is not an array or an object that implements the PrimitiveValObject interface. * @category Primitive */ export declare function copyPrimitive<T extends PrimitiveVal>(a: T, b: T): T; //# sourceMappingURL=primitive_value.d.ts.map