Skip to content

Throw an error when pass an object created by Object.create(null) #1

Description

@pea3nut
> require('var_dump')(Object.create(null))
TypeError: Cannot read property 'name' of undefined
    at varIsObject (/Users/liuboyuan01/_pea3nut/project/mnt/var-dump/node_modules/var_dump/index.js:140:25)
    at _dump (/Users/liuboyuan01/_pea3nut/project/mnt/var-dump/node_modules/var_dump/index.js:26:14)
    at var_dump (/Users/liuboyuan01/_pea3nut/project/mnt/var-dump/node_modules/var_dump/index.js:183:17)
> throw

There is a way resolving:

  1. Check all .constructor existing before .constructor.name
  2. Replace obj.hasOwnProperty(i) to Object.prototype.hasOwnProperty.call(obj, i)

Activity

  1. ankurnarkhede commented on Jan 24, 2020

    @ankurnarkhede
    Owner

    Thanks @pea3nut for reporting the issue. I will modify the package and release a new version soon.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions