mozilla/localForage — pull request #282 by thgreasi (2014-10-19 19:01:40+00:00)
Title: feat(localforage): add support for custom drivers

Resolves #267

This is a simple implementation, not guessing the use of requirejs, browserify or anything else.
The developer uses an async call like `localforage.defineDriver(dummyStorageDriver);` and passing a "driver definition object" that should look like
```js
{
_driver: 'customDriverUniqueName',
_initStorage: function(options) { },
clear: function(callback) { },
getItem: function(key, callback) { },
key: function(n, callback) { },
keys: function(callback) { },
length: function(callback) { },
removeItem: function(key, callback) { },
setItem: function(key, value, callback) { }
}
```
It also may contain a `_support` property that is either boolean (true/false) or it returns a `Promise` that resolves to a boolean value. If `_support` is omitted, then `true` is used.

For a brief how-to take a look at `test/dummyStorageDriver.js` and `test/test.customdriver.js`.

PS: The async nature of the `defineDriver` method may also prove useful for a future implementation that utilizes requirejs/browserify to load the driver, as [presented in this comment](https://github.com/mozilla/localForage/issues/267#issuecomment-58617567) of #267.