#Jaadi
Jaadi is simple, easy to use, abstraction API over many storage techniques provided by DOM, W3C, Browser specific (Chrome) and user defined storages. Jaadi provides interface for basic CRUD operations.
##How to get it?
You can download the latest version of jaadi from the build/ folder. Standard Jaadi implementation gives access to following storage implementations
- Browser DOM's default property map
{}
- Browser Cookie
document.cookies
- W3C's
window.localStorage
- W3C's
window.sessionStorage
- Chrome's
chrome.storage.local
##API Usage
Jaadi provides these basic CRUD methods
- get
- put
- remove
- size
- items
var dom = Jaadi.createInstance("dom")
create an entry into the storage
dom.put("a",10); //put a literal
dom.put("person", {name:"Name","age":10}); //put a JSON
get the item from storage using the keys
var val = dom.get("a");
var person = dom.get("person"); //get back a JSON object
remove the entry from storage
dom.remove("person"); //remove the person object
Returns the dom elements as pair (key,value)
. This follows the python's items() construct which returns the list of items.
var items = dom.items(); //get the items as set
for(var i = 0; i < items.length;i++)
{
key = items[i][0];
value = items[i][1];
console.log("Key="+key+" Value=" + value);
}
Returns the count of items in the storage
var count = dom.size(); //size of the Jaadi
Jaadi allows you to create your own storage extension and use it across your app. Extend the basic class and write your own storage plugin.
All the storage mechanisms are created as plugins. Refer to src/ folder for .jaadi.js
files
Add plugin to Jaadi
Jaadi.plugins.add("bst",BinarySearchTree);
Use it
tree = Jaadi.createInstance("bst");
Jaadi provides a simple Binary search tree implementation. You can download the plugin.
- Browser DOM's default property map
{}
- Browser Cookie
document.cookies
- W3C's
window.localStorage
- W3C's
window.sessionStorage
- Chrome's
chrome.storage.local
- Simple Binary tree implementation