Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion jstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,33 @@
return typeof(def) == 'undefined' ? null : def;
},

/**
* Looks up items by key match.
*
* @param {String} string - Value to match on.
* @return {array} List of storage items.
*/
search: function(str) {
var returnVals = [];

for (i in _storage) {
if (_storage.hasOwnProperty(i) && i != '__jstorage_meta') {
if (str) {
// remove unwanted types and return records
if (_storage[i].match(new RegExp(str, "g")) !== null) {
returnVals.push($.extend(_storage[_storage[i]], {_key: _storage[i]}));
}
}
else {
// return everything
returnVals.push($.extend(_storage[_storage[i]], {_key: _storage[i]}));
}
}
}

return returnVals;
}

/**
* Deletes a key from cache.
*
Expand Down Expand Up @@ -993,4 +1020,4 @@
// Initialize jStorage
_init();

})();
})();