( state: PersistedViewportState | undefined, )
| 261 | } |
| 262 | |
| 263 | function sanitizeViewportState( |
| 264 | state: PersistedViewportState | undefined, |
| 265 | ): PersistedViewportState | null { |
| 266 | if (!state) { |
| 267 | return null; |
| 268 | } |
| 269 | |
| 270 | return { |
| 271 | pan: isPoint(state.pan) ? state.pan : DEFAULT_VIEWPORT_STATE.pan, |
| 272 | rotationQuarterTurns: Number.isFinite(state.rotationQuarterTurns) |
| 273 | ? state.rotationQuarterTurns |
| 274 | : DEFAULT_VIEWPORT_STATE.rotationQuarterTurns, |
| 275 | viewMode: isViewMode(state.viewMode) |
| 276 | ? state.viewMode |
| 277 | : DEFAULT_VIEWPORT_STATE.viewMode, |
| 278 | zoom: state.zoom == null || Number.isFinite(state.zoom) ? state.zoom : null, |
| 279 | }; |
| 280 | } |
| 281 | |
| 282 | function isPoint(value: unknown): value is Point { |
| 283 | return Boolean( |
no test coverage detected