次の動作が正常なのか疑問に思っています。
コード
var when = require('when'); // I'm using when@3.7.4 node_modules/when
console.log("INIT");
when.promise(function(resolve, reject) {
return when.reject("false")
.then(function(ok) {
console.log("Step 1 - in then, ok = %s", ok);
return 'ok1';
}, function(err) {
console.log("Step 1.1 - in catch, err = %s", err);
return reject(err);
}).then(function(ok) {
console.log("Step 2 - in then, ok2 = %s", ok);
return resolve("done");
}).catch(function(err) {
console.log("Step 3 - in catch, err = %s", err);
return reject(err);
});
}).then(function(mainok) {
console.log("Step 9 - in main then, mainok = %s", mainok);
}).catch(function(err) {
console.log("Step 9 - in main catch, err = %s", err);
});
実行時に受け取った出力は次のとおりです
INIT
Step 1.1 - in catch, err = false
Step 2 - in then, ok2 = undefined
Step 9 - in main catch, err = false
API を読んで、ステップ 1.1 が呼び出され、次にステップ 9 が呼び出されると予想していましたが、ステップ 2 は呼び出されませんでした。
それはバグですか、それとも API を読み間違えましたか?
ヒントをありがとう!