git ssb

3+

Dominic / ssb-blobs



Tree: c0e9a969c5c0484a867b4ca5508beaeff462f603

Files: c0e9a969c5c0484a867b4ca5508beaeff462f603 / create.js

537 bytesRaw
1var util = require('multiblob/util')
2var isBlob = require('ssb-ref').isBlob
3var MultiBlob = require('multiblob')
4
5function desigil (hash) {
6 return isBlob(hash) ? hash.substring(1) : hash
7}
8
9function resigil (hash) {
10 return isBlob(hash) ? hash : '&'+hash
11}
12
13module.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