zip-stream
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -12,5 +12,6 @@ /** | ||
var loDefaults = require('lodash.defaults'); | ||
var util = module.exports = {}; | ||
util.defaults = require('lodash.defaults'); | ||
util.crc32 = require('./crc32'); | ||
@@ -32,2 +33,10 @@ | ||
// this is slightly different from lodash version | ||
util.defaults = function(object, source, guard) { | ||
var args = arguments; | ||
args[0] = args[0] || {}; | ||
return loDefaults.apply(null, args); | ||
}; | ||
util.dosDateTime = function(d, utc) { | ||
@@ -60,5 +69,9 @@ d = (d instanceof Date) ? d : util.dateify(d); | ||
util.sanitizeFilePath = function(filepath) { | ||
filepath = util.unixifyPath(filepath || ''); | ||
util.sanitizePath = function() { | ||
var filepath = util.unixifyPath.apply(util, arguments); | ||
if (filepath === '.') { | ||
filepath = ''; | ||
} | ||
while (filepath.substring(0, 1) === '/') { | ||
@@ -65,0 +78,0 @@ filepath = filepath.substring(1); |
@@ -18,2 +18,6 @@ /** | ||
var ZipStream = module.exports = function(options) { | ||
if (!(this instanceof ZipStream)) { | ||
return new ZipStream(opts); | ||
} | ||
options = this.options = util.defaults(options, { | ||
@@ -81,5 +85,5 @@ comment: '', | ||
var processStream = self._newProcessStream(file.store); | ||
processStream.on('error', callback); | ||
processStream.once('error', callback); | ||
processStream.on('end', function() { | ||
processStream.once('end', function() { | ||
file.crc32 = processStream.digest; | ||
@@ -115,5 +119,5 @@ file.uncompressedSize = processStream.rawSize; | ||
var processStream = self._newProcessStream(file.store); | ||
processStream.on('error', callback); | ||
processStream.once('error', callback); | ||
processStream.on('end', function() { | ||
processStream.once('end', function() { | ||
file.crc32 = processStream.digest; | ||
@@ -152,3 +156,3 @@ file.uncompressedSize = processStream.rawSize; | ||
type: 'file', | ||
name: null, | ||
name: '', | ||
date: null, | ||
@@ -159,3 +163,3 @@ store: false, | ||
data.name = util.sanitizeFilePath(data.name); | ||
data.name = util.sanitizePath(data.name); | ||
@@ -162,0 +166,0 @@ if (typeof data.lastModifiedDate !== 'number') { |
{ | ||
"name": "zip-stream", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "a streaming zip generator.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-zip-stream", |
@@ -1,2 +0,2 @@ | ||
# zip-stream v0.1.0 [![Build Status](https://secure.travis-ci.org/ctalkington/node-zip-stream.png?branch=master)](http://travis-ci.org/ctalkington/node-zip-stream) | ||
# zip-stream v0.1.1 [![Build Status](https://secure.travis-ci.org/ctalkington/node-zip-stream.png?branch=master)](http://travis-ci.org/ctalkington/node-zip-stream) | ||
@@ -3,0 +3,0 @@ zip-stream is a streaming zip generator. It was built to be a successor to [zipstream](https://npmjs.org/package/zipstream). Dependencies are kept to a minimum through the use of many of node's built-in modules including the use of zlib module for compression. |
@@ -9,2 +9,16 @@ var crypto = require('crypto'); | ||
function adjustDateByOffset(d, offset) { | ||
d = d instanceof Date || new Date(); | ||
if (offset >= 1) { | ||
d.setMinutes(d.getMinutes() - offset); | ||
} else { | ||
d.setMinutes(d.getMinutes() + Math.abs(offset)); | ||
} | ||
return d; | ||
} | ||
module.exports.adjustDateByOffset = adjustDateByOffset; | ||
function binaryBuffer(n) { | ||
@@ -22,2 +36,33 @@ var buffer = new Buffer(n); | ||
function BinaryStream(size, options) { | ||
Readable.call(this, options); | ||
var buf = new Buffer(size); | ||
for (var i = 0; i < size; i++) { | ||
buf.writeUInt8(i&255, i); | ||
} | ||
this.push(buf); | ||
this.push(null); | ||
} | ||
inherits(BinaryStream, Readable); | ||
BinaryStream.prototype._read = function(size) {}; | ||
module.exports.BinaryStream = BinaryStream; | ||
function DeadEndStream(options) { | ||
Writable.call(this, options); | ||
} | ||
inherits(DeadEndStream, Writable); | ||
DeadEndStream.prototype._write = function(chuck, encoding, callback) { | ||
callback(); | ||
}; | ||
module.exports.DeadEndStream = DeadEndStream; | ||
function WriteHashStream(path, options) { | ||
@@ -24,0 +69,0 @@ fs.WriteStream.call(this, path, options); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
58268
28
1023
0
5