import { Optional } from "polar-shared/src/util/ts/Optional" ; export class ConditionalSetting { private readonly key : string ; constructor ( key ) { this . key = key ; } param predicate public accept ( predicate ) { return predicate ( this . get ( ) ) ; } public get ( ) { return Optional . of ( window . localStorage . getItem ( this . key ) ) ; } public set ( value ) { window . localStorage . setItem ( this . key , value ) ; } } export type Predicate < T > = ( value : Optional < T > ) => boolean ;