vars-equal
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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)



Readme

Keywords

none

Package Sidebar

Install

npm i vars-equal

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

9.59 kB

Total Files

6

Last publish

Collaborators

  • thimpat