Skip to content

find* methods should return optional elementΒ #201

@kylef

Description

@kylef

This is a breaking change and I would wait a bit before we do this to settle the current unreleased changes.

We should rename the current find* methods to filter* because in JavaScript find methods are expected to return the single element and our implementation if the method is inconsistent. We should implement find* to return first matching item.

Take the following example:

// JS Array `find`
["a", "b", "c"].find(c => c === "b"); // "b"
// Array Element `find`
ArrayElement(["a", "b", "c"]).find(c => c.toValue() === "b"); // ["b"]
// We return array slice of B not just B.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions