-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aabb196
commit 1bcfc8a
Showing
4 changed files
with
55 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"exclude": [ | ||
"./node" | ||
], | ||
"tasks": { | ||
"test": "deno test", | ||
"dev": "deno task test --watch", | ||
"node": "deno run --allow-env --allow-read --allow-write --allow-run dnt.ts" | ||
} | ||
} | ||
"exclude": [ | ||
"./node" | ||
], | ||
"tasks": { | ||
"test": "deno test", | ||
"dev": "deno task test --watch", | ||
"node": "deno run --allow-env --allow-read --allow-write --allow-run dnt.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { persistentAtom } from "npm:@nanostores/[email protected]"; | ||
import { WritableAtom, action, atom } from "npm:[email protected]"; | ||
import { action, atom, WritableAtom } from "npm:[email protected]"; | ||
|
||
export type WordleError = | ||
| "max_attempts_reached" | ||
|
@@ -13,7 +13,7 @@ export function wordle( | |
persistKey?: string; | ||
maxAttempts?: number; | ||
validateAttempt?: (word: string) => boolean; | ||
} | ||
}, | ||
) { | ||
if (options?.persistKey) { | ||
console.log("key is", `"wordle-${options?.persistKey}"`); | ||
|
@@ -27,9 +27,9 @@ export function wordle( | |
const $attempts: WritableAtom<string[]> = | ||
options?.persistKey && options?.persistKey.length > 0 | ||
? persistentAtom(`wordle-${options?.persistKey}`, [], { | ||
encode: JSON.stringify, | ||
decode: JSON.parse, | ||
}) | ||
encode: JSON.stringify, | ||
decode: JSON.parse, | ||
}) | ||
: atom([]); | ||
|
||
const maxAttempts = options?.maxAttempts ?? 6; | ||
|
@@ -64,7 +64,7 @@ export function wordle( | |
store.set([...store.get(), attemptedWord]); | ||
|
||
return {}; | ||
} | ||
}, | ||
); | ||
|
||
return { word: $word, attempts: $attempts, attempt, maxAttempts }; | ||
|