UNPKG

659 BJavaScriptView Raw
1/*globals importScripts:true, self:true */
2importScripts("/dist/localforage.js");
3
4self.addEventListener('message', function(e) {
5 function handleError(e) {
6 self.postMessage({
7 error: JSON.stringify(e),
8 body: e,
9 fail: true
10 });
11 }
12
13 localforage.setDriver(e.data.driver, function() {
14 localforage.setItem('web worker', e.data.value, function() {
15 localforage.getItem('web worker', function(err, value) {
16 self.postMessage({
17 body: value
18 });
19 });
20 }, handleError).catch(handleError);
21 }, handleError);
22}, false);