Files: 85b9a420c6cbd73479d210c1ab83d7049b21a7d0 / 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