Skip to content

Conversation

magicmark
Copy link

@mcmath thanks for this library!

Came across an issue we're hitting - if this library called over any objects created with Object.create(null), then an error is thrown because of this line:

if (obj.hasOwnProperty(key)) {

I've added a regression test, which also demonstrates the issue:

before

$ npm run test:unit

> [email protected] test:unit
> istanbul cover -e .ts -x '*.test.ts' _mocha -- src --opts mocha.opts

  !․․․․․․․․․․․․․

  13 passing (39ms)
  1 failing

  1) handles null prototype objects:
     TypeError: obj.hasOwnProperty is not a function
      at DeepMapKeys.mapObject (src/deep-map-keys.ts:1:6130)
      at DeepMapKeys.map (src/deep-map-keys.ts:1:5022)
      at deepMapKeys (src/index.ts:1:3000)
      at Context.<anonymous> (src/index.test.ts:112:3)
      at processImmediate (node:internal/timers:471:21)

after

it passes!

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.

1 participant