Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/isx/iterable/is_single.ts>isSingle

Collection of validation functions for JavaScript data
Go to Latest
function isSingle
import { isSingle } from "https://deno.land/x/isx@1.1.1/iterable/is_single.ts";

Whether the array is single element or not.

Examples

Example 1

import { isSingle } from "https://deno.land/x/isx@$VERSION/iterable/is_single.ts";
import { assert, assertFalse } from "https://deno.land/std/testing/asserts.ts";

assert(isSingle([0]));
assertFalse(isSingle([]));
assertFalse(isSingle([0, 1, 2]));

Parameters

input: T[]

Any array.

Returns

input is [T]

Parameters

input: readonly T[]

Returns

input is readonly [T]

Whether the input is single element or not.

Examples

Example 1

import { isSingle } from "https://deno.land/x/isx@$VERSION/iterable/is_single.ts";
import { assert, assertFalse } from "https://deno.land/std/testing/asserts.ts";

assert(isSingle("a"));
assertFalse(isSingle(""));
assertFalse(isSingle(new Set([0, 1, 2])));

Parameters

input: Iterable<unknown>

Any iterable.

Returns

boolean