@mikuroxina/mini-fn
    Preparing search index...

    Function head

    • Gets the first element of the list.

      Type Parameters

      • T

      Parameters

      Returns Option.Option<T>

      The first element of list if exists.

      Examples

      expect(head(empty())).toStrictEqual(Option.none());
      expect(head(fromString("hoge"))).toStrictEqual(Option.some("h"));

      const list = singleton(42);
      expect(head(list)).toStrictEqual(Option.some(42));
      expect(head(list.rest())).toStrictEqual(Option.none());