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

q

Package Overview
Dependencies
Maintainers
0
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.2.4 to 0.2.5

q/lib/q/forwarder.js

34

q/lib/q.js

@@ -53,2 +53,4 @@ // vim:ts=4:sts=4:sw=4:

var DUCK = "promiseSend";
var enqueue;

@@ -65,16 +67,2 @@ try {

var print;
if (typeof console !== "undefined") {
// browsers in debug mode, Node
print = function (message) {
console.log(message);
};
} else if (typeof require !== "undefined") {
// Narwhal
print = require("system").print;
} else {
// browsers otherwise
print = function () {}
}
// useful for an identity stub and default resolvers

@@ -119,3 +107,3 @@ function identity (x) {return x}

promise.emit = function () {
promise[DUCK] = function () {
var args = Array.prototype.slice.call(arguments);

@@ -179,3 +167,3 @@ if (pending) {

promise.emit = function (op, resolved /* ...args */) {
promise[DUCK] = function (op, resolved /* ...args */) {
var args = Array.prototype.slice.call(arguments, 2);

@@ -213,3 +201,3 @@ var result;

function isPromise(object) {
return object instanceof Promise;
return object && typeof object[DUCK] === "function";
};

@@ -283,6 +271,6 @@

"put": function (name, value) {
object[name] = value;
return object[name] = value;
},
"del": function (name) {
delete object[name];
return delete object[name];
},

@@ -351,3 +339,3 @@ "post": function (name /*...args*/) {

done = true;
deferred.resolve(ref(value).emit("when", resolved, rejected));
deferred.resolve(ref(value)[DUCK]("when", resolved, rejected));
}, function (reason) {

@@ -488,9 +476,9 @@ if (done)

*/
function forward(promise /*, op, resolved, ... */) {
function forward(promise, op, resolved /* ... */) {
var args = Array.prototype.slice.call(arguments, 1);
enqueue(function () {
try {
promise.emit.apply(promise, args);
promise[DUCK].apply(promise, args);
} catch (exception) {
print(exception.stack || exception);
resolved(reject(exception));
}

@@ -497,0 +485,0 @@ });

{
"name": "q",
"description": "defer/when-style promises (CommonJS/Promises/B)",
"version": "0.2.4",
"version": "0.2.5",
"homepage": "http://github.com/kriskowal/q/",

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

@@ -65,5 +65,5 @@ // vim:ts=4:sts=4:sw=4:

Q.when(Q.post(d.promise, 'a', [1]), function (result) {
ASSERT.equal(result, 2, 'correct value is returned by post');
ASSERT.equal(value._a, 1, 'post invoked function as expected');
Q.when(Q.post(d.promise, 'a', 1), function (result) {
ASSERT.ok(result === 2, 'correct value is returned by post');
ASSERT.ok(value._a === 1, 'post invoked function as expected');
done();

@@ -81,3 +81,3 @@ }, function (reason) {

Q.when(Q.post(d.promise, 'a', [1]), function (result) {
Q.when(Q.post(d.promise, 'a', 1), function (result) {
ASSERT.fail('Unxpeced to call non-existing method:' + result);

@@ -84,0 +84,0 @@ done();

Sorry, the diff of this file is not supported yet

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