Skip to content

Commit

Permalink
fix(Collection): toJSON() errors if the collection includes empty val…
Browse files Browse the repository at this point in the history
…ues (#5129)
  • Loading branch information
vaporoxx committed Dec 26, 2020
1 parent b19b8b5 commit 2c2249e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/util/Collection.js
Expand Up @@ -5,7 +5,7 @@ const Util = require('./Util');

class Collection extends BaseCollection {
toJSON() {
return this.map(e => (typeof e.toJSON === 'function' ? e.toJSON() : Util.flatten(e)));
return this.map(e => (typeof e?.toJSON === 'function' ? e.toJSON() : Util.flatten(e)));
}
}

Expand Down

3 comments on commit 2c2249e

@mtnkodiak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a typo. Was this the intended change?

@tipakA
Copy link
Contributor

@tipakA tipakA commented on 2c2249e Jan 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtnkodiak
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick reply! I'm a Java guy, still learning js. Thanks for the link.

Please sign in to comment.