Skip to content

Commit

Permalink
🎨 ✨ add getState and refactor some name
Browse files Browse the repository at this point in the history
  • Loading branch information
hemedani committed May 8, 2021
1 parent 3146503 commit 929d67b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ export const create = <T>(
: await createFile(JSON.stringify(db));
};

const checkData = (data: T) => {
const validate = (data: T) => {
const isRight = check(data);
return isRight === true
? isRight
: throwError(`${isRight[0].message} but get ${isRight[0].actual}`);
};

const set = async (data: T) => {
const getState = () => db;

const setState = async (data: T) => {
db = {
...data,
};
Expand All @@ -51,8 +53,9 @@ export const create = <T>(

return {
setup,
set,
checkData,
setState,
getState,
validate,
db,
};
};

0 comments on commit 929d67b

Please sign in to comment.