git ssb

3+

Dominic / ssb-blobs



Tree: 383baf84a6679ed22590252fdf2983277df27db5

Files: 383baf84a6679ed22590252fdf2983277df27db5 / 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