gulpjs / bach Goto Github PK
View Code? Open in Web Editor NEWCompose your async functions with elegance.
License: MIT License
Compose your async functions with elegance.
License: MIT License
Use jscs-preset-gulp
On bach's coveralls, there is no master
branch - so the badge will link to an unknown branch. You may have to sync the branches in coveralls to get a correct badge again.
If we can find frozen modules that are battle tested to replace them, we should probably switch.
The code in master uses now-and-later
where one can pass either an array or an object with functions to execute but it seems that there is no way to pass an object down to now-and-later.
If I understand your intentions correctly passing objects was a way to "name" anonymous functions so if someone uses tasks being anonymous functions in Gulp4 they would still get meaningful timing info. I was imagining that orchestrator would build an objects with functions to execute, "naming" those functions using task names, function names or a generated id (as the last resort). If so we need to find a way of passing down an object with those functions through bach.
Just to make the discussion more concrete, here is the use-case I'm having on my mind:
gulp = require('gulp4');
gulp.task(function foo(done) {...});
gulp.task('bar', function (done) {...});
var baz = function (done) {...});
gulp.task('default', ['foo', 'bar', baz]);
For the foo
function we can easily get a name / key from the function name itself, for bar
we don't have it so would use a task name and for baz
we've got nothing so would have to generate a key.
Now, those names / ids are important to properly report timing / duration of each task and I was under the impression that this is what an object-as-argument was introduced in now-and-later. If so we need to find a way of passing this info down to now-and-later. Honestly I'm not sure what would be a nice API here, something like this maybe, perhaps: bach.parallel(foo, {bar: bar})
? Or bach.parallel({foo: foo, bar: bar})
?
I must admit that I'm still not at ease with new layering so I might be talking rubbish here. In any case the functional use-case I'm after here is timing tasks in Gulp4. Thoughts?
To the each function? Actually it would be same for all in stack.
function fn1 (cb) {
assert.equal(this.hello, 'world')
this.foo = 'foo'
cb(null, 1)
}
function fn2 (cb) {
assert.equal(this.foo, 'foo')
assert.equal(this.hello, 'world')
this.bar = 'bar'
cb(null, 2)
}
function fn3 (cb) {
assert.equal(this.bar, 'bar')
assert.equal(this.hello, 'world')
cb(null, 3)
}
var seriesDone = bach.series(fn1, fn2, fn3)
seriesDone({hello: 'world'}, function (err, res) {
console.log(res)
//=> [1, 2, 3]
})
like middleware/plugin stack
If you have a sync
function and an async
function, and pass the sync
function to .series
first, then execution finishes before the async
function is finished:
var bach = require('bach');
function sync () {
console.log('sync function');
}
function async (done) {
console.log('async function');
done(null, 'async done');
}
var fn = bach.series(sync, async);
fn(function (err, msg) {
console.log(msg);
});
This could be handled in async-done
by checking the function length (like was done in orchestrator), but I don't know if that's how you're intending async-done
to be used, so I opened the issue here.
This double entendre opportunity seems too good to pass up!
Referencing: #28
Replacing lodash modules with arr-map will remove support for iterating over objects. The current tests do not test with objects, only arrays.
I want to cleanup the jshint and add a linting task in the project. Probably not a good idea to depend on gulp to lint.
The docs mention that settle{Series,Parallel} can be accessed on the bach object, but AFAIK they are only accessible via require("bach/settle"). Perhaps you should update the docs about this.
To bring inline with gulp repos. Use eslint-config-gulp and update code style
In package.json, readme, etc
I want all the gulp4 repos to have the same structure in package.json. It also needs things like engine that specifies we only work in node 0.10
Docs are out of sync with the newest now-and-later. Need to update.
API change but I think we can keep using it the same
Passing a non-function (ex. undefined) to series / parallel results in an "obscure" error from underlying libraries. Arguments supplied to parallel / series should probably be verified and an explicit error should be thrown if any of the arguments is not a function.
Happy to send a PR if this makes sense.
The ": Function" notation used in the API Documentation is unclear.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.