Skip to content

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

Description

@robinbullocks4rb

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions