Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tar

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tar - npm Package Compare versions

Comparing version 0.1.17 to 0.1.18

4

lib/buffer-entry.js

@@ -23,2 +23,4 @@ // just like the Entry class, but it buffers the contents

inherits(BufferEntry, Entry)
// collect the bytes as they come in.

@@ -30,3 +32,1 @@ BufferEntry.prototype.write = function (c) {

}
inherits(BufferEntry, Entry)

@@ -48,166 +48,167 @@ // A passthrough read/write stream that sets its properties

inherits(Entry, Stream,
{ write: function (c) {
if (this._ending) this.error("write() after end()", null, true)
if (this._remaining === 0) {
this.error("invalid bytes past eof")
}
inherits(Entry, Stream)
// often we'll get a bunch of \0 at the end of the last write,
// since chunks will always be 512 bytes when reading a tarball.
if (c.length > this._remaining) {
c = c.slice(0, this._remaining)
}
this._remaining -= c.length
Entry.prototype.write = function (c) {
if (this._ending) this.error("write() after end()", null, true)
if (this._remaining === 0) {
this.error("invalid bytes past eof")
}
// put it on the stack.
var ql = this._queueLen
this._queue.push(c)
this._queueLen ++
// often we'll get a bunch of \0 at the end of the last write,
// since chunks will always be 512 bytes when reading a tarball.
if (c.length > this._remaining) {
c = c.slice(0, this._remaining)
}
this._remaining -= c.length
this._read()
// put it on the stack.
var ql = this._queueLen
this._queue.push(c)
this._queueLen ++
// either paused, or buffered
if (this._paused || ql > 0) {
this._needDrain = true
return false
}
this._read()
return true
// either paused, or buffered
if (this._paused || ql > 0) {
this._needDrain = true
return false
}
, end: function (c) {
if (c) this.write(c)
this._ending = true
this._read()
}
return true
}
, pause: function () {
this._paused = true
this.emit("pause")
}
Entry.prototype.end = function (c) {
if (c) this.write(c)
this._ending = true
this._read()
}
, resume: function () {
// console.error(" Tar Entry resume", this.path)
this.emit("resume")
this._paused = false
this._read()
return this._queueLen - this._index > 1
}
Entry.prototype.pause = function () {
this._paused = true
this.emit("pause")
}
Entry.prototype.resume = function () {
// console.error(" Tar Entry resume", this.path)
this.emit("resume")
this._paused = false
this._read()
return this._queueLen - this._index > 1
}
// This is bound to the instance
, _read: function () {
// console.error(" Tar Entry _read", this.path)
Entry.prototype._read = function () {
// console.error(" Tar Entry _read", this.path)
if (this._paused || this._reading || this._ended) return
if (this._paused || this._reading || this._ended) return
// set this flag so that event handlers don't inadvertently
// get multiple _read() calls running.
this._reading = true
// set this flag so that event handlers don't inadvertently
// get multiple _read() calls running.
this._reading = true
// have any data to emit?
while (this._index < this._queueLen && !this._paused) {
var chunk = this._queue[this._index ++]
this.emit("data", chunk)
}
// have any data to emit?
while (this._index < this._queueLen && !this._paused) {
var chunk = this._queue[this._index ++]
this.emit("data", chunk)
}
// check if we're drained
if (this._index >= this._queueLen) {
this._queue.length = this._queueLen = this._index = 0
if (this._needDrain) {
this._needDrain = false
this.emit("drain")
}
if (this._ending) {
this._ended = true
this.emit("end")
}
// check if we're drained
if (this._index >= this._queueLen) {
this._queue.length = this._queueLen = this._index = 0
if (this._needDrain) {
this._needDrain = false
this.emit("drain")
}
// if the queue gets too big, then pluck off whatever we can.
// this should be fairly rare.
var mql = this._maxQueueLen
if (this._queueLen > mql && this._index > 0) {
mql = Math.min(this._index, mql)
this._index -= mql
this._queueLen -= mql
this._queue = this._queue.slice(mql)
if (this._ending) {
this._ended = true
this.emit("end")
}
}
this._reading = false
// if the queue gets too big, then pluck off whatever we can.
// this should be fairly rare.
var mql = this._maxQueueLen
if (this._queueLen > mql && this._index > 0) {
mql = Math.min(this._index, mql)
this._index -= mql
this._queueLen -= mql
this._queue = this._queue.slice(mql)
}
, _setProps: function () {
// props = extended->global->header->{}
var header = this._header
, extended = this._extended
, global = this._global
, props = this.props
this._reading = false
}
// first get the values from the normal header.
var fields = tar.fields
for (var f = 0; fields[f] !== null; f ++) {
var field = fields[f]
, val = header[field]
if (typeof val !== "undefined") props[field] = val
}
Entry.prototype._setProps = function () {
// props = extended->global->header->{}
var header = this._header
, extended = this._extended
, global = this._global
, props = this.props
// next, the global header for this file.
// numeric values, etc, will have already been parsed.
;[global, extended].forEach(function (p) {
Object.keys(p).forEach(function (f) {
if (typeof p[f] !== "undefined") props[f] = p[f]
})
})
// first get the values from the normal header.
var fields = tar.fields
for (var f = 0; fields[f] !== null; f ++) {
var field = fields[f]
, val = header[field]
if (typeof val !== "undefined") props[field] = val
}
// no nulls allowed in path or linkpath
;["path", "linkpath"].forEach(function (p) {
if (props.hasOwnProperty(p)) {
props[p] = props[p].split("\0")[0]
}
// next, the global header for this file.
// numeric values, etc, will have already been parsed.
;[global, extended].forEach(function (p) {
Object.keys(p).forEach(function (f) {
if (typeof p[f] !== "undefined") props[f] = p[f]
})
})
// no nulls allowed in path or linkpath
;["path", "linkpath"].forEach(function (p) {
if (props.hasOwnProperty(p)) {
props[p] = props[p].split("\0")[0]
}
})
// set date fields to be a proper date
;["mtime", "ctime", "atime"].forEach(function (p) {
if (props.hasOwnProperty(p)) {
props[p] = new Date(props[p] * 1000)
}
})
// set the type so that we know what kind of file to create
var type
switch (tar.types[props.type]) {
case "OldFile":
case "ContiguousFile":
type = "File"
break
// set date fields to be a proper date
;["mtime", "ctime", "atime"].forEach(function (p) {
if (props.hasOwnProperty(p)) {
props[p] = new Date(props[p] * 1000)
}
})
case "GNUDumpDir":
type = "Directory"
break
// set the type so that we know what kind of file to create
var type
switch (tar.types[props.type]) {
case "OldFile":
case "ContiguousFile":
type = "File"
break
case undefined:
type = "Unknown"
break
case "GNUDumpDir":
type = "Directory"
break
case "Link":
case "SymbolicLink":
case "CharacterDevice":
case "BlockDevice":
case "Directory":
case "FIFO":
default:
type = tar.types[props.type]
}
case undefined:
type = "Unknown"
break
this.type = type
this.path = props.path
this.size = props.size
case "Link":
case "SymbolicLink":
case "CharacterDevice":
case "BlockDevice":
case "Directory":
case "FIFO":
default:
type = tar.types[props.type]
}
// size is special, since it signals when the file needs to end.
this._remaining = props.size
}
, warn: fstream.warn
, error: fstream.error
})
this.type = type
this.path = props.path
this.size = props.size
// size is special, since it signals when the file needs to end.
this._remaining = props.size
}
Entry.prototype.warn = fstream.warn
Entry.prototype.error = fstream.error

@@ -11,3 +11,2 @@

, path = require("path")
, inherits = require("inherits")
, TarHeader = require("./header.js")

@@ -14,0 +13,0 @@

@@ -33,3 +33,4 @@ // An Entry consisting of:

inherits(ExtendedHeader, Entry, { _parse: parse })
inherits(ExtendedHeader, Entry)
ExtendedHeader.prototype._parse = parse

@@ -36,0 +37,0 @@ var s = 0

@@ -5,3 +5,3 @@ {

"description": "tar for node",
"version": "0.1.17",
"version": "0.1.18",
"repository": {

@@ -16,3 +16,3 @@ "type": "git",

"dependencies": {
"inherits": "1.x",
"inherits": "2",
"block-stream": "*",

@@ -19,0 +19,0 @@ "fstream": "~0.1.8"

@@ -10,24 +10,21 @@ # node-tar

At least, this includes every version of:
At least, this includes every version of:
* bsdtar
* gnutar
* solaris posix tar
* Joerg Schilling's star ("Schilly tar")
* bsdtar
* gnutar
* solaris posix tar
* Joerg Schilling's star ("Schilly tar")
2. Create tar files that can be extracted by any of the following tar
programs:
2. Create tar files that can be extracted by any of the following tar programs:
* bsdtar/libarchive version 2.6.2
* gnutar 1.15 and above
* SunOS Posix tar
* Joerg Schilling's star ("Schilly tar")
* bsdtar/libarchive version 2.6.2
* gnutar 1.15 and above
* SunOS Posix tar
* Joerg Schilling's star ("Schilly tar")
3. 100% test coverage. Speed is important. Correctness is slightly
more important.
3. 100% test coverage. Speed is important. Correctness is slightly more important.
4. Create the kind of tar interface that Node users would want to use.
5. Satisfy npm's needs for a portable tar implementation with a
JavaScript interface.
5. Satisfy npm's needs for a portable tar implementation with a JavaScript interface.

@@ -34,0 +31,0 @@ 6. No excuses. No complaining. No tolerance for failure.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc