git ssb

3+

cel / ssb-npm-registry



Commit d5f4acee1403676fc69209710977d0bc98c2e71d

Avoid deprecated Buffer constructor

cel committed on 5/17/2020, 11:40:58 PM
Parent: 4f27567900a7b5b821bccc74e95bfc96c8233159

Files changed

bootstrap/bin.jschanged
index.jschanged
bootstrap/bin.jsView
@@ -179,9 +179,9 @@
179179
180180 function idToBuf(id) {
181181 var m = blobIdRegex.exec(id)
182182 if (!m) return null
183- return new Buffer(m[1], 'base64')
183 + return Buffer.from(m[1], 'base64')
184184 }
185185
186186 function blobFilename(buf) {
187187 if (!buf) return null
@@ -325,9 +325,9 @@
325325 })
326326 })
327327 req.removeListener('error', cb)
328328 function gotMsg(value, cb) {
329- var encoded = new Buffer(JSON.stringify(value, null, 2), 'binary')
329 + var encoded = Buffer.from(JSON.stringify(value, null, 2), 'binary')
330330 var hash = crypto.createHash('sha256').update(encoded).digest('base64')
331331 var id1 = '%' + hash + '.sha256'
332332 if (id !== id1) return cb(new Error('mismatched hash ' + id + ' ' + id1))
333333 cb(null, value)
index.jsView
@@ -23,9 +23,9 @@
2323 }
2424
2525 function idToHex(id) {
2626 var b64 = String(id).replace(/^[%#&]|\.[a-z0-9]*$/g, '')
27- return new Buffer(b64, 'base64').toString('hex')
27 + return Buffer.from(b64, 'base64').toString('hex')
2828 }
2929
3030 function onceify(fn, self) {
3131 var cbs = [], err, data
@@ -780,9 +780,9 @@
780780 catch (e) {}
781781 if (self.req.headers['if-none-match'] === id) return self.respondRaw(304)
782782 self.server.getMsg(id, function (err, msg) {
783783 if (err) return self.respondError(500, err.message || err)
784- var out = new Buffer(JSON.stringify(msg, null, 2), 'utf8')
784 + var out = Buffer.from(JSON.stringify(msg, null, 2), 'utf8')
785785 self.res.writeHead(200, {
786786 'Content-Type': 'application/json',
787787 'Cache-Control': 'public, max-age=315360000',
788788 'Content-Length': out.length,
@@ -1008,9 +1008,9 @@
10081008 var links = {/* <name>-<version>.tgz: {link: <BlobId>, size: number} */}
10091009 var done = multicb()
10101010 function addAttachmentAsBlob(filename, cb) {
10111011 var data = attachments[filename].data
1012- var tarball = new Buffer(data, 'base64')
1012 + var tarball = Buffer.from(data, 'base64')
10131013 var length = attachments[filename].length
10141014 if (length && length !== tarball.length) return self.respondError(400,
10151015 'Length mismatch for attachment \'' + filename + '\'')
10161016 self.server.sbot.blobs.add(function (err, id) {

Built with git-ssb-web