New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

concurrent

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concurrent - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

@@ -5,4 +5,4 @@ var Future = require('./future');

/**
* Iterates over the collection an fulfills with the number iterated over
*
* Iterates over the collection an fulfills with the array
*
* @param {Array} arr The array to iterate over

@@ -9,0 +9,0 @@ * @param {Function} iterator The function to be called each time

@@ -17,3 +17,3 @@ var Promise = require('./promise');

* Checks if the future is completed
*
*
* @return {Boolean} Whether or not the future is completed

@@ -27,3 +27,3 @@ */

* Assigns one callback for both fulfill and reject
*
*
* @param {Function} callback The callback for both results

@@ -40,4 +40,28 @@ */

/**
* Converts a traditional style callback and resolves the future. If the future
* has more than one argument beyond err, it will return and array as the value.
*
* @return {Function} The callback for async
*/
Future.prototype.convert = function() {
var self = this;
return function() {
var args = Array.prototype.slice.call(arguments);
var err = args.shift();
if (err) {
return self.reject(err);
}
if (args.length === 1) {
args = args.shift();
}
return self.fulfill(args);
};
};
/**
* Returns a future that rejects after some time
*
*
* @param {Number} duration Number of milliseconds to reject at

@@ -48,3 +72,3 @@ * @return {Future} The instremented future

var future = new Future();
this.then(function(value) {

@@ -63,3 +87,3 @@ future.fulfill(value);

* Falls back to the result of the other future if this one fails
*
*
* @param {Promise} promise The promise to fallback to

@@ -84,3 +108,3 @@ * @return {Future} The future with the fallback value

* Filters the future by ensuring it matches the predicate
*
*
* @param {Function} predicate The predicate to test the value of the future

@@ -107,3 +131,3 @@ * @return {Future} The new future

* Creates a new future based on the map callback
*
*
* @param {Function} callback The callback on the successful value

@@ -118,3 +142,3 @@ * @return {Future} The new future

* Calls the callback on failure
*
*
* @param {Function} callback The callback to be called if the promise fails

@@ -128,3 +152,3 @@ */

* Calls the callback on success
*
*
* @param {Function} callback The callback to be called if the promise succeeds

@@ -138,3 +162,3 @@ */

* Recovers the future if it fails
*
*
* @param {Object} value The value to recover to

@@ -166,3 +190,3 @@ * @return {Future} The new future

* Takes two futures and zips their values as a tuple
*
*
* @param {Promise} promise The promise to be applied on the right of the tuple

@@ -169,0 +193,0 @@ * @return {Future} The new future which will fulfill with the tuple

@@ -6,4 +6,5 @@ /**

* @type {Function}
* @private
*/
var next = typeof setImmediate === 'function' ? setImmediate : process.nextTick;
module.exports = next;
{
"name": "concurrent",
"version": "0.0.6",
"version": "0.0.7",
"description": "Promises/A+ with Scala awesomeness",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -58,2 +58,47 @@ var chai = require('chai');

describe('#convert', function() {
it('should have convert', function() {
expect(future).to.have.property('convert');
});
it('should have reject on error', function(done) {
var async = function(callback) {
callback(ERROR);
};
async(future.convert());
future.then(null, function(reason) {
expect(reason).to.eql(ERROR);
done();
});
});
it('should fulfill with one value', function(done) {
var async = function(callback) {
callback(null, SUCCESS);
};
async(future.convert());
future.then(function(value) {
expect(value).to.eql(SUCCESS);
done();
});
});
it('should fulfill with multiple values', function(done) {
var async = function(callback) {
callback(null, LEFT, RIGHT);
};
async(future.convert());
future.then(function(value) {
expect(value).to.eql([LEFT, RIGHT]);
done();
});
});
});
describe('#ready', function() {

@@ -60,0 +105,0 @@ it('should have ready', function() {