Basil.js是一个JavaScript的数据持久化层库,实现了统一的LocalStorage、Cookie和Session存储。
基本使用:
basil = new window.Basil(options);// basic methodsbasil.set('foo', 'bar'); // store 'bar' value under 'foo' keybasil.set('abc', 'xyz'); // store 'xyz' value under 'abc' keybasil.get('foo'); // returns 'bar'basil.keys(); // returns ['abc', 'foo']basil.keysMap(); // returns { 'abc': ['local'], 'foo': ['local'] }basil.remove('foo'); // remove 'foo' value// advanced methodsbasil.check('local'); // boolean. Test if localStorage is availablebasil.reset(); // reset all stored values under namespace支持的浏览器:
Firefox3.5+
InternetExplorer7(requiresjson2.js)
InternetExplorer8+
Chrome4+
Safari4+
评论