Package Exports
- simple-comparator
- simple-comparator/dist_commonjs/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simple-comparator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
What is it?
The JS/TS utility to confirm deep equality of two simple objects, arrays or simple data type, to be used in Deno and Node.js.
The bahaviour match the toEqual() matcher function of the Jest library.
The orignal inspiration went from the issue in React.js application I had, where the useEffect triggered change to the global context of changed variable, but with same content.
Ready to be used in Deno and Node.js. To see more details how to use it, please check related unit tests in ./src/*.spec.ts and tests in ./tests folder.
Deno example
deno test https://raw.githubusercontent.com/dominikj111/simple-comparator/main/tests/deno.test.ts or
deno test https://raw.githubusercontent.com/dominikj111/simple-comparator/main/tests/deno.test.js
How to get it on Node.js or Bun
npm i simple-comparator, bun add simple-comparator
bun test doesn't work as expected with this library as there are Deno tests included and bun can't resolve the assert_equals module.
Problems to solve
As a develoer, I want:
- To deeply compare two objects, arrays or simple data type.
import { same, diff, compare } from "simple-comparator/index";
...
React.useEffect(() => {
if (diff(state.var_1, state.var_2)) {
// do some action
}
}, [ state.var_1, state.var_2 ]);
...Possible improvements when requested
🔲 Add bundling to import from CDN (vanilla js) -> umd, esm
🔲 Improve Continuous Integration (automatic build, linting and testing)
🔲 Add Changelog, Code of Conduct