All Projects â†’ gdotdesign â†’ elm-storage

gdotdesign / elm-storage

Licence: other
Unified interface for accessing and modifying LocalStorage, SessionStorage and Cookies

Programming Languages

elm
856 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to elm-storage

Brownies
đŸ« Tastier cookies, local, session, and db storage in a tiny package. Includes subscribe() events for changes.
Stars: ✭ 2,386 (+18253.85%)
Mutual labels:  cookie, localstorage, sessionstorage
Proxy Storage
Provides an adapter for storage mechanisms (cookies, localStorage, sessionStorage, memoryStorage) and implements the Web Storage interface
Stars: ✭ 10 (-23.08%)
Mutual labels:  cookie, localstorage, sessionstorage
svelte-persistent-store
A Svelte store that keep its value through pages and reloads
Stars: ✭ 111 (+753.85%)
Mutual labels:  cookie, localstorage, sessionstorage
h5webstorage
Web Storage for Angular 2
Stars: ✭ 38 (+192.31%)
Mutual labels:  localstorage, sessionstorage
lookie
Store your data in localStorage with optional expiration time. Almost like a cookie.
Stars: ✭ 78 (+500%)
Mutual labels:  cookie, localstorage
Angular Local Storage
An AngularJS module that gives you access to the browsers local storage with cookie fallback
Stars: ✭ 2,862 (+21915.38%)
Mutual labels:  cookie, localstorage
Awesome Web Storage
😎 Everything you need to know about Client-side Storage.
Stars: ✭ 227 (+1646.15%)
Mutual labels:  localstorage, sessionstorage
Jquery Ezstorage
jQuery EZStorage Plugin: manages browser side storage of data
Stars: ✭ 7 (-46.15%)
Mutual labels:  cookie, sessionstorage
Vue Warehouse
A Cross-browser storage for Vue.js and Nuxt.js, with plugins support and easy extensibility based on Store.js.
Stars: ✭ 161 (+1138.46%)
Mutual labels:  cookie, localstorage
vue-storage-watcher
a reactive storage plugin for vue 👀🔭
Stars: ✭ 60 (+361.54%)
Mutual labels:  localstorage, sessionstorage
cache-bucket
Light Cache for nodeJs and browserJs with TTL.
Stars: ✭ 14 (+7.69%)
Mutual labels:  localstorage, sessionstorage
local-storage-fallback
Check and use appropriate storage adapter for browser (localStorage, sessionStorage, cookies, memory)
Stars: ✭ 103 (+692.31%)
Mutual labels:  localstorage, sessionstorage
phaser-super-storage
A cross platform storage plugin for Phaser
Stars: ✭ 49 (+276.92%)
Mutual labels:  cookie, localstorage
ng2-storage
A local and session storage wrapper for angular 2.
Stars: ✭ 14 (+7.69%)
Mutual labels:  localstorage, sessionstorage
Jest Localstorage Mock
A module to mock window.localStorage and window.sessionStorage in Jest
Stars: ✭ 247 (+1800%)
Mutual labels:  localstorage, sessionstorage
Client-Storage
🗄 Bulletproof persistent Client storage, works with disabled Cookies and/or localStorage
Stars: ✭ 15 (+15.38%)
Mutual labels:  cookie, localstorage
Ngx Store
Angular decorators to automagically keep variables in HTML5 LocalStorage, SessionStorage, cookies; injectable services for managing and listening to data changes and a bit more.
Stars: ✭ 152 (+1069.23%)
Mutual labels:  localstorage, sessionstorage
React Local Storage
Showcase on how to use the native localStorage of the browser in React.
Stars: ✭ 168 (+1192.31%)
Mutual labels:  localstorage, sessionstorage
mst-persist
Persist and hydrate MobX-state-tree stores (in < 100 LoC)
Stars: ✭ 75 (+476.92%)
Mutual labels:  localstorage, sessionstorage
browserStorage
æ”è§ˆć™šæœŹćœ°ć­˜ć‚šć°èŁ…
Stars: ✭ 30 (+130.77%)
Mutual labels:  localstorage, sessionstorage

elm-storage

Build Status Elm Package Version

This module provides a unified interface for accessing and modifying LocalStorage, SessionStorage and Cookies.

Installation

Add gdotdesign/elm-storage to your dependencies:

"dependencies": {
  "gdotdesign/elm-storage": "1.0.0 <= v < 2.0.0"
}

And install with elm-github-install using the elm-install command.

Usage

The following functions are available for Storage.Local, Storage.Session:

-- Asynchronous
get : String -> Task Error (Maybe String)
set : String -> String -> Task Error ()
remove : String -> Task Error ()
keys : Task Error (List String)
length : Task Error Int
clear : Task Error ()

-- Synchronous
getSync : String -> Result Error (Maybe String)
setSync : String -> String -> Result Error ()
keysSync : () -> Result Error (List String)
removeSync : String -> Result Error ()
length : () -> Result Error Int
clear : () -> Result Error ()

and a slightly different version for Storage.Cookie:

-- Asynchronous
set : String -> String -> SetOptions -> Task Error ()
remove : String -> RemoveOptions -> Task Error ()
get : String -> Task Error (Maybe String)
clear : RemoveOptions -> Task Error ()
keys : Task Error (List String)
length : Task Error Int

-- Synchronous
setSync : String -> String -> SetOptions -> Result Error ()
removeSync : String -> RemoveOptions -> Result Error ()
getSync : String -> Result Error (Maybe String)
keysSync : () -> Result Error (List String)
clear : RemoveOptions -> Result Error ()
length : () -> Result Error Int

-- Options
type alias SetOptions =
  { domain : String
  , expires : Float
  , secure : Bool
  , path : String
  }

type alias RemoveOptions =
  { domain : String
  , path : String
  }

Testing

The module contains steps and assertions to use with elm-spec. Check out the specs on how to use them, and here is a quick example:

import Spec exposing (..)

import Storage.Spec.Local exposing (localStorage)

tests : Node
tests =
  describe "Local Storage"
    [ it "should be testable"
      [ localStorage.clear
      , localStorage.set "user" "yoda"
      , localStorage.hasItem "user"
      , localStorage.valueEquals "user" "yoda"
      , localStorage.haveNumberOfItems 1
      , localStorage.haveItems ["user"]
      ]
    ]

main =
  run tests
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].