Skip to main content
Module

x/fun/array.ts>isNonEmpty

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function isNonEmpty
import { isNonEmpty } from "https://deno.land/x/fun@v2.0.0/array.ts";

A Refinement<ReadonlyArray, NonEmptyArray>, returning true if called with an array that has at least one item.

Examples

Example 1

import * as A from "./array.ts";

const arr1 = [1]
const arr2 = A.init<number>();

const result1 = A.isNonEmpty(arr1);
// true and arr1 has type NonEmptyArray<number>
const result2 = A.isNonEmpty(arr2);
// false

Parameters

a: ReadonlyArray<A>