As Myk suggests in his post <http://groups.google.com/group/mozilla-labs-jetpack/browse_thread/thread/8813c5da5b135bf3> adding a |has| and |list| commands to storage.simple would be excellent additions. First, |has| and |list| should be added to JEP 11 <https://wiki.mozilla.org/Labs/Jetpack/JEP/11> and then added to the actual API. Finally, the documentation should be updated.
Created attachment 385962 [details] [diff] [review] WIP v1 Lots of changes. Since the code is fairly small and changes in this bug and bug 499872 overlap, this patch covers both bugs (plus some). This patch adds the following methods: clear forEachItem forEachKey forEachValue has size Nearly every method can be called multiple ways, e.g., to act on a single key or value, a set of keys, or all items. They're documented, so have a look. Needs a little more polish.
OS: Mac OS X → All
Hardware: x86 → All
Created attachment 385980 [details] [diff] [review] WIP v2 A little more polish to go, like filtering out bad keys (actually, bad keys should cause an error to be thrown I'm thinking) and making sure values can't be null anymore, since null is now used to signify async completion for the forEach methods. I've updated the tests for the new methods, but I could write more stress tests with bad keys and values.
Attachment #385962 - Attachment is obsolete: true
Created attachment 386223 [details] [diff] [review] for your consideration v1 This patch adds polish, tests, and the methods keys and values, which yield the store's keys and values in arrays.
Attachment #385980 - Attachment is obsolete: true
I've gone overboard, morphing the bug accordingly.
Summary: Integrate |has| and |list| into simple storage. → Simple storage improvements
Duplicate of this bug: 499872
Created attachment 386332 [details] [diff] [review] for your consideration v2 has() wasn't passing key and keyArray back to callbacks, fixed that. A couple of other small fixes. JEP update forthcoming.
Attachment #386223 - Attachment is obsolete: true
Created attachment 386379 [details] [diff] [review] for your consideration v3 Uh, has() didn't need to pass keyArray to the callback. The callback gets existsObject.
Attachment #386332 - Attachment is obsolete: true
Comment on attachment 386379 [details] [diff] [review] for your consideration v3 Will attach new version shortly.
Attachment #386379 - Attachment is obsolete: true
Created attachment 386934 [details] [diff] [review] for your consideration v4 Allows passing a key array to values() to get specific values in an array. Adds mapItems() and reduceItems() and tightens up the code by using these internally. Updated the JEP with these changes also.
Hi Drew, Do you need us to commit this? Have we given you commit access yet?
Yes, please commit as it's ready to go. I'm still at the kid's table.
Has been applied in this push: http://hg.mozilla.org/labs/jetpack/rev/34fb13b648b1
Created attachment 387085 [details] [diff] [review] documentation patch Simply adds simple storage to extension/index.html.
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.