jetpack.storage.simple.has(key)
Simple property bag interfaces often have |has| methods in addition to
their |get|, |set|, and |remove| methods, and they come in handy, even
though one can accomplish the same thing with |typeof get("foo") ==
"undefined"|, since the code is shorter to type and easier to grok.
In some cases |has| can also be more efficient than |get| when testing
sparse properties or those with large values.
-myk
+1.
Myk, can you add this to the JEP? We should also consider a |list| method, which returns all currently set values.
list
too.1) Instead of |list|, what do you think about |keys|, |values|, and | pairs|?
1) Instead of |list|, what do you think about |keys|, |values|, and |
pairs|? I guess everyone has an intuitive sense of what |list| means
-- probably "pairs" -- but it's not so clear.
2) Are the results of |list| and the other three methods I proposed
ordered? If not, should there be sorting methods too, or do we leave
that up to callers once they get their list?
Something else that might be cool but for a later discussion is if I
could retrieve my entire simple storage as a JS object. Like,
jetpack.storage.simple.dictionary gets me { key1: val1, key2:
val2, ... }.