npm

Need private packages and team management tools?Check out npm Orgs. »

@writetome51/arrays-match

1.0.6 • Public • Published

npm version NpmLicense npm

arraysMatch(array1, array2): boolean

If array1 and array2 match, returns true. Else, returns false.
It automatically handles checking nested arrays too. The only thing it
can't do is match arrays that contain objects.

Examples

arraysMatch([], []); // true

arraysMatch(['h', 'j'],  ['h', 'j']); // true

arraysMatch(['h', 'j'],  ['h', 'j', 'k']); // false

arraysMatch([1, 2, [3]], [1, 2, [3]]); // true

arraysMatch([1, 2, [3, [4]]], [1, 2, [3, [4]]]); // true

arraysMatch([1, 2, [3, [4, 5]]], [1, 2, [3, [4, 8]]]); // false

arraysMatch([ {prop:1} ], [ {prop:1} ]); // false

Installation

npm i @writetome51/arrays-match

Loading

// if using TypeScript:
import {arraysMatch} from '@writetome51/arraysMatch'; 
 // if using ES5 Javascript:
var arraysMatch = require('@writetome51/arraysMatch').arraysMatch;

install

npm i @writetome51/arrays-match

Downloadsweekly downloads

6

version

1.0.6

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability