UNPKG

@playcanvas/observer

Version:

Generic implementation of the observer pattern

34 lines (33 loc) 1.28 kB
/** * Determines whether two arrays are deeply equal. Two arrays are considered equal if they have the * same length and corresponding elements are equal. This function also supports nested arrays, * comparing them recursively. * * @param a - The first array to compare. * @param b - The second array to compare. * @returns Returns `true` if the arrays are deeply equal, otherwise `false`. * * @example * arrayEquals([1, 2, 3], [1, 2, 3]); // true * arrayEquals([1, 2, 3], [3, 2, 1]); // false * arrayEquals([1, [2, 3]], [1, [2, 3]]); // true * arrayEquals([1, [2, 3]], [1, [3, 2]]); // false * arrayEquals([1, 2, 3], null); // false * arrayEquals(null, null); // false */ declare const arrayEquals: (a: any[], b: any[]) => boolean; /** * Creates a deep copy of an array, recursively copying any nested arrays. * Non-array objects within the array are not deep copied (they remain references). * * @param arr - The array to copy. * @returns A deep copy of the array with all nested arrays also copied. * * @example * const original = [[1, 2], [3, 4]]; * const copy = deepCopyArray(original); * copy[0][0] = 99; * console.log(original[0][0]); // 1 (unchanged) */ declare const deepCopyArray: (arr: any[]) => any[]; export { arrayEquals, deepCopyArray };