-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lodash Dependency #52
Comments
One reason to not use Lodash: its heavy use of CommonJS/Node style modules means no compiling to ES6 modules from TS. json-type-validation/src/decoder.ts Line 2 in 60576fe
|
Also I was unable to use json-type-validation library in Stencil project due Cannot Use External Module due to a call to |
``At my work we heavily relied on this dependency but since we started using svelte we had troubles with lodash.isequal and how its built. So I forked this repo here and made the change that you suggested. It solves our problem and your function works great. Except for when So modified the function slightly: function isEqual(a: any, b: any) {
if (a === b) {
return true;
}
if (a === null && b === null) {
return true;
}
if (typeof (a) !== typeof (b)) {
return false;
}
if (typeof (a) === 'object') {
// new if that fixes that bug
if (a === null && b !== null || a !== null && b === null) {
return false;
}
// Array
if (Array.isArray(a)) {
if (!Array.isArray(b)) {
return false;
}
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!isEqual(a[i], b[i])) {
return false;
}
}
return true;
}
// Hash table
const keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) {
return false;
}
for (let i = 0; i < keys.length; i++) {
if (!b.hasOwnProperty(keys[i])) {
return false;
}
if (!isEqual(a[keys[i]], b[keys[i]])) {
return false;
}
}
return true;
}
} |
May I suggest removing Lodash as a dependency?
The single call to the Lodash
isEqual
function could be probably replaced with a simple local implemention:The text was updated successfully, but these errors were encountered: