import * as A from "../Array"; import type { Option } from "../Option"; import { none, some } from "../Option"; import type { NonEmptyArray } from "./model"; /** * Append an element to the front of an array, creating a new non empty array * * @category Constructors * @since 1.0.0 */ export const cons_: (head: A, tail: ReadonlyArray) => NonEmptyArray = A.cons_; /** * Append an element to the front of an array, creating a new non empty array * * @category Constructors * @since 1.0.0 */ export const cons: (tail: ReadonlyArray) => (head: A) => NonEmptyArray = A.cons; /** * Append an element to the end of an array, creating a new non empty array * * @category Constructors * @since 1.0.0 */ export const snoc_: (init: ReadonlyArray, end: A) => NonEmptyArray = A.snoc_; /** * Append an element to the end of an array, creating a new non empty array * * @category Constructors * @since 1.0.0 */ export const snoc: (end: A) => (init: ReadonlyArray) => NonEmptyArray = A.snoc; /** * Builds a `NonEmptyArray` from an array returning `none` if `as` is an empty array * * @category Constructors * @since 1.0.0 */ export const fromArray = (as: ReadonlyArray): Option> => (A.isNonEmpty(as) ? some(as) : none());