Files: e95ec6716fb1a5b78058ee1150877a432bd6a457 / browser.js
399 bytesRaw
1 | module.exports = function (file, suffix, _codec) { |
2 | var codec = _codec || require('./codec') |
3 | return { |
4 | set: function (v, cb) { |
5 | console.log('set', file, v) |
6 | localStorage[file] = codec.encode(v) |
7 | cb() |
8 | }, |
9 | get: function (cb) { |
10 | var value |
11 | try { value = codec.decode(localStorage[file]) } |
12 | catch (err) { return cb(err) } |
13 | cb(null, value) |
14 | } |
15 | } |
16 | |
17 | } |
18 | |
19 | |
20 | |
21 |
Built with git-ssb-web