0.3.1 • Published 4 years ago

jeck v0.3.1

Weekly downloads
23
License
MIT
Repository
github
Last release
4 years ago

Jeck

It's a small, fast utility to compare string, boolean, number, array, objects (including deep nested), null and undefined.

Installation

Jeck works in both node.js and browser environments. For node, install with npm:

npm i jeck

To use in browser, grab the jeck.umd.js file and add it to your page:

<script src="https://unpkg.com/jeck/dist/jeck.umd.js"></script>

Available in ESM, CJS and UMD formats.

Usage

These examples assume you're in node.js, or something similar:

const jeck = require("jeck");

// Primitive values
jeck(42, 17); // false
jeck(["orange", "apple", "ananas"], ["mango"]); // false
jeck(null, null); // true
jeck(undefined, undefined); // true

// Without array order tolerancy
jeck(["mango", true, 42], [42, "mango", true]); // false
// With array order tolerancy
jeck(["mango", true, 42], [42, "mango", true], { orderTolerant: true }); // true

// Object with nested structure
const deepA = {
  a: { lot: { of: { nested: { levels: { in: { this: "object" } } } } } }
};
const deepB = {
  a: { lot: { of: { nested: { levels: { in: { this: { object: true } } } } } } }
};
jeck(deepA, deepB); // false

// Array with nested structures
const arrayA = [{ type: "shadow" }, { type: "grass", isStrong: true }];
const arrayB = [{ type: "fire" }, { type: "water", isWeak: false }];

jeck(arrayA, arrayB); // false

Checkout more examples in: __tests__/jeck.js

License

MIT

0.3.1

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago