(
rootOrientation: Orientation,
location: number[],
direction: Position
)
| 156 | } |
| 157 | |
| 158 | export function getRelativeLocation( |
| 159 | rootOrientation: Orientation, |
| 160 | location: number[], |
| 161 | direction: Position |
| 162 | ): number[] { |
| 163 | const orientation = getLocationOrientation(rootOrientation, location); |
| 164 | const directionOrientation = getDirectionOrientation(direction); |
| 165 | |
| 166 | if (orientation === directionOrientation) { |
| 167 | const [rest, _index] = tail(location); |
| 168 | let index = _index; |
| 169 | |
| 170 | if (direction === 'right' || direction === 'bottom') { |
| 171 | index += 1; |
| 172 | } |
| 173 | |
| 174 | return [...rest, index]; |
| 175 | } else { |
| 176 | const index = direction === 'right' || direction === 'bottom' ? 1 : 0; |
| 177 | return [...location, index]; |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | export function getDirectionOrientation(direction: Position): Orientation { |
| 182 | return direction === 'top' || direction === 'bottom' |
no test coverage detected
searching dependent graphs…