@@ -11,7 +11,7 @@ import type {
1111 Persister ,
1212 PersisterListener ,
1313 PersisterStats ,
14- Persists as PersistsType ,
14+ Persists as PersistsEnum ,
1515} from '../@types/persisters/index.d.ts' ;
1616import { arrayClear , arrayPush , arrayShift } from '../common/array.ts' ;
1717import {
@@ -24,10 +24,16 @@ import {mapEnsure, mapGet, mapNew, mapSet} from '../common/map.ts';
2424import { objFreeze , objIsEmpty } from '../common/obj.ts' ;
2525import type { Id } from '../@types/common/index.d.ts' ;
2626
27+ const enum PersistsValues {
28+ StoreOnly = 1 ,
29+ MergeableStoreOnly = 2 ,
30+ StoreOrMergeableStore = 3 ,
31+ }
32+
2733export const Persists = {
28- StoreOnly : 1 ,
29- MergeableStoreOnly : 2 ,
30- StoreOrMergeableStore : 3 ,
34+ StoreOnly : PersistsValues . StoreOnly ,
35+ MergeableStoreOnly : PersistsValues . MergeableStoreOnly ,
36+ StoreOrMergeableStore : PersistsValues . StoreOrMergeableStore ,
3137} ;
3238
3339type Action = ( ) => Promise < any > ;
@@ -36,7 +42,7 @@ const scheduleRunning: Map<any, 0 | 1> = mapNew();
3642const scheduleActions : Map < any , Action [ ] > = mapNew ( ) ;
3743
3844const getStoreFunctions = (
39- persist : PersistsType = Persists . StoreOnly ,
45+ persist : PersistsEnum | any = PersistsValues . StoreOnly ,
4046 store : PersistedStore < typeof persist > ,
4147) :
4248 | [
@@ -53,7 +59,7 @@ const getStoreFunctions = (
5359 hasChanges : ( changes : MergeableChanges ) => boolean ,
5460 setDefaultContent : ( content : Content ) => MergeableStore ,
5561 ] =>
56- persist != Persists . StoreOnly && store . isMergeable ( )
62+ persist != PersistsValues . StoreOnly && store . isMergeable ( )
5763 ? [
5864 1 ,
5965 ( store as MergeableStore ) . getMergeableContent ,
@@ -62,7 +68,7 @@ const getStoreFunctions = (
6268 ! objIsEmpty ( changedTables ) || ! objIsEmpty ( changedValues ) ,
6369 ( store as MergeableStore ) . setDefaultContent ,
6470 ]
65- : persist != Persists . MergeableStoreOnly
71+ : persist != PersistsValues . MergeableStoreOnly
6672 ? [
6773 0 ,
6874 store . getContent ,
@@ -75,7 +81,7 @@ const getStoreFunctions = (
7581
7682export const createCustomPersister = <
7783 ListeningHandle ,
78- Persist extends PersistsType = PersistsType . StoreOnly ,
84+ Persist extends PersistsEnum = PersistsEnum . StoreOnly ,
7985> (
8086 store : PersistedStore < Persist > ,
8187 getPersisted : ( ) => Promise < PersistedContent < Persist > | undefined > ,
0 commit comments