Skip to main content
Module

x/fun/array.ts>isOutOfBounds

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

Given an index and a ReadonlyArray, return true if the index is valid for the given array. This tests whether index is between 0 and arr.length inclusive.

Examples

Example 1

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

const arr = A.of(1);

const result1 = A.isOutOfBounds(0, arr); // false
const result2 = A.isOutOfBounds(-1, arr); // true
const result3 = A.isOutOfBounds(10, arr); // true

Parameters

index: number
ua: ReadonlyArray<A>

Returns

boolean