Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the function to work with Multiple files #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Added the function to work with Multiple files #4

wants to merge 6 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 14, 2012

You can go to the examples and run node test_multi.js

I am going to make the recursive version of the call next.

Let me know if there are any conventions I should follow in terms of the way it is coded (If tabs bother you feel free to change that :{P or if you have any other suggestions.

@rubenv
Copy link
Owner

rubenv commented Feb 21, 2012

Will review this in depth soon, but I'm very overloaded with work right now. Stay tuned.

@ghost
Copy link
Author

ghost commented Feb 22, 2012

Hey,

I agree about the libraries. I don't think I even use spo here at all that wandered in from a different branch I have going. It's my function dumping ground.

What is in spo that is useful is a function to dump a directory to Json for zipping folders( Arguably it even works ). That is something that can just be in the zipper source directly. Don't waste your time with that. When I do the zip folder part I'll share that separately.

Async.js is pretty peer reviewed.

x++;
}

async.series(calls,callback);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use forEachSeries? This makes doing this a lot cleaner. That way you don't have to build an array with function calls, but can apply a function for each item in an array.

This is what I came up on my own. It is Coffeescript, but very easy to write in Javascript, too:

iterator = (item, callback) =>
  console.log "Adding file", item.filename, item.path
  zip.addFile item.path, item.filename, (err) ->
    console.log "Done adding", item.filename
    callback(err)

async.forEachSeries files, iterator, (err) =>
  console.log "Done creating zip file"
  callback(null)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants