mirror of
https://github.com/sussy-code/smov.git
synced 2025-01-01 16:37:39 +01:00
commented functions
This commit is contained in:
parent
f6a4f59adb
commit
23b8b816dd
1 changed files with 22 additions and 0 deletions
|
@ -38,6 +38,12 @@ function buildStoreObject(data) {
|
||||||
// updates succesful, return
|
// updates succesful, return
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get a instance of a stored item
|
||||||
|
* will be migrated to the latest version on fetch
|
||||||
|
* call .save() on it put the new modified data back
|
||||||
|
*/
|
||||||
get() {
|
get() {
|
||||||
// get from storage api
|
// get from storage api
|
||||||
const store = this;
|
const store = this;
|
||||||
|
@ -94,10 +100,22 @@ export function versionedStoreBuilder() {
|
||||||
versions: {},
|
versions: {},
|
||||||
storageString: null,
|
storageString: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set key of localstorage item, must be unique
|
||||||
|
*/
|
||||||
setKey(str) {
|
setKey(str) {
|
||||||
this._data.storageString = str;
|
this._data.storageString = str;
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* add a version to the store
|
||||||
|
*
|
||||||
|
* version: version number
|
||||||
|
* migrate: function to update from previous version to this version
|
||||||
|
* create: function to return an empty storage item from this version (in correct syntax)
|
||||||
|
*/
|
||||||
addVersion({ version, migrate, create }) {
|
addVersion({ version, migrate, create }) {
|
||||||
// input checking
|
// input checking
|
||||||
if (version < 0)
|
if (version < 0)
|
||||||
|
@ -128,6 +146,10 @@ export function versionedStoreBuilder() {
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns function store based on what has been set
|
||||||
|
*/
|
||||||
build() {
|
build() {
|
||||||
// check if version list doesnt skip versions
|
// check if version list doesnt skip versions
|
||||||
const versionListSorted = this._data.versionList.sort((a,b)=>a-b);
|
const versionListSorted = this._data.versionList.sort((a,b)=>a-b);
|
||||||
|
|
Loading…
Reference in a new issue