Skip to content
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

[#94] Support for cloning an Empty class instance from fast-querystring #95

Merged
merged 1 commit into from Mar 16, 2024

Conversation

planttheidea
Copy link
Owner

Reason for change

In #94 , it was identified that cloning an object with a prototype that lacks a constructor will fail.

const Empty = function() {};
Empty.prototype = Object.create(null);

const object = new Empty();
const clone = copy(object);

It was failing on calling Function.prototype.toString on the prototype.constructor, which was null.

Change

Check for the existence of the constructor before calling toString on it. In the above case, it causes the condition to fail, falling back to using Object.create to construct a new object with the Empty.prototype.

@planttheidea planttheidea merged commit 5606957 into master Mar 16, 2024
@planttheidea planttheidea deleted the issue-94/empty-class-instance-support branch March 16, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant