MCPcopy Create free account
hub / github.com/primer/react / wrapArray

Function wrapArray

packages/react/src/TreeView/useTypeahead.ts:95–97  ·  view source on GitHub ↗

* Wraps an array around itself at a given start index * * @example * wrapArray(['a', 'b', 'c', 'd'], 2) // ['c', 'd', 'a', 'b']

(array: T[], startIndex: number)

Source from the content-addressed store, hash-verified

93 * wrapArray(['a', 'b', 'c', 'd'], 2) // ['c', 'd', 'a', 'b']
94 */
95function wrapArray<T>(array: T[], startIndex: number) {
96 return array.map((_, index) => array[(startIndex + index) % array.length])
97}

Callers 1

useTypeaheadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected