Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new streamline file extensions

  • Loading branch information...
commit 31067b8c5567c78382066c9cd76d4ed4efe0ab9b 1 parent 47afd7b
@bjouhier bjouhier authored
Showing with 41 additions and 36 deletions.
  1. +4 −32 API.md
  2. +3 −4 janzip/janzip.js
  3. +34 −0 janzip/janzip.md
View
36 API.md
@@ -1,34 +1,6 @@
+# node-native-zip
-# node-native-zip module
-
-Simple API to create a zip archive. No external dependencies (except streamline.js).
-
-* `archive = new zip.Zip(outStream[, options])`
- Creates a zip archive.
- Uses _deflate_ compression by default. You can override this by passing
- `options = { zipMethod: zip.store }`
- `options.filter`: optional function to filter the contents of directories.
- Called as `filter(_, filename, parentEntry)`.
- `options.transform`: optional function to transform the contents of files.
- Called as `transform(_, contents, entry)` where `contents` is a buffer (not a string).
-
-* `archive.add(_, entry)`
- Adds an entry to the archive.
- If the entry is `{ name: "...", path: "..." }`,
- the `path` file or directory (and all its contents) is added to the archive.
- If the entry is `{ name: "...", data: "..." }`,
- the `data` buffer is added to the archive.
- You may also specify a `date` in the entry.
- You can also pass an array of entries instead of a single entry.
- Returns `this` for chaining
-
-* `archive.finish(_)`
- Writes the trailer at the end of the archive.
- Returns `this` for chaining.
-
-* `zipMethod: zip.store`
- _store_ method (no compression)
-
-* `zipMethod: zip.deflate`
- _deflate_ method (standard compression)
+A ZIP library without external dependencies
+* [streamline-zip/janzip/janzip](janzip/janzip.md)
+ node-native-zip module
View
7 janzip/janzip.js
@@ -7,7 +7,6 @@
*/
"use strict";
if (!require('streamline/module')(module)) return;
-var flows = require('streamline/lib/util/flows');
var streams = require('streamline/lib/streams/server/streams');
var RollingBuffer = require("./rollingbuffer");
@@ -133,12 +132,12 @@ exports.Zip = function(outStream, options) {
///
this.add = function(_, entry) {
if (Array.isArray(entry)) {
- flows.each(_, entry, this.add.bind(this));
+ entry.forEach_(_, this.add.bind(this));
} else {
if (entry.data == null) {
var stat = fs.stat(entry.path, _);
if (stat.isDirectory()) {
- flows.each(_, fs.readdir(entry.path, _), function(_, n) {
+ fs.readdir(entry.path, _).forEach_(_, function(_, n) {
if (options.filter && !options.filter(_, n, entry)) return;
this.add(_, {
name: entry.name ? entry.name + "/" + n : n,
@@ -172,7 +171,7 @@ exports.Zip = function(outStream, options) {
this.finish = function(_) {
var totalFileLength = fileOffset;
- flows.each(_, dirBuffers, function(_, b) {
+ dirBuffers.forEach_(_, function(_, b) {
os.write(_, b);
});
View
34 janzip/janzip.md
@@ -0,0 +1,34 @@
+
+# node-native-zip module
+
+Simple API to create a zip archive. No external dependencies (except streamline.js).
+
+* `archive = new zip.Zip(outStream[, options])`
+ Creates a zip archive.
+ Uses _deflate_ compression by default. You can override this by passing
+ `options = { zipMethod: zip.store }`
+ `options.filter`: optional function to filter the contents of directories.
+ Called as `filter(_, filename, parentEntry)`.
+ `options.transform`: optional function to transform the contents of files.
+ Called as `transform(_, contents, entry)` where `contents` is a buffer (not a string).
+
+* `archive.add(_, entry)`
+ Adds an entry to the archive.
+ If the entry is `{ name: "...", path: "..." }`,
+ the `path` file or directory (and all its contents) is added to the archive.
+ If the entry is `{ name: "...", data: "..." }`,
+ the `data` buffer is added to the archive.
+ You may also specify a `date` in the entry.
+ You can also pass an array of entries instead of a single entry.
+ Returns `this` for chaining
+
+* `archive.finish(_)`
+ Writes the trailer at the end of the archive.
+ Returns `this` for chaining.
+
+* `zipMethod: zip.store`
+ _store_ method (no compression)
+
+* `zipMethod: zip.deflate`
+ _deflate_ method (standard compression)
+
Please sign in to comment.
Something went wrong with that request. Please try again.