# All files / src/js Relude_Js_Promise.bs.js

55.88% Statements 19/34
0% Branches 0/6
47.06% Functions 8/17
55.88% Lines 19/34

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    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
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72

    2x
    2x
    2x

    2x
    2x
    1x

    1x

    2x

    3x
    3x
    3x
    2x

    1x

    3x

    2x
    2x
    2x
    2x
    2x

     'use strict';

    var Block = require("bs-platform/lib/js/block.js");
    var Curry = require("bs-platform/lib/js/curry.js");
    var Relude_IO = require("../Relude_IO.bs.js");

    function toIO(promise) {
      return Relude_IO.async((function (onDone) {
                    promise.then((function (v) {
                              return Promise.resolve(Curry._1(onDone, /* Ok */Block.__(0, [v])));
                            })).catch((function (e) {
                            return Promise.resolve(Curry._1(onDone, /* Error */Block.__(1, [e])));
                          }));
                    return /* () */0;
                  }));
    }

    function toIOLazy(runPromise) {
      return Relude_IO.async((function (onDone) {
                    var promise = Curry._1(runPromise, /* () */0);
                    promise.then((function (v) {
                              return Promise.resolve(Curry._1(onDone, /* Ok */Block.__(0, [v])));
                            })).catch((function (e) {
                            return Promise.resolve(Curry._1(onDone, /* Error */Block.__(1, [e])));
                          }));
                    return /* () */0;
                  }));
    }

    function fromIO(io) {
      return new Promise((function (resolve, reject) {
                    return Relude_IO.unsafeRunAsync((function (result) {
                                  if (result.tag) {
                                    return reject(result[0]);
                                  } else {
                                    return resolve(result[0]);
                                  }
                                }), io);
                  }));
    }

    function fromIOExn(io) {
      return new Promise((function (resolve, reject) {
                    return Relude_IO.unsafeRunAsync((function (result) {
                                  if (result.tag) {
                                    return reject(result[0]);
                                  } else {
                                    return resolve(result[0]);
                                  }
                                }), io);
                  }));
    }

    function fromIOJsExn(io) {
      return new Promise((function (resolve, reject) {
                    return Relude_IO.unsafeRunAsync((function (result) {
                                  if (result.tag) {
                                    return reject(result[0]);
                                  } else {
                                    return resolve(result[0]);
                                  }
                                }), io);
                  }));
    }

    exports.toIO = toIO;
    exports.toIOLazy = toIOLazy;
    exports.fromIO = fromIO;
    exports.fromIOExn = fromIOExn;
    exports.fromIOJsExn = fromIOJsExn;
    /* Relude_IO Not a pure module */