Skip to content

Async vs Sync Task creation #4

@thejmazz

Description

@thejmazz
  • duplexify with async globby and set read/write stream later - didnt convert globby to promise yet, but tested async with setTimeout

Failed all test cases when I switched task from being a sync function to a co.wrap(function * (){ .. }) - which returns a promise, but is nice because yielding promises is nice.

Before:

const task = Task(...)
isStream(task) // true

after:

const task = Task(...)
task.then((stream) => isStream(stream) /* true */ )

The reason it became async is for globby - I am checking the filesystem to see which files exist that match patterns in input and output. This may become negligible as tasks become able to pass values to each other. However, perhaps the performance impact of globby.sync will not be negligible when running many tasks, or tasks that have many files.

For now, I am just going to use globby.sync. As well, glob-stream may be worth a try - will still be async but perhaps glob-stream can be piped into the main Task stream.

At some point, Task may need to have a stream that wraps a stream. So that you can stream in input object into, and stream out an output info object on a .end after the .end/.push(null) of the inner stream.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions