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.

Is it possible to strip undefined properties on encoding?

See original GitHub issue

In the docs it says that both null and undefined will come through as null on the other end. Is it possible to configure something to make undefined properties to be removed completely during encoding?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
simonjeesamcommented, Oct 16, 2018

I went ahead and tried a fix myself based on the work done by @brentd here.

Pull request here.

2reactions
scmorsecommented, Oct 6, 2017

IMO it is a bug to have undefined encoded as null. undefined should not be defined in the encoding. Just like with JSON:

> JSON.parse(JSON.stringify({a: undefined}))
{}
> JSON.parse(JSON.stringify({a: undefined})).a
undefined

Yet with this lib:

> msgpack.decode(msgpack.encode({a: undefined}))
{ a: null }
> msgpack.decode(msgpack.encode({a: undefined})).a
null
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove undefined and null values from an object ...
You can simply chain _.omit() with _.isUndefined and _.isNull compositions, and get the result with lazy evaluation.
Read more >
Strip unknown properties during encode · Issue #274 - GitHub
@ggoodman I'm working on this right now. My plan is to deprecate the type combinator in favour of a xxx (name to be...
Read more >
Remove undefined values from an array in JavaScript
This post will discuss how to remove undefined values from an array in JavaScript. The solution should return a new array that excludes...
Read more >
7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
The short answer is that JavaScript interpreter returns undefined when accessing a variable or object property that is not yet initialized.
Read more >
3 Ways to Remove a Property from a JavaScript Object
Here the delete operator deletes property2 from the myObject . After the delete operator is completed, the object will no longer have the...
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