( orderedIds: number[], anchorId: number | undefined, targetId: number, )
| 15 | } |
| 16 | |
| 17 | export function getContiguousSelection( |
| 18 | orderedIds: number[], |
| 19 | anchorId: number | undefined, |
| 20 | targetId: number, |
| 21 | ): number[] { |
| 22 | if (!orderedIds.length) { |
| 23 | return [] |
| 24 | } |
| 25 | |
| 26 | const anchorIndex |
| 27 | = anchorId !== undefined ? orderedIds.indexOf(anchorId) : -1 |
| 28 | const targetIndex = orderedIds.indexOf(targetId) |
| 29 | |
| 30 | if (targetIndex === -1) { |
| 31 | return [] |
| 32 | } |
| 33 | |
| 34 | if (anchorIndex === -1) { |
| 35 | return [targetId] |
| 36 | } |
| 37 | |
| 38 | const startIndex = Math.min(anchorIndex, targetIndex) |
| 39 | const endIndex = Math.max(anchorIndex, targetIndex) |
| 40 | |
| 41 | return orderedIds.slice(startIndex, endIndex + 1) |
| 42 | } |
| 43 | |
| 44 | export * from './entryNameValidationMessage' |
no outgoing calls
no test coverage detected