vars-equal
v1.0.1
Published
Compare two variables
Downloads
3
Readme
Description
Compare two variables
Installation
npm install vars-equal
Usage
CJS
const {varsEqual} = require("vars-equal");
ESM / Typescript
import {varsEqual} from "vars-equal";
Overview
varsEqual
Compare two inputs (Objects, Arrays, etc.)
varsEqual(15, "d"); // false
varsEqual([1, 2, 3],[1, 2, 3]); // true
varsEqual([1, 2, 3],[1, 3, 2]); // false
varsEqual({aa: 1, bb: 2, cc: 3}, {aa: 1, bb: 2, cc: 3}); // true
varsEqual({aa: 1, bb: 2, cc: 3}, {cc: 3, bb: 2, aa: 1}); // true
varsEqual({aa: 1, bb: 2, cc: 3}, {aa: 0, bb: 2, cc: 3}); // false
// true
varsEqual(
[{ff: 6, ee: [1, 2, 3, "ewe", "dfdf"], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}, {ff: 6, ee: [1, 2, 3, "ewe", "dfdf"], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}],
[{ff: 6, ee: [1, 2, 3, "ewe", "dfdf"], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}, {ff: 6, ee: [1, 2, 3, "ewe", "dfdf"], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}],
)
// true
varsEqual(
{ff: 6, ee: [1, 2, 3, "ewe",
[{ff: 6, ee: [1, 2, 3, "ewe", "dfdf"], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}, {ff: 6, ee: [1, 2, 3, "ewe", "dfdf"],
dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}]], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1},
{ff: 6, ee: [1, 2, 3, "ewe",
[{ff: 6, ee: [1, 2, 3, "ewe", "dfdf"], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}, {ff: 6, ee: [1, 2, 3, "ewe", "dfdf"],
dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1}]], dd: 4, cc: [1, 2, 3, "ewe", "dfdf"], bb: 2, aa: 1},
);
Package
📁 package
│
└───📁 cjs
│ │
│ └─📝 index.cjs ⇽ CJS version - Browser (2.3KiB unminified)
│
└───📁 esm
│
└─📝 index.mjs ⇽ ESM version - Browser (2.3KiB unminified)