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 1
1
-- | This module defines a data type and various functions for interacting
2
2
-- | 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
+
3
22
module Web.Storage.Storage
4
23
( Storage
5
24
, length
@@ -33,7 +52,8 @@ foreign import _getItem :: String -> Storage -> Effect (Nullable String)
33
52
getItem :: String -> Storage -> Effect (Maybe String )
34
53
getItem s = map toMaybe <<< _getItem s
35
54
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.
37
57
foreign import setItem :: String -> String -> Storage -> Effect Unit
38
58
39
59
-- | Removes the given key from the storage.
You can’t perform that action at this time.
0 commit comments