I want to give to your attention the library
Vow , which was written by my colleague Dmitry Filatov
dfilatov .
The library implements
Promises / A + , works very quickly and requires a small amount of memory. According to performance tests, it is much ahead of
Q , but at the same time it maintains an asynchronous manner of work.
Working with
Vow looks as easy as working with
Q. Among the shortcomings (compared to
Q ), we can only single out the lack of
progress .
')
Sample code using
Vow :
function readFile(filename, encoding) { var promise = Vow.promise(); fs.readFile(filename, encoding, function(err, data) { if (err) return promise.reject(err); promise.fulfill(data); }); return promise; } Vow.all([readFile('test1.txt', 'utf8'), readFile('test2.txt', 'utf8')]).then(function(results) { console.log(results.join('\n')); });
A benchmark that reflects how much
Q is a slow library (creation of consecutive promises is being tested):
| time | operations per second |
---|
Q | 54.891ms | 18 |
When | 3.484ms | 287 |
Vow | 1.158ms | 864 |
Also for Vow the library of work with the file system is implemented:
vow-fs :
https://github.com/dfilatov/vow-fs .
NPM Package:
vowRepository:
https://github.com/dfilatov/jspromise