Skip to content

How to deal with empty items #6

Open
@hax

Description

@hax

What [1, , 2, , , 2, 1].unique() should return?

At least there are three options:

  1. Treat empty items as undefined, so returns [1, undefined, 2].
    This matches what [...new Set(arr)] do as README, but I suppose it's not intentional. Note if unique(f), f would be called on every empty items as undefined, (or called with no param?) (To avoid runtime error, if f is a key, I guess it should be treat as x => x?.[key])
  2. Skip all empty items and keep them, so returns [1, , 2, , , ,]
  3. Skip all empty items and drop them, so returns [1, 2]

Personally I prefer the last option.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions