npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

params-equal

v1.1.0

Published

Checks if two elements are really equal

Downloads

9

Readme

params-equal NPM version

Is function() {} = function() {}? Or {} = {}? "hello" = new String("hello")? Now they are. params-equal checks if two given parameters are equal and works for cases, other programs do not check. Optimalised to be as fast as it is possible and tested to work as intended.

Install

Install with npm:

$ npm install --save params-equal
import paramsEqual from 'params-equal';
or
const paramsEqual = require('params-equal').default;

paramsEqual(NaN, NaN) //=> true

paramsEqual(NaN, 0 / 0) //=> true

paramsEqual(null, null) //=> true

paramsEqual(true, true) //=> true

paramsEqual(true, false) //=> false

paramsEqual("", "") //=> true

paramsEqual("", "hi") //=> false

paramsEqual(2, 2) //=> true

paramsEqual(2, 4) //=> false

paramsEqual(2, "4") //=> false

paramsEqual(-0, +0) // => false

paramsEqual(Infinity, Infinity) // => true

paramsEqual(Infinity, 1 / 0) // => true

paramsEqual(-0, -0)) // => true

paramsEqual(/a/g, /a/g) //=> true

paramsEqual(/a/g, /a/u) //=> false

paramsEqual(/b/g, /a/g) //=> false

paramsEqual(/a/g, new RegExp('a', 'g')) //=> true

paramsEqual(Symbol(12), Symbol(12)) //=> true

paramsEqual(Symbol(12), Symbol("12")) //=> true

paramsEqual(Symbol(12), Symbol(6)) //=> false

paramsEqual(new Boolean(true), new Boolean(true)) //=> true

paramsEqual(new Boolean(true), new Boolean(false)) //=> false

paramsEqual(new Object(), new Object()) //=> true

paramsEqual([], []) //=> true

paramsEqual([1], []) //=> false

paramsEqual({}, []) //=> false

paramsEqual(function() {}, function() {}) //=> true

paramsEqual(function hi() {}, function() {}) //=> false

paramsEqual(() => {}, function() {}) //=> false

paramsEqual(function() {}, function() {return false; }) //=> false

paramsEqual(async function() {}, function() {}) //=> false

paramsEqual(new Date(), new Date(1256252)) //=> false

paramsEqual({ hi: { hello: 1 } }, { hi: { hello: "1" } }) //=> false

paramsEqual([{ hi: "hello" }, "hi"], [{ hi: "hello" }, "hi"]) //=> true

paramsEqual({
  log: [],
  set yo(name: string) {
    this.log.push(name);
  },
  get yo() {
    return "this is set";
  }
},
{
  log: [],
  get yo() {
    return "this is set";
  }
}) //=> false

paramsEqual({
  log: [],
  yo: "this is set"
},
{
  log: [],
  get yo() {
    return "this is set";
  }
}) //=> false

paramsEqual({
  log: [],
  set yo(name: string) {
    this.log.push(name);
  },
  get yo() {
    return "this is set";
  }
},
{
  log: [],
  set yo(name: string) {
    this.log.push(name);
  },
  get yo() {
    return "this is set";
  }
}) //=> true

const a = { hi: "hello", s: {} };
const b = { hi: "hello", s: {} };
const c = { hi: "h", c: {} };

c.c = c;
a.s = a;
b.s = c;
paramsEqual(a, b) //=> RangeError("You are not allowed to create infinite nest")

Test

  • Unit tests:
$ npm install && npm test

Author

kmdrGroch

License

Copyright © 2018, kmdrGroch. Released under the MIT License.

Note

The code will work for node >= 8, although there is a possibility that development tools won't work for some versions.