no deprecation on 10

This commit is contained in:
Mathias Buus 2018-04-26 13:36:36 +02:00
parent d38b9661d2
commit 01aa7ef5d1
3 changed files with 10 additions and 10 deletions

View file

@ -1,3 +1,6 @@
var toBuffer = require('to-buffer')
var alloc = require('buffer-alloc')
var ZEROS = '0000000000000000000' var ZEROS = '0000000000000000000'
var SEVENS = '7777777777777777777' var SEVENS = '7777777777777777777'
var ZERO_OFFSET = '0'.charCodeAt(0) var ZERO_OFFSET = '0'.charCodeAt(0)
@ -71,12 +74,6 @@ var toTypeflag = function (flag) {
return 0 return 0
} }
var alloc = function (size) {
var buf = new Buffer(size)
buf.fill(0)
return buf
}
var indexOf = function (block, num, offset, end) { var indexOf = function (block, num, offset, end) {
for (; offset < end; offset++) { for (; offset < end; offset++) {
if (block[offset] === num) return offset if (block[offset] === num) return offset
@ -175,7 +172,7 @@ exports.encodePax = function (opts) { // TODO: encode more stuff in pax
result += addLength(' ' + key + '=' + pax[key] + '\n') result += addLength(' ' + key + '=' + pax[key] + '\n')
} }
} }
return new Buffer(result) return toBuffer(result)
} }
exports.decodePax = function (buf) { exports.decodePax = function (buf) {

View file

@ -1,6 +1,8 @@
var constants = require('constants') var constants = require('constants')
var eos = require('end-of-stream') var eos = require('end-of-stream')
var util = require('util') var util = require('util')
var alloc = require('buffer-alloc')
var toBuffer = require('to-buffer')
var Readable = require('readable-stream').Readable var Readable = require('readable-stream').Readable
var Writable = require('readable-stream').Writable var Writable = require('readable-stream').Writable
@ -11,8 +13,7 @@ var headers = require('./headers')
var DMODE = parseInt('755', 8) var DMODE = parseInt('755', 8)
var FMODE = parseInt('644', 8) var FMODE = parseInt('644', 8)
var END_OF_TAR = new Buffer(1024) var END_OF_TAR = alloc(1024)
END_OF_TAR.fill(0)
var noop = function () {} var noop = function () {}
@ -124,7 +125,7 @@ Pack.prototype.entry = function (header, buffer, callback) {
if (!header.gid) header.gid = 0 if (!header.gid) header.gid = 0
if (!header.mtime) header.mtime = new Date() if (!header.mtime) header.mtime = new Date()
if (typeof buffer === 'string') buffer = new Buffer(buffer) if (typeof buffer === 'string') buffer = toBuffer(buffer)
if (Buffer.isBuffer(buffer)) { if (Buffer.isBuffer(buffer)) {
header.size = buffer.length header.size = buffer.length
this._encode(header) this._encode(header)

View file

@ -8,8 +8,10 @@
}, },
"dependencies": { "dependencies": {
"bl": "^1.0.0", "bl": "^1.0.0",
"buffer-alloc": "^1.1.0",
"end-of-stream": "^1.0.0", "end-of-stream": "^1.0.0",
"readable-stream": "^2.0.0", "readable-stream": "^2.0.0",
"to-buffer": "^1.1.0",
"xtend": "^4.0.0" "xtend": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {