import { map , Maybe } from '@typed/maybe' ; import { getItem , setItem , StorageEnv } from '@typed/storage' ; import { Grid , GridRepository } from '../domain' ; export function createGridRepository ( storageKey ) { function * getGrid ( ) { const gridJson = yield * getItem ( storageKey ) ; const grid = map ( JSON . parse , gridJson ) ; return grid ; } function * updateGrid ( grid ) { yield * setItem ( storageKey , JSON . stringify ( grid ) ) ; return grid ; } return { getGrid , updateGrid , } ; }