source: imaps-frontend/node_modules/@babel/core/lib/gensync-utils/async.js

main
Last change on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 7 months ago

Pred finalna verzija

  • Property mode set to 100644
File size: 2.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.forwardAsync = forwardAsync;
7exports.isAsync = void 0;
8exports.isThenable = isThenable;
9exports.maybeAsync = maybeAsync;
10exports.waitFor = exports.onFirstPause = void 0;
11function _gensync() {
12 const data = require("gensync");
13 _gensync = function () {
14 return data;
15 };
16 return data;
17}
18function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
19function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
20const runGenerator = _gensync()(function* (item) {
21 return yield* item;
22});
23const isAsync = exports.isAsync = _gensync()({
24 sync: () => false,
25 errback: cb => cb(null, true)
26});
27function maybeAsync(fn, message) {
28 return _gensync()({
29 sync(...args) {
30 const result = fn.apply(this, args);
31 if (isThenable(result)) throw new Error(message);
32 return result;
33 },
34 async(...args) {
35 return Promise.resolve(fn.apply(this, args));
36 }
37 });
38}
39const withKind = _gensync()({
40 sync: cb => cb("sync"),
41 async: function () {
42 var _ref = _asyncToGenerator(function* (cb) {
43 return cb("async");
44 });
45 return function async(_x) {
46 return _ref.apply(this, arguments);
47 };
48 }()
49});
50function forwardAsync(action, cb) {
51 const g = _gensync()(action);
52 return withKind(kind => {
53 const adapted = g[kind];
54 return cb(adapted);
55 });
56}
57const onFirstPause = exports.onFirstPause = _gensync()({
58 name: "onFirstPause",
59 arity: 2,
60 sync: function (item) {
61 return runGenerator.sync(item);
62 },
63 errback: function (item, firstPause, cb) {
64 let completed = false;
65 runGenerator.errback(item, (err, value) => {
66 completed = true;
67 cb(err, value);
68 });
69 if (!completed) {
70 firstPause();
71 }
72 }
73});
74const waitFor = exports.waitFor = _gensync()({
75 sync: x => x,
76 async: function () {
77 var _ref2 = _asyncToGenerator(function* (x) {
78 return x;
79 });
80 return function async(_x2) {
81 return _ref2.apply(this, arguments);
82 };
83 }()
84});
85function isThenable(val) {
86 return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function";
87}
880 && 0;
89
90//# sourceMappingURL=async.js.map
Note: See TracBrowser for help on using the repository browser.