Skip to main content
Module

x/rimbu/mod.ts>IndexRange.getIndicesFor

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function IndexRange.getIndicesFor
import { IndexRange } from "https://deno.land/x/rimbu@0.14.0/mod.ts";
const { getIndicesFor } = IndexRange;

Returns, given the range IndexRange, and a target maximum length, the actual index range. This can be one of three options:

  • 'empty': there are no elements within the range
  • 'all': all elements are within the range
  • [start: number, end: number]: an inclusive range of element indices within the given range

Parameters

range: IndexRange
  • the IndexRange to use
length: number
  • the target maximum length

Returns

[number, number] | "empty" | "all"