1.0.0 • Published 5 years ago

thesmo-comparators v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Comparators

Summary

This package contains collection of comparators for objects and primitives.

API

API methods clarification

1. ObjectsByJointRootPrimitives

Signature

/* arguments object */
({ 
    firstOperand: object, 
    secondOperand: object
})
/* returns */
boolean

Usage example

const { ObjectsByJointRootPrimitives } = require("thesmo-comparators");

const obj1 = { a: 1, b: 2, c: 3 };
const obj2 = { b: 2 };
const obj3 = { a: 1, b: 2, c: 4 };
const obj4 = { g: 5, h: 6 };

// true
const obj1_obj1 = ObjectsByJointRootPrimitives(obj1, obj1);

// true
const obj1_obj2 = ObjectsByJointRootPrimitives(obj1, obj2);

// true
const obj2_obj3 = ObjectsByJointRootPrimitives(obj2, obj3);

// false (obj1.c !== obj3.c)
const obj1_obj3 = ObjectsByJointRootPrimitives(obj1, obj3);

// false (no joint fields were found)
const obj1_obj4 = ObjectsByJointRootPrimitives(obj1, obj4);

2. Primitives

Signature

/* arguments object */
({ 
    firstMember: any,
    secondMember: any
})
/* returns */
boolean

Usage example

const { Primitives } = require("thesmo-comparators");

const one = 1;
const anotherOne = 1;
const oneAsString = "1";

// true
const one_one = Primitives(one, one);

// true
const one_anotherOne = Primitives(one, anotherOne);

// false
const one_oneAsString = Primitives(one, oneAsString);
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago