Skip to content

Farbdose/DotStorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DotStorage

Wrapper for localStorage to add full dot support

jsFiddle for Testing

Dependencies

This requires pako to work...

Usage

Set primitive values:

dotStorage.Hello = "World";

Set objects:

dotStorage.simpleObj = {
    "Hello": "World"
};

Set complex arrays and access them again:

dotStorage.complexArray = [
    {"Hello": "World0", "index": 0},
    {"Hello": "World1", "index": 1},
    {"Hello": "World2", "index": 2}
];

dotStorage.complexArray.forEach(function (e, i) {
    console.log(e.Hello, e.index);
});

Save an object, modify nested properties and be surprised that DotStorage saves these changes too

var myObj = {"New": "object"};
dotStorage.refTest = myObj;
myObj = dotStorage.refTest;

myObj.New = {"nested": {"otherObject": [0, 1]}};
console.log(JSON.stringify(dotStorage.refTest.New));

myObj.New.nested = 2;
console.log(JSON.stringify(dotStorage.refTest.New));

About

A persistent Javascript Object - Wrapper for localStorage to add full dot support

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors