Skip to content

Feature request: add an iterable-aware firstValue / head helper #1796

Description

@tyteen4a03

Problem

es-toolkit currently provides head, but it appears to be array-oriented. For example, it works for arrays but not generic iterables such as Set:

head([1, 2]); // 1
head(new Set([1, 2])); // undefined

It would be good if there is a new function that works across all iterables. It would be a shortcut of values[Symbol.iterator]().next().value;.

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