Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

q

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

q - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

test.js

4

CHANGES.md

@@ -11,2 +11,6 @@ <!-- vim:ts=4:sts=4:sw=4:et:tw=60 -->

0.7.2
- Fixed thenable promise assimilation.
0.7.1

@@ -13,0 +17,0 @@

7

package.json
{
"name": "q",
"version": "0.7.2",
"description": "A library for promises (CommonJS/Promises/A,B,D)",
"version": "0.7.1",
"homepage": "http://github.com/kriskowal/q/",

@@ -38,3 +38,3 @@ "author": "Kris Kowal <kris@cixar.com> (http://github.com/kriskowal/)",

"scripts": {
"prepublish": "uglifyjs -o q.min.js -nc q.js"
"test": "node test/all.js"
},

@@ -51,6 +51,3 @@ "overlay": {

"test": "./test"
},
"scripts": {
"test": "node test/all.js"
}
}

@@ -22,3 +22,3 @@ // vim:ts=4:sts=4:sw=4:

// micro-optmization for compression systems, permitting
// every occurrence of the "undefined" variable bo be
// every occurrence of the "undefined" variable to be
// replaced with a single-character.

@@ -268,2 +268,3 @@

"view", "viewInfo",
"timeout", "delay",
"end"

@@ -367,13 +368,5 @@ ],

if (object && typeof object.then === "function") {
return Promise({}, function fallback(op, rejected) {
if (op !== "when") {
return when(object, function (value) {
return ref(value).promiseSend.apply(undefined, arguments);
});
} else {
var result = defer();
object.then(result.resolve, result.reject);
return result.promise;
}
});
var result = defer();
object.then(result.resolve, result.reject);
return result.promise;
}

@@ -788,2 +781,25 @@ return Promise({

/**
*/
exports.timeout = timeout;
function timeout(promise, timeout) {
var deferred = defer();
when(promise, deferred.resolve, deferred.reject);
setTimeout(function () {
deferred.reject("Timed out");
}, timeout);
return deferred.promise;
}
/**
*/
exports.delay = delay;
function delay(promise, timeout) {
var deferred = defer();
setTimeout(function () {
deferred.resolve(promise);
}, timeout);
return deferred.promise;
}
/*

@@ -790,0 +806,0 @@ * In module systems that support ``module.exports`` assignment or exports

@@ -18,2 +18,6 @@

We have a [mailing list].
[mailing list]: https://groups.google.com/forum/#!forum/q-continuum
Q is designed to work well with jQuery, Dojo, and as part of an

@@ -20,0 +24,0 @@ ecosystem of NodeJS NPM packages, many of which also work in browsers,

var Q = require('../q');
exports['test assimilation'] = function (ASSERT, done) {
exports['test ref assimilation'] = function (ASSERT, done) {
Q.ref({
"then": function (resolved, rejected) {
resolved(10);
}
})
.then(function (value) {
ASSERT.equal(value, 10, 'thenable resolved');
return value + 10;
})
.then(function (value) {
ASSERT.equal(value, 20, 'thenable chained');
return value + 10;
})
.then(function (value) {
ASSERT.equal(value, 30, 'thenable chained again');
})
.fin(done);
}
exports['test when assimilation'] = function (ASSERT, done) {
Q.when({

@@ -10,10 +30,32 @@ "then": function (resolved, rejected) {

}, function (value) {
ASSERT.ok(true, 'thenable resolved');
done();
}, function () {
ASSERT.ok(false, 'thenable rejected');
done();
ASSERT.equal(value, 10, 'thenable resolved');
return value + 10;
})
.then(function (value) {
ASSERT.equal(value, 20, 'thenable chained');
return value + 10;
})
.then(function (value) {
ASSERT.equal(value, 30, 'thenable chained again');
})
.fin(done);
}
exports['test ref assimilation and piplining'] = function (ASSERT, done) {
Q.ref({
"then": function (resolved, rejected) {
resolved([10]);
}
})
.get(0)
.then(function (value) {
ASSERT.equal(value, 10, 'thenable resolved');
return value + 10;
})
.fail(function (reason) {
ASSERT.ok(false, reason);
})
.fin(done);
}
exports['test provision'] = function (ASSERT, done) {

@@ -20,0 +62,0 @@ Q.when(10).then(function (value) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc