-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grid): add setStore helper function and add set method to GridSt…
…ore interface setStore() can be passed to Grid's each() method to write each hex to the grid's store (or the store passed to setStore())
- Loading branch information
1 parent
956a2a0
commit 10125c1
Showing
4 changed files
with
13 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './inStore' | ||
export * from './neighborOf' | ||
export * from './setStore' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Hex } from '../../hex' | ||
import { Grid } from '../grid' | ||
import { GridStore } from '../types' | ||
|
||
export const setStore = <T extends Hex, S extends GridStore<T>, G extends GridStore<T>>(store?: S) => ( | ||
hex: T, | ||
grid: Grid<T, G>, | ||
): GridStore<T> | void => (store ?? grid.store)?.set(hex.toString(), hex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters