diff --git a/.gitignore b/.gitignore
index e43b0f9..6423b8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
.DS_Store
+node_modules
+.vscode
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..130b70d
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,43 @@
+# Contributing
+
+I consider jStorage complete, so only bug fixes are accepted but no new features please. jStorage has an extremely
+permissive license, you can do whatever you like with the code with no kind of attribution required. If you want a
+version of jStorage that has additional features or has some existing features stripped, you can fork or clone the
+code of jStorage and treat it as you like. You can even republish it under another name and license if you like,
+no constraints about that.
+
+## Alternatives
+
+If you do not need to support IE6 and IE7, you don't even need something like jStorage. You can accomplish all
+your storage needs with the folowing simple functions with no dependencies whatsoever
+
+ /**
+ * Stores a value to the persistent browser storage
+ *
+ * @param {String} key The key name of stored object
+ * @param {Mixed} value A value to be stored, can be anything that is JSON compatible
+ */
+ function store(key, value){
+ window.localStorage[key] = JSON.stringify(value);
+ }
+
+ /**
+ * Loads a value from the persistent browser storage by a key
+ *
+ * @param {String} key The key name of stored object
+ * @return {Mixed} Stored value, can be anything that is JSON compatible
+ */
+ function retrieve(key){
+ var value;
+ try{
+ value = JSON.parse(window.localStorage[key]);
+ }catch(E){}
+ return value;
+ }
+
+The usage of JSON is required to support storing other values than strings which is the "native" storage type
+for using localStorage API.
+
+## Formatting
+
+Use 4 spaces instead of tabs. Commas last. Use double quotes instead of single quotes where possible.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..00d2e13
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to
\ No newline at end of file
diff --git a/README.md b/README.md
index 520d1cf..baca9fb 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,9 @@
+## NB!
+
+> This project is in a frozen state. No more API changes. Pull requests for bug fixes are welcomed, anything else gets most probably ignored. A bug is something that breaks the application, outdated package file is not a bug.
+
+----
+
# jStorage
**jStorage** is a cross-browser key-value store database to store data locally in the browser - jStorage supports all major browsers, both in **desktop** (yes - even Internet Explorer 6) and in **mobile**.
@@ -6,15 +12,151 @@ Additionally jStorage is library agnostic, it works well with any other JavaScri
jStorage supports storing Strings, Numbers, JavaScript objects, Arrays and even native XML nodes which kind of makes it a JSON storage. jStorage also supports setting TTL values for auto expiring stored keys and - best of all - notifying other tabs/windows when a key has been changed, which makes jStorage also a local PubSub platform for web applications.
-jStorage is pretty small, about 10kB when minified, 4kB gzipped.
+jStorage is pretty small, about 7kB when minified, 3kB gzipped.
+
+## Function reference
+
+### set(key, value[, options])
+
+```javascript
+$.jStorage.set(key, value, options)
+```
+
+Saves a value to local storage. key needs to be string otherwise an exception is thrown. value can be any JSONeable value, including objects and arrays or a XML node.
+Currently XML nodes can't be nested inside other objects: `$.jStorage.set("xml", xml_node)` is OK but `$.jStorage.set("xml", {xml: xml_node})` is not.
+
+Options is an optional options object. Currently only available option is options.TTL which can be used to set the TTL value to the key `$.jStorage.set(key, value, {TTL: 1000})`. NB - if no TTL option value has been set, any currently used TTL value for the key will be removed.
+
+### get(key[, default])
+
+```javascript
+value = $.jStorage.get(key)
+value = $.jStorage.get(key, "default value")
+```
+
+get retrieves the value if key exists, or default if it doesn't. key needs to be string otherwise an exception is thrown. default can be any value.
+
+### deleteKey(key)
+
+```javascript
+$.jStorage.deleteKey(key)
+```
+
+Removes a key from the storage. key needs to be string otherwise an exception is thrown.
+
+### setTTL(key, ttl)
+
+```javascript
+$.jStorage.set("mykey", "keyvalue");
+$.jStorage.setTTL("mykey", 3000); // expires in 3 seconds
+```
+
+Sets a TTL (in milliseconds) for an existing key. Use 0 or negative value to clear TTL.
+
+### getTTL(key)
+
+```javascript
+ttl = $.jStorage.getTTL("mykey"); // TTL in milliseconds or 0
+```
+
+Gets remaining TTL (in milliseconds) for a key or 0 if not TTL has been set.
+
+### flush()
+
+```javascript
+$.jStorage.flush()
+```
+
+Clears the cache.
+
+### index()
+
+```javascript
+$.jStorage.index()
+```
+
+Returns all the keys currently in use as an array.
+
+```javascript
+var index = $.jStorage.index();
+console.log(index); // ["key1","key2","key3"]
+```
+
+### storageSize()
-If jStorage is loaded on the page localStorage and sessionStorage polyfills are added to IE6 and IE7 in addition to regular $.jStorage methods.
-You can use regular setItem/getItem
-methods with the polyfills but getter/setters can be used as well:
+```javascript
+$.jStorage.storageSize()
+```
- localStorage.mykey = myval;
+Returns the size of the stored data in bytes
-is absolutely valid with jStorage. The only downside is that you can't use *onstorage* event, you need to fall back to *listenKeyChange* instead.
+### currentBackend()
+
+```javascript
+$.jStorage.currentBackend()
+```
+
+Returns the storage engine currently in use or false if none
+
+### reInit()
+
+```javascript
+$.jStorage.reInit()
+```
+
+Reloads the data from browser storage
+
+### storageAvailable()
+
+```javascript
+$.jStorage.storageAvailable()
+```
+
+Returns true if storage is available
+
+### subscribe(channel, callback)
+
+```javascript
+$.jStorage.subscribe("ch1", function(channel, payload){
+ console.log(payload+ " from " + channel);
+});
+```
+
+Subscribes to a Publish/Subscribe channel (see demo)
+
+### publish(channel, payload)
+
+```javascript
+$.jStorage.publish("ch1", "data");
+```
+
+Publishes payload to a Publish/Subscribe channel (see demo)
+
+### listenKeyChange(key, callback)
+
+```javascript
+$.jStorage.listenKeyChange("mykey", function(key, action){
+ console.log(key + " has been " + action);
+});
+```
+
+Listens for updates for selected key. NB! even updates made in other windows/tabs are reflected, so this feature can also be used for some kind of publish/subscribe service.
+
+If you want to listen for any key change, use `"*"` as the key name
+
+```javascript
+$.jStorage.listenKeyChange("*", function(key, action){
+ console.log(key + " has been " + action);
+});
+```
+
+### stopListening(key[, callback])
+
+```javascript
+$.jStorage.stopListening("mykey"); // cancel all listeners for "mykey" change
+```
+
+Stops listening for key change. If callback is set, only the used callback will be cleared, otherwise all listeners will be dropped.
## Donate
@@ -34,22 +176,14 @@ jStorage supports the following features:
## Browser support
-Current availability: jStorage supports all major browsers - Internet Explorer 6+, Firefox 2+,
+Current availability: jStorage supports all major browsers - Internet Explorer 6+, Firefox 2+,
Safari 4+, Chrome 4+, Opera 10.50+
-If the browser doesn't support data caching, then no exceptions are raised - jStorage can still
+If the browser doesn't support data caching, then no exceptions are raised - jStorage can still
be used by the script but nothing is actually stored.
-## Tests
-
-See [tests/testrunner.html](http://www.jstorage.info/static/tests/testrunner.html) for unit tests
-
-**NB!** - listenKeyChange and publish/subscribe tests tend to fail sometimes in Internet Explorer, which should be ok.
-
-## Docs
-
-Project homepage and docs: [www.jstorage.info](http://www.jstorage.info)
-
## License
-**MIT**
\ No newline at end of file
+[Unlicense](http://unlicense.org/) Since version 0.4.7
+
+**MIT** (versions up to 0.4.6)
diff --git a/component.json b/component.json
index f14ea8a..fbac9d6 100644
--- a/component.json
+++ b/component.json
@@ -1,7 +1,7 @@
{
- "name": "jStorage",
- "version": "0.3.0",
- "main": "./jstorage.js",
- "author": "Andris Reinman ",
- "dependencies": {}
-}
\ No newline at end of file
+ "name": "jStorage",
+ "version": "0.4.13",
+ "main": "./jstorage.js",
+ "author": "Andris Reinman ",
+ "dependencies": {}
+}
diff --git a/test.html b/example/index.html
similarity index 98%
rename from test.html
rename to example/index.html
index a0ee624..c341c25 100644
--- a/test.html
+++ b/example/index.html
@@ -13,8 +13,8 @@
.container{width: 700px;margin: 10px auto;}
-
-
+
+