File: promise_s27.t.js

package info (click to toggle)
libnginx-mod-js 0.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,300 kB
  • sloc: ansic: 124,113; perl: 9,084; javascript: 2,717; exp: 487; sh: 322; xml: 312; python: 181; makefile: 18
file content (34 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*---
includes: []
flags: [async]
---*/

var inherits = (child, parent) => {
    child.prototype = Object.create(parent.prototype, {
        constructor: {
        value: child,
        enumerable: false,
        writable: true,
        configurable: true
        }
    });
    Object.setPrototypeOf(child, parent);
};

function BoxedPromise(executor) {
    var context, args;
    new Promise(wrappedExecutor);
    executor.apply(context, args);

    function wrappedExecutor(resolve, reject) {
        context = this;
        args = [v => resolve(v),v => reject(v)];
    }
}

inherits(BoxedPromise, Promise);

Promise.resolve()
.then(() => BoxedPromise.resolve())
.catch(e => assert.sameValue(e.constructor, TypeError))
.then($DONE, $DONE);