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

Error thrown when input object does not inherit from Object.prototype #7

Closed
robinbullocks4rb opened this issue May 30, 2016 · 1 comment

Comments

@robinbullocks4rb
Copy link
Contributor

robinbullocks4rb commented May 30, 2016

The rename function in index.js uses obj.hasOwnProperty, which is not defined when the object does not inherit from Object.prototype. In the most basic example, this would fail with TypeError: obj.hasOwnProperty is not a function:

const input = Object.create(null);
input.a = 0;
require('rename-keys')(input, key => key);

A more realistic example would be trying to rename the keys of an object returned from querystring, which in Node v6 stopped inheriting from Object.prototype.

const querystring = require('querystring'),
    rename = require('rename-keys');

rename(querystring.parse('a=1'), key => key);

Live example of the same

@robinbullocks4rb
Copy link
Contributor Author

@jonschlinkert I will prepare a PR for this now.

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

No branches or pull requests

1 participant