( layout: Layout, itemKey: string, cb: (item: LayoutItem) => LayoutItem )
| 161 | * @returns Tuple of [new layout, modified item or null if not found] |
| 162 | */ |
| 163 | export function withLayoutItem( |
| 164 | layout: Layout, |
| 165 | itemKey: string, |
| 166 | cb: (item: LayoutItem) => LayoutItem |
| 167 | ): [LayoutItem[], LayoutItem | null] { |
| 168 | let item = getLayoutItem(layout, itemKey); |
| 169 | if (!item) { |
| 170 | return [[...layout], null]; |
| 171 | } |
| 172 | |
| 173 | // Clone, then modify via callback |
| 174 | item = cb(cloneLayoutItem(item)); |
| 175 | const newLayout = modifyLayout(layout, item); |
| 176 | |
| 177 | return [newLayout, item]; |
| 178 | } |
| 179 | |
| 180 | // ============================================================================ |
| 181 | // Bounds Correction |
no test coverage detected
searching dependent graphs…