Comparing version 2.1.1 to 2.1.2
17
index.js
@@ -108,2 +108,4 @@ var is = require('./is') | ||
ctx.args = args | ||
ctx.resolve = next.bind(null, null) | ||
ctx.reject = next | ||
@@ -132,5 +134,14 @@ var index = 0 | ||
fn.call(self, ctx, next) | ||
// args without next() | ||
if (fn.length < 2) next() | ||
var val = fn.call(self, ctx, next) | ||
if (fn.length < 2) { | ||
// args without next() | ||
if (val && is.function(val.then)) { | ||
// thenable | ||
val.then(function () { | ||
next() | ||
}).catch(next) | ||
} else { | ||
next() | ||
} | ||
} | ||
} else { | ||
@@ -137,0 +148,0 @@ // trigger empty callback if no more pipe |
{ | ||
"name": "ginga", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Middleware framework for JavaScript functions", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -39,3 +39,8 @@ var tape = require('tape') | ||
function (ctx) { | ||
ctx.logs.push('more') | ||
return new Promise(function (resolve) { | ||
setTimeout(function () { | ||
ctx.logs.push('more') | ||
resolve() // no value, should do next | ||
}, 10) | ||
}) | ||
}, | ||
@@ -48,7 +53,9 @@ function (ctx) { | ||
'tock', | ||
function (ctx, next) { | ||
// resolver function err | ||
next(function (res) { | ||
t.error('resolver called') | ||
})('booooom') | ||
function (ctx) { | ||
// promise reject | ||
return new Promise(function (resolve, reject) { | ||
setTimeout(function () { | ||
reject('booooom') // no value, should do next | ||
}, 10) | ||
}) | ||
} | ||
@@ -55,0 +62,0 @@ ) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19155
13
480