dreamdust/sticky — Issue #1: StickyStore.get should support a 'default' argument
Author: chris-morgan
Created: 2011-10-16 13:21:33+00:00
State: open

It would be nice if `StickStore.get` supported an extra 'default' argument.

At present:

var foo = store.get('foo');
if (foo === null) {
foo = 'bar';
}

This would be nicer done as:

var foo = store.get('foo', 'bar')

Then, if the key `foo` doesn't exist, it'll return the value `'bar'`.

(Python's `dict.get` does this. Basically, it's basically `def get(self, key, default=None)`.)

Rationale: It's very useful for configuration stores as this will probably be used a lot for as it means that you don't need to worry about whether an option is set but can take a default value immediately and easily.