-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: master
Are you sure you want to change the base?
Conversation
Will review this in depth soon, but I'm very overloaded with work right now. Stay tuned. |
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); |
There was a problem hiding this comment.
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)
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.