-
Couldn't load subscription status.
- Fork 5
Description
Hi, first of all your package looks amazing as it is! Thank you for it.
My question is not a nitpick, but rather a curiosity. I'm looking to move away from https://github.com/dchester/jsonpath to something RFC 9535 compliant and without esprima in dependencies for better security.
I went to package.json to confirm esprima is nowhere to be found, but there was es-toolkit with which im not familiar and it was not any clearer from a two usages in the code https://github.com/search?q=repo%3Aashphy%2Fjsonpath-js+es-toolkit+language%3ATypeScript&type=code&l=TypeScript.
It seems like isEqual from es-toolkit does strict deep equality check. Which is essentially assert.deepStrictEqual from node:assert with only difference being that isEqual treats -0 and +0 as the same, while assert.deepStrictEqual thinks otherwise. I personally agree with node on this front.
`assert.deepStrictEqual` on `isEqual` examples
Examples copied from https://es-toolkit.slash.page/reference/predicate/isEqual.html
const assert = require("node:assert/strict");
// Example 1: Comparing Primitive Values
assert.deepStrictEqual(1, 1);
assert.deepStrictEqual("hello", "hello");
assert.deepStrictEqual(true, true);
assert.notDeepStrictEqual(1, 2);
assert.notDeepStrictEqual("hello", "world");
assert.notDeepStrictEqual(true, false);
// Example 2: Comparing Special Cases
assert.deepStrictEqual(NaN, NaN);
assert.notDeepStrictEqual(+0, -0); // the only difference between between assert.deepStrictEqual and es-toolkit.isEqual
// Example 3: Comparing Date Objects
const date1 = new Date('2020-01-01');
const date2 = new Date('2020-01-01');
assert.deepStrictEqual(date1, date2);
const date3 = new Date('2021-01-01');
assert.notDeepStrictEqual(date1, date3);
// Example 4: Comparing RegExp Objects
const regex1 = /hello/g;
const regex2 = /hello/g;
assert.deepStrictEqual(regex1, regex2);
const regex3 = /hello/i;
assert.notDeepStrictEqual(regex1, regex3);
// Example 5: Comparing Objects
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { a: 1, b: { c: 2 } };
assert.deepStrictEqual(obj1, obj2);
const obj3 = { a: 1, b: { c: 3 } };
assert.notDeepStrictEqual(obj1, obj3);
const obj4 = { a: 1, b: 2 };
const obj5 = { a: 1, c: 2 };
assert.notDeepStrictEqual(obj4, obj5);
// Example 6: Comparing Arrays
const arr1 = [1, 2, 3];
const arr2 = [1, 2, 3];
assert.deepStrictEqual(arr1, arr2);
const arr3 = [1, 2, 4];
assert.notDeepStrictEqual(arr1, arr3);
const arr4 = [1, 2];
assert.notDeepStrictEqual(arr1, arr4);What do you think of using node's 1st party node:assert module and deepStrictEqual method from it instead of 3rd party module for something which node has native support for? This will allow your package to go zero dependencies.
Potentially make an exception for difference in -0, +0 comparison.