UNPKG

showcar-storage

Version:

This module provides an abstraction layer for storing information on the client-side.

103 lines (69 loc) 5.01 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Home - Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Storage.html">Storage</a><ul class='methods'><li data-type='method'><a href="Storage.html#get">get</a></li><li data-type='method'><a href="Storage.html#has">has</a></li><li data-type='method'><a href="Storage.html#remove">remove</a></li><li data-type='method'><a href="Storage.html#set">set</a></li></ul></li></ul> </nav> <div id="main"> <section class="readme"> <article><h1>showcar-storage</h1><p>This module provides an abstraction layer for storing information on the client-side.</p> <h2>Usage</h2><p>How to use:</p> <h3>Instantiation</h3><pre class="prettyprint source lang-javascript"><code> const Storage = require(&quot;showcar-storage&quot;); const localStore = new Storage(&quot;local&quot;); const sessionStore = new Storage(&quot;session&quot;); const cookieStore = new Storage(&quot;cookie&quot;);</code></pre><h3>Use the following api</h3><h4><code>someStore.set(key, value, [{ expires, path }]);</code></h4><p> Sets the given value for the specified key in the respective store. The optional third parameter takes a map with any of the following options:</p> <ul> <li><code>expires: &lt;Date|UTCString|int&gt;</code> Expiration date of the cookie as date-object, UTCString or positive integer in seconds from now. Defaults to <code>Fri, 31 Dec 9999 23:59:59 GMT</code>.</li> <li><p><code>path: &lt;string&gt;</code> Will be set as the cookie's path. Defaults to <code>/</code>.</p> <p>Returns the reference to the respective store, i.e. <code>someStore</code>.</p> </li> </ul> <h4><code>someStore.get(key[, default = null]);</code></h4><p> Gets the value for the specified key from the respective store. If a second argument is given and a value for the specified key is not found in the respective store, the second argument is returned.</p> <p> Returns the stored value or the value of <code>default</code>.</p> <h4><code>someStore.has(key);</code></h4><p> Checks whether the respective store knows about the key and whether the value for this key is not null. This method is synonymous to <code>null !== someStore.get(key, null);</code></p> <p> Returns boolean <code>true</code> if the given key exists and is not null and not undefined, <code>false</code> otherwise.</p> <h4><code>someStore.remove(key);</code></h4><p> Deletes the key and the associated value from the respective store.</p> <p> Returns the reference to the respective store, i.e. <code>someStore</code>.</p> <h2>Installation</h2><h3>How to install:</h3><p> To install showcar-storage within your project use bower.</p> <p> <code>bower install --save git@github.com:AutoScout24/showcar-storage.git</code></p> <h2>Contributing</h2><h3>How to contribute:</h3><p> Fork this repository and <code>git clone</code> your fork. Then <code>npm install</code> the required dependencies.</p> <p> Note: If you do not have <code>grunt</code> installed globally, use <code>./node_modules/.bin/grunt</code> instead.</p> <h4>Run the tests</h4><p> Run <code>grunt test</code> (or <code>./node_modules/.bin/grunt test</code>).</p> <h4>Build for dev</h4><p> Run <code>grunt build</code> (or <code>./node_modules/.bin/grunt build</code>). Find the generated files in <em>./dist/</em> next to it's sourcemap.</p> <h4>Build minified for distribution</h4><p> Run <code>grunt dist</code> (or <code>./node_modules/.bin/grunt dist</code>). Find the generated file <em>./dist/storage.min.js</em> next to it's sourcemap.</p> <h4>Contribute</h4><p> Save your changes and run <code>grunt dist</code> (or <code>./node_modules/.bin/grunt dist</code>).</p> <p> Commit your code <em>and</em> the compiled libraries in <em>./dist</em>. Then create a pull-request.</p> <h2>License</h2><p>MIT License</p></article> </section> </div> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri May 13 2016 17:38:26 GMT+0200 (W. Europe Daylight Time) using the Minami theme. </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>