Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Oct 15, 2015
1 parent afd4441 commit f8215bc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
40 changes: 20 additions & 20 deletions extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,38 @@ var headers = require('./headers')
var Writable = require('readable-stream').Writable
var PassThrough = require('readable-stream').PassThrough

var noop = function() {}
var noop = function () {}

var overflow = function(size) {
var overflow = function (size) {
size &= 511
return size && 512 - size
}

var emptyStream = function(self, offset) {
var emptyStream = function (self, offset) {
var s = new Source(self, offset)
s.end()
return s
}

var mixinPax = function(header, pax) {
var mixinPax = function (header, pax) {
if (pax.path) header.name = pax.path
if (pax.linkpath) header.linkname = pax.linkpath
return header
}

var Source = function(self, offset) {
var Source = function (self, offset) {
this._parent = self
this.offset = offset
PassThrough.call(this)
}

util.inherits(Source, PassThrough)

Source.prototype.destroy = function(err) {
Source.prototype.destroy = function (err) {
this._parent.destroy(err)
}

var Extract = function(opts) {
var Extract = function (opts) {
if (!(this instanceof Extract)) return new Extract(opts)
Writable.call(this, opts)

Expand All @@ -59,60 +59,60 @@ var Extract = function(opts) {
var self = this
var b = self._buffer

var oncontinue = function() {
var oncontinue = function () {
self._continue()
}

var onunlock = function(err) {
var onunlock = function (err) {
self._locked = false
if (err) return self.destroy(err)
if (!self._stream) oncontinue()
}

var onstreamend = function() {
var onstreamend = function () {
self._stream = null
var drain = overflow(self._header.size)
if (drain) self._parse(drain, ondrain)
else self._parse(512, onheader)
if (!self._locked) oncontinue()
}

var ondrain = function() {
var ondrain = function () {
self._buffer.consume(overflow(self._header.size))
self._parse(512, onheader)
oncontinue()
}

var onpaxglobalheader = function() {
var onpaxglobalheader = function () {
var size = self._header.size
self._paxGlobal = headers.decodePax(b.slice(0, size))
b.consume(size)
onstreamend()
}

var onpaxheader = function() {
var onpaxheader = function () {
var size = self._header.size
self._pax = headers.decodePax(b.slice(0, size))
if (self._paxGlobal) self._pax = xtend(self._paxGlobal, self._pax)
b.consume(size)
onstreamend()
}

var ongnulongpath = function() {
var ongnulongpath = function () {
var size = self._header.size
this._gnuLongPath = headers.decodeLongPath(b.slice(0, size))
b.consume(size)
onstreamend()
}

var ongnulonglinkpath = function() {
var ongnulonglinkpath = function () {
var size = self._header.size
this._gnuLongLinkPath = headers.decodeLongPath(b.slice(0, size))
b.consume(size)
onstreamend()
}

var onheader = function() {
var onheader = function () {
var offset = self._offset
var header
try {
Expand Down Expand Up @@ -183,7 +183,7 @@ var Extract = function(opts) {

util.inherits(Extract, Writable)

Extract.prototype.destroy = function(err) {
Extract.prototype.destroy = function (err) {
if (this._destroyed) return
this._destroyed = true

Expand All @@ -192,22 +192,22 @@ Extract.prototype.destroy = function(err) {
if (this._stream) this._stream.emit('close')
}

Extract.prototype._parse = function(size, onparse) {
Extract.prototype._parse = function (size, onparse) {
if (this._destroyed) return
this._offset += size
this._missing = size
this._onparse = onparse
}

Extract.prototype._continue = function(err) {
Extract.prototype._continue = function () {
if (this._destroyed) return
var cb = this._cb
this._cb = noop
if (this._overflow) this._write(this._overflow, undefined, cb)
else cb()
}

Extract.prototype._write = function(data, enc, cb) {
Extract.prototype._write = function (data, enc, cb) {
if (this._destroyed) return

var s = this._stream
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
exports.extract = require('./extract')
exports.pack = require('./pack')
exports.pack = require('./pack')
2 changes: 1 addition & 1 deletion test/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ exports.UNICODE_TAR = path.join(__dirname, 'unicode.tar')
exports.NAME_IS_100_TAR = path.join(__dirname, 'name-is-100.tar')
exports.INVALID_TGZ = path.join(__dirname, 'invalid.tgz')
exports.SPACE_TAR_GZ = path.join(__dirname, 'space.tar')
exports.GNU_LONG_PATH = path.join(__dirname, 'gnu-long-path.tar')
exports.GNU_LONG_PATH = path.join(__dirname, 'gnu-long-path.tar')
2 changes: 1 addition & 1 deletion test/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ test('unicode', function(t) {
t.equal(data.length & 511, 0)
t.deepEqual(data, fs.readFileSync(fixtures.UNICODE_TAR))
}))
})
})

0 comments on commit f8215bc

Please sign in to comment.