(length: number, index: number, plusOrNot: number)
| 128 | * @param plusOrNot +1 or -1 |
| 129 | */ |
| 130 | export 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 |
no outgoing calls
no test coverage detected