File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 11-- | This module defines a data type and various functions for interacting
22-- | with the `Storage` interface of the Web Storage API.
3+ -- | For example:
4+ -- |
5+ -- | ```purescript
6+ -- | main :: Effect Unit
7+ -- | main = do
8+ -- | w <- window
9+ -- | s <- localStorage w
10+ -- | setItem "this-is-my-key" "Here is my value." s
11+ -- | v <- getItem "this-is-my-key" s
12+ -- | logShow v
13+ -- |
14+ -- | removeItem "this-is-my-key" s
15+ -- | v' <- getItem "this-is-my-key" s
16+ -- | log "It is gone!"
17+ -- | logShow v'
18+ -- |
19+ -- | clear s
20+ -- | ```
21+
322module Web.Storage.Storage
423 ( Storage
524 , length
@@ -33,7 +52,8 @@ foreign import _getItem :: String -> Storage -> Effect (Nullable String)
3352getItem :: String -> Storage -> Effect (Maybe String )
3453getItem s = map toMaybe <<< _getItem s
3554
36- -- | Given a key name and a value (in that order), adds that key to the storage or updates its value if it already exists.
55+ -- | Given a key name and a value (in that order), adds that key to the
56+ -- | storage or updates its value if it already exists.
3757foreign import setItem :: String -> String -> Storage -> Effect Unit
3858
3959-- | Removes the given key from the storage.
You can’t perform that action at this time.
0 commit comments