Files: a569cc80c75f15b0204f3af8a330e5866dd83389 / create.js
537 bytesRaw
1 | var util = require('multiblob/util') |
2 | var isBlob = require('ssb-ref').isBlob |
3 | var MultiBlob = require('multiblob') |
4 | |
5 | function desigil (hash) { |
6 | return isBlob(hash) ? hash.substring(1) : hash |
7 | } |
8 | |
9 | function resigil (hash) { |
10 | return isBlob(hash) ? hash : '&'+hash |
11 | } |
12 | |
13 | module.exports = function (dir) { |
14 | return MultiBlob({ |
15 | dir: dir, |
16 | alg: 'sha256', |
17 | encode: function (buf, alg) { |
18 | return resigil(util.encode(buf, alg)) |
19 | }, |
20 | decode: function (str) { |
21 | return util.decode(desigil(str)) |
22 | }, |
23 | isHash: isBlob |
24 | }) |
25 | } |
26 | |
27 | |
28 |
Built with git-ssb-web