All Projects → azu → shallow-equal-object

azu / shallow-equal-object

Licence: MIT license
Shallow equal check object that support TypeScript.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to shallow-equal-object

website-checks
check your website for issues with multiple tools and get PDF reports of the results
Stars: ✭ 69 (+228.57%)
Mutual labels:  check
AMChoice
Radio Button and check box for iOS
Stars: ✭ 45 (+114.29%)
Mutual labels:  check
private-ip
Check if IP address is private.
Stars: ✭ 26 (+23.81%)
Mutual labels:  check
system-checks
⚙ Checks and shows Linux system info - Distro name, IP, running processes and etc. Official site - system-checks.org
Stars: ✭ 35 (+66.67%)
Mutual labels:  check
python-valid8
Yet another validation lib ;). Provides tools for general-purpose variable validation, function inputs/outputs validation as well as class fields validation. All entry points raise consistent ValidationError including all contextual details, with dynamic inheritance of ValueError/TypeError as appropriate.
Stars: ✭ 24 (+14.29%)
Mutual labels:  check
datatyping
Pythonic type checking
Stars: ✭ 37 (+76.19%)
Mutual labels:  check
Preconditions
Preconditions.NET provides convenience static methods to help check that a method or a constructor is invoked with proper parameter or not.
Stars: ✭ 17 (-19.05%)
Mutual labels:  check
nagitheus
Nagios Check towards Prometheus
Stars: ✭ 19 (-9.52%)
Mutual labels:  check
connection checker
Android library for checking the internet connectivity of a device.
Stars: ✭ 26 (+23.81%)
Mutual labels:  check
url-survival-check
批量检测URL存活
Stars: ✭ 44 (+109.52%)
Mutual labels:  check
nestjs-redis
Redis(ioredis) module for NestJS framework
Stars: ✭ 112 (+433.33%)
Mutual labels:  check
gramatika.app
Website of Gramatika check spelling and typo tools in Bahasa Indonesia
Stars: ✭ 72 (+242.86%)
Mutual labels:  check
react-native-appstore-version-checker
[Deprecated] A react native module to fetch the version of latest app from android playstore or apple app store
Stars: ✭ 88 (+319.05%)
Mutual labels:  check
metaschema
Schema definition and validation 💡
Stars: ✭ 25 (+19.05%)
Mutual labels:  check
has-value
Returns true if a value exists, false if empty. Works with deeply nested values using object paths.
Stars: ✭ 27 (+28.57%)
Mutual labels:  check
wrapcheck
A Go linter to check that errors from external packages are wrapped
Stars: ✭ 141 (+571.43%)
Mutual labels:  check
danetls
Program to test DANE enabled TLS Services
Stars: ✭ 18 (-14.29%)
Mutual labels:  check
diffido
Watch web pages for changes
Stars: ✭ 19 (-9.52%)
Mutual labels:  check
checkif.js
Javascript check library
Stars: ✭ 30 (+42.86%)
Mutual labels:  check
ultimateMICR-SDK
Bank check information extraction/OCR from Magnetic Ink Character Recognition [MICR] (E-13B & CMC-7) using deep learning
Stars: ✭ 42 (+100%)
Mutual labels:  check

shallow-equal-object Build Status

Shallow equality check for objects.

Feature

  • Custom equal function
  • Debug mode
    • Why it is not equal?

Install

Install with npm:

npm install shallow-equal-object

Usage

const { shallowEqual } = require("shallow-equal-object");
shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // => true
shallowEqual({ a: 1, b: 2 }, { a: 1, b: 42 }); // => false
shallowEqual({ a: 1, b: 2 }, { }); // => false

Options

You can pass option object as 3rd arguments.

customEqual: (a:any, b:any) => boolean

assert.ok(shallowEqual(base, { a: 1, b: 2 }, {
    customEqual: (a, b) => {
        return typeof a === "number" && typeof b === "number";
    }
}));
assert.equal(shallowEqual({ a: "string" }, { a: "string" }, {
    customEqual: (a, b) => {
        return typeof a === "number" && typeof b === "number";
    }
}), false);

debug: boolean

Enable debug mode if { debug: true }

Debug mode show helpful log that why that result is false.

it("objectA is not object", () => {
    shallowEqual(null, {}, {
        debug: true,
        console: consoleMock
    });
    assert.strictEqual(logCalls[0], "objectA is not object.");
});
it("objectB is not object", () => {
    shallowEqual({}, null, {
        debug: true,
        console: consoleMock
    });
    assert.strictEqual(logCalls[0], "objectB is not object.");
});
it("object key length is not same", () => {
    shallowEqual({}, { a: 1 }, {
        debug: true,
        console: consoleMock
    });
    assert.strictEqual(logCalls[0], "object key length is not same");
});
it("object value is not equal", () => {
    shallowEqual({ a: 1 }, { a: 2 }, {
        debug: true,
        console: consoleMock
    });
    assert.strictEqual(logCalls[0], "key:a is not equals between A and B.");
});

You can pass console object to { debug: true, console: ConsoleAPI }

Related

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].