-
Notifications
You must be signed in to change notification settings - Fork 139
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
DSUtils.removeCircular is removing more stuff than it should #75
Comments
Here's the transpiled version of that function that I'm using which results in this: function removeCircular(object) {
var objects = [];
return (function rmCirc(value) {
var i = undefined;
var nu = undefined;
if (typeof value === "object" && value !== null && !(value instanceof Boolean) && !(value instanceof Date) && !(value instanceof Number) && !(value instanceof RegExp) && !(value instanceof String)) {
for (i = 0; i < objects.length; i += 1) {
if (objects[i] === value) {
return undefined;
}
}
objects.push(value);
if (DSUtils.isArray(value)) {
nu = [];
for (i = 0; i < value.length; i += 1) {
nu[i] = rmCirc(value[i]);
}
} else {
nu = {};
forOwn(value, function (v, k) {
return nu[k] = rmCirc(value[k]);
});
}
return nu;
}
return value;
})(object);
} |
and the function as it was added in 1.1.0 function removeCircular(object) {
var objects = [];
return (function rmCirc(value) {
var i;
var nu;
if (typeof value === 'object' && value !== null && !(value instanceof Boolean) && !(value instanceof Date) && !(value instanceof Number) && !(value instanceof RegExp) && !(value instanceof String)) {
for (i = 0; i < objects.length; i += 1) {
if (objects[i] === value) {
return undefined;
}
}
objects.push(value);
if (DSUtils.isArray(value)) {
nu = [];
for (i = 0; i < value.length; i += 1) {
nu[i] = rmCirc(value[i]);
}
} else {
nu = {};
forOwn(value, function (v, k) {
nu[k] = rmCirc(value[k]);
});
}
return nu;
}
return value;
}(object));
} |
I think I figured it out. It's this: Original ES5: forOwn(value, function (v, k) {
nu[k] = rmCirc(value[k]);
}); New ES6: forOwn(value, function (v, k) {
return nu[k] = rmCirc(value[k]);
}); The |
Here are some examples:
The text was updated successfully, but these errors were encountered: