A few utility functions for JavaScript/TypeScript objects and arrays, with no external dependencies.
npm install @ahouse/object-utilites
Check if two arrays have the same values.
import { arraysAreEqual } from '@ahouse/object-utilities';
const a = [4, 'test', {x: ''}];
const a2 = [4, 'test', {x: ''}];
const b = [4, 'test', {x: 'test'}];
const c = [4, 'test', {y: ''}];
const d = [4, 'test', {x: '', y: ''}];
arraysAreEqual(a, a); // true
arraysAreEqual(a, a2); // true
arraysAreEqual(a, b); // false
arraysAreEqual(a, c); // false
arraysAreEqual(a, d); // false
Converts an array into an object that has the same values, where the key is one of the value's properties instead of an index.
Deep copy an object (i.e. recursively copy inner objects as well).
Merge an object (or several) with another object, into a new object, recursively.
Flatten multi-level objects.
Check if a variable is an object, but not an array (unlike typeof x === 'object').
Checks if two arrays have the same values.
Merge an object (or several) into another object, recursively.
See contributing.md
.