0.1.2 • Published 1 year ago

@gallofeliz/persistant-object v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Persistant Object

import { createFilePersistantObject } from '@gallofeliz/persistant-object'

interface MyState {
	count: number
}

const obj = await createFilePersistantObject<MyState>({
	filename: '/save.json',
	onSaveError: (e) => { console.error(e) }
})

if (!obj.count) {
	obj.count = 0
}

obj.count++

// /save.json will be {"count": 1} and next run will increment
0.1.2

1 year ago

0.1.0

1 year ago