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

x/aitertools/src/range.ts>Range#at

Well-tested utility functions dealing with async iterables
Latest
method Range.prototype.at
import { Range } from "https://deno.land/x/aitertools@0.6.0/src/range.ts";

Returns the element at the specified index in the range. Note that it guarantees to return the same value as Array.from(range).at(index).

import { range } from "./range.ts";

const r = range(10, -10, -3.5);
console.log(r.at(3), r.at(-1));

The above example will print the following 2 lines:

-0.5
-7.5

Parameters

index: number

The index of the element to return. If it is negative, it counts from the end of the range.

Returns

T | undefined

The element at the specified index in the range. If the index is out of range, undefined is returned.