1.0.6 • Published 4 years ago

compareme v1.0.6

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

compareme

Library to compare objects

  1. Install
npm install compareme
  1. Usage
import compareme from 'compareme';

compareme.is({a: 1}).like({a: 2}); // true
compareme.is({a: 1, b: 2}).deeply.like({a: 3}) // true
compareme.is({a: 1}).strictly.like({a: 2, b: 3}) // false
compareme.get([10]).strictly.and.deeply.difference.with(['Something']);
/*
{
    success: false,
    differences: [{
        index: '0',
        first: 'number',
        second: 'string',
    }],
}
*/
compareme.get({a: 1, b: {c: 2}}).unexpected.elements.strictly.and.deeply.with({a: 2, b: {d: 's'}});
/*
[{
    index: 'b.d',
    first: 'undefined',
    second: 'string',
}]

compareme.get({a: 1, b: {c: 2}}).missing.elements.strictly.and.deeply.with({a: 2, b: {d: 's'}});

compareme.get({a: 1, b: {c: 2}}).type.differences.strictly.and.deeply.with({a: 2, b: {c: 's'}});
*/
  1. Development
npm run dev

This watches files and compiles them

  1. Run tests
npm test

npm run dev should be running to watch and recompile files.

  1. List of methods
  • Start methods:

    • is(object): returns a boolean at the end of the chain.
    • get(object): returns an object with the boolean result of the chain and a list of differences.
  • Modifiers:

    • not: negates the condition.
    • deeply: checks first object deeply. Values in second object could not exist.
    • strictly: checks first object deeply and values must match. Second object could not have different values.
    • and
  • Finish methods:

    • like: compares the type of each pair of objects.
1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago