git ssb

0+

cel / pull-git-pack



Commit 2f9035b1c53d3c74c26141129b65b1bdce305b97

Avoid deprecated Buffer constructor

cel committed on 5/11/2020, 11:57:27 PM
Parent: 9056455fffb2b91e8cb5d58f1437a0495d284791

Files changed

index.jschanged
index.jsView
@@ -38,9 +38,9 @@
3838 var inflate = new pako.Inflate()
3939 var ended, dataOut
4040
4141 inflate.onData = function (data) {
42- dataOut = new Buffer(data)
42 + dataOut = Buffer.from(data)
4343 }
4444
4545 inflate.onEnd = function (status) {
4646 ended = (status === 0) ? true : new Error(inflate.strm.msg)
@@ -75,9 +75,9 @@
7575 var queue = []
7676 var ended
7777
7878 def.onData = function (data) {
79- queue.push([null, new Buffer(data)])
79 + queue.push([null, Buffer.from(data)])
8080 }
8181
8282 def.onEnd = function (status) {
8383 queue.push([(status === 0) ? true : new Error(def.strm.msg)])
@@ -132,9 +132,9 @@
132132
133133 function readHeader(cb) {
134134 readWord(null, function (end, header) {
135135 if (ended = end) return cb(end)
136- if (!header.equals(header, new Buffer('PACK')))
136 + if (!header.equals(header, Buffer.from('PACK')))
137137 read(new Error('Invalid packfile header'), error(cb))
138138 else
139139 readVersion(cb)
140140 })
@@ -443,18 +443,18 @@
443443 vals.push(b | 0x80)
444444 b = length & 0x7f
445445 }
446446 vals.push(b)
447- cb(null, new Buffer(vals))
447 + cb(null, Buffer.from(vals))
448448 }
449449
450450 function encodePack(opts, numObjects, readObject) {
451451 if (numObjects === undefined)
452452 numObjects = opts, opts = null
453453 if (readObject === undefined)
454454 return encodePack.bind(this, opts, numObjects)
455455
456- var header = new Buffer(12)
456 + var header = Buffer.alloc(12)
457457 header.write('PACK')
458458 header.writeUInt32BE(PACK_VERSION, 4)
459459 header.writeUInt32BE(numObjects, 8)
460460 var checksum = createHash('sha1')

Built with git-ssb-web