MCPcopy Create free account
hub / github.com/apitable/apitable / getArrayLoopIndex

Function getArrayLoopIndex

packages/core/src/utils/array.ts:130–137  ·  view source on GitHub ↗
(length: number, index: number, plusOrNot: number)

Source from the content-addressed store, hash-verified

128 * @param plusOrNot +1 or -1
129 */
130export const getArrayLoopIndex = (length: number, index: number, plusOrNot: number) => {
131 if (index == null || length <= 0) return 0;
132 const newIndex = index + plusOrNot;
133 if (newIndex < 0) {
134 return (length + newIndex) % length;
135 }
136 return newIndex % length;
137};
138
139/**
140 * @description adds an anchorIndex to each item in the object array to be sorted, where anchorIndex is the order of the unsorted array

Callers 4

SearchBaseFunction · 0.90
setCursorIndex2PreFunction · 0.90
setCursorIndex2NextFunction · 0.90
updateIndexFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected