You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wish I'd seen that before I wrote this, handy if you'd prefer an array of items with a _key property.
/** * Access records matching a string. * * @param {string} string * Text of the string to return values for. OPTIONAL. * * return {array} * Array list of localStorage objects, keys added as "_key" property. */$.jStorage.search=functionsearch(string){varresults=$.jStorage.index(),returnVals=[];for(variinresults){// Remove unwanted types and return records.if(string){if(results[i].match(newRegExp(string,"g"))!==null){returnVals.push($.extend($.jStorage.get(results[i]),{_key: results[i]}));}}else{// Return everything.returnVals.push($.extend($.jStorage.get(results[i]),{_key: results[i]}));}}returnreturnVals;};
If you need to search among the keys for a given string you could clone the
index
-function and modify it:It will return an array with keys containing the string.
The text was updated successfully, but these errors were encountered: