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

x/rimbu/common/index.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@1.0.4/common/index.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"