File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 1+ -- | This module defines a data type and various functions for interacting
2+ -- | with the `Storage` interface of the Web Storage API.
13module Web.Storage.Storage
24 ( Storage
35 , length
@@ -16,20 +18,26 @@ import Effect (Effect)
1618
1719foreign import data Storage :: Type
1820
21+ -- | Returns the number of items in the storage.
1922foreign import length :: Storage -> Effect Int
2023
2124foreign import _key :: Int -> Storage -> Effect (Nullable String )
2225
26+ -- | Retrieves the key at the given index in the storage, if one exists.
2327key :: Int -> Storage -> Effect (Maybe String )
2428key i = map toMaybe <<< _key i
2529
2630foreign import _getItem :: String -> Storage -> Effect (Nullable String )
2731
32+ -- | Retrieves the value stored at the given key, if one exists.
2833getItem :: String -> Storage -> Effect (Maybe String )
2934getItem s = map toMaybe <<< _getItem s
3035
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.
3137foreign import setItem :: String -> String -> Storage -> Effect Unit
3238
39+ -- | Removes the given key from the storage.
3340foreign import removeItem :: String -> Storage -> Effect Unit
3441
42+ -- | Clears all keys from the storage.
3543foreign import clear :: Storage -> Effect Unit
You can’t perform that action at this time.
0 commit comments