Debian Codegraph @

deferred/ext/promise/finally.js

raw
1 // 'finally' - Promise extension
2 //
3 // promise.finally(cb)
4 //
5 // Called on promise resolution returns same promise, doesn't pass any values to
6 // provided callback
7
8 "use strict";
9
10 var callable = require("es5-ext/object/valid-callable")
11 , deferred = require("../../deferred");
12
13 deferred.extend(
14 "finally",
15 function (cb) {
16 callable(cb);
17 if (!this.pending) this.pending = [];
18 this.pending.push("finally", arguments);
19 return this;
20 },
21 function (cb) { cb(); },
22 function (cb) {
23 callable(cb)();
24 return this;
25 }
26 );