Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>array.isNonEmpty

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

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>