Skip to content

find* methods should return optional element #201

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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