question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider not filtering out properties that are explicitely set to undefined

See original GitHub issue

There are use-cases in which it makes sense to set a property to undefined and still expect it to be copied. Object.assign() does not filter out such properties, either.

What’s the reason for them to be filtered in node-extend?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

1reaction
danielo515commented, Sep 25, 2016

However, this module is exclusively to mirror jQuery’s “extend” function, so that’s the behavior it will preserve.

I recommend https://npmjs.com/object.assign if you want an official polyfill for the native language feature.

That exact advice is what I expect to be more noticeable. Since this module is just called extend, it could lead to confusion. I know that the very first sentence is that it mirrors JQuery’s extend function, but for people who is not familiar with JQuery it means nothing. A small explanation of the unexpected behaviors would be nice, and of course your recommendation for another polyfill

Thanks and regards

0reactions
ljharbcommented, Sep 16, 2016

Ah, I understand what this issue is about now.

Object.assign does do what you mean - in other words, Object.assign({}, { value: 3 }, { value: undefined }) will result in { value: undefined }.

However, this module is exclusively to mirror jQuery’s “extend” function, so that’s the behavior it will preserve.

I recommend https://npmjs.com/object.assign if you want an official polyfill for the native language feature.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Filter to remove undefined items is not picked up by ...
The solution is to pass a type-guard function that tells TypeScript that you're filtering out the undefined part of the type:
Read more >
Distinguish missing and undefined · Issue #13195
TypeScript Version: 2.1.4 Code Current, with --strictNullChecks on, the typescript compiler seems to treat interface Foo1 { bar?
Read more >
Understanding the difference between null and undefined ...
We'll look at the difference between null and undefined values. The value null must be explicitly set for a property. For example, here...
Read more >
A Definitive Guide to Handling Errors in JavaScript
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >
Documentation - Narrowing
Argument of type 'string | number' is not assignable to parameter of type ... But it turns out that in JavaScript, typeof null...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found