@ulisesgascon/is-different
A limited way to compare two values and return true if they are different
About
Simple and very opinionated wrapper to manage Boolean conversions
❤️ Awesome Features:
- Simple and easy to use 🔥
- Typescript support 💪
- Zero dependencies 🚀
- Easy to use and great test coverage ✅
Installation
npm install @ulisesgascon/is-different
Usage
Simple example
Importation
const { isDifferent } = require("@ulisesgascon/is-different");
import { isDifferent } from "@ulisesgascon/is-different";
usage
console.log(isDifferent([1, 2, 3], [1, 2])); // true
console.log(isDifferent("on", "off")); // true
console.log(isDifferent(true, false)); // true
console.log(isDifferent({ a: 1 }, { a: 2 })); // true
console.log(isDifferent(1, 2)); // true
console.log(isDifferent([1, 2], [1, 2])); // true
console.log(isDifferent("on", "on")); // true
console.log(isDifferent(true, true)); // true
console.log(isDifferent({ a: 1 }, { a: 1 })); // true
console.log(isDifferent(1, 1)); // true
Known limitations
This library is doing a transformation to JSON and comparing both strings, this will ignore non-valid JSON values like functions.
- BigInt type is not supported
- Functions type is not supported due JSON definition
isDifferentContent(
{
a: () => {
return true;
},
},
{
a: () => {
return false;
},
}
); // false
isDifferent(
() => {
return true;
},
() => {
return true;
}
); //false
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Ulises Gascón - Initial work- - @ulisesGascon
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- This project is under development, but you can help us to improve it! We ❤️ FOSS!