andris9/jStorage — Issue #22: possible enhancement: count method
Author: MichaelMartinez
Created: 2012-01-16 18:25:06+00:00
State: open

Hi, I really appreciate the efforts you've put into this great library. I modified your library to provide a count of keys in the storage object.

/**
* Returns a count of all used keys in index array
* ie. 6
*
* @returns int
*/
count: function(){
var countNum = 0;
var index = [], i;
for(i in _storage){
if(_storage.hasOwnProperty(i)&& i != "_jstorage_meta"){
index.push(i);
}
}
countNum = index.length;
return countNum;
},

I realize I could use $.jStorage.index().length to get the same value, but I recently typed "lenght" into github search and was shocked by all of the typos. Anyway, my line of thought is that explicitly calling a method is never a "bad thing." Take care and thanks again.