-
Notifications
You must be signed in to change notification settings - Fork 0
Function.asCircular
GitHub Action edited this page Jul 6, 2025
·
17 revisions
API Reference / asCircular
asCircular<
T
>(array
):T
[]
Defined in: as-circular.ts:18
Accepts an array and converts it into a circular array.
T
T
[]
The array to make circular.
T
[]
A Proxy to the original array which intercepts certain getters, setters, and methods to allow for circular and negative indexing of the array.
const arr = asCircular([0, 1, 2]);
console.log(arr[3]); // prints 0
console.log(arr[6]); // also prints 0
console.log(arr[-1]); // prints 2
console.log(arr[-4]); // also prints 2
console.log(arr.at(-6)); // prints 0 fdsa