auth0/angular-storage — pull request #5 by thomastuts (2014-10-08 09:41:33+00:00)
Title: Implement namespacing (issue #2)

I've implemented namespacing since I needed it for my current project, and because there was an issue for it already anyway. I've added a couple of tests that all pass. It supports the following functionality:

- Adding a namespace
- Adding an optional namespace delimiter (defaults to `.`)
- Specifying either a custom namespace or no namespace on a per-method basis (i.e. `get()`, `set()` and `remove()`). If the namespace is `null`, it will not use any namespace to get/set/remove that value (similar to the current implementation). If the namespace is given and not null, it will use that namespace to perform the operation. I'm not sure about the syntax yet, since I didn't want to change too much of the original API.

Also: you might notice that I have replaced all references to `this` with a top-level `store` object, this way I can reference it in the helper function that creates the namespaced key.

____

#### Namespacing configuration

I didn't want to create a whole new provider just to be able to configure things in Angular's `config()` block so I've declared the configuration on the service instead. There are two namespacing options you can set:

- `store.namespace` which defaults to `null` (current behaviour)
- `store.namespaceDelimiter` which defaults to `.` - this will result in stored keys such as `namespace.key`

____

#### Custom/no namespacing syntax

In the `store` methods, the namespace parameter can either be omitted (default behaviour), `null` where it will not use any namespace, or a value which will be used for the namespace instead of the default one.

- `store.get(name, namespace)`
- `store.remove(name, namespace)`
- `store.set(name, elem, namespace)` -- This is the syntax I'm not sure about since the other two methods have the custom namespace right after the key name. I think this way is better though, since this behaviour most likely won't be used a lot, and if we moved it to the second argument, people would have to type `store.set('someName', null, 'someValue')` all the time. Would love to hear your feedback on this.