Sha256: df82f6980855ff7315ee420c6fcf7f6fc00ad1ce63ecbd92dce427151a974547

Contents?: true

Size: 1.27 KB

Versions: 22

Compression:

Stored size: 1.27 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.once = once;
var _async = require("./async.js");
function once(fn) {
  let result;
  let resultP;
  let promiseReferenced = false;
  return function* () {
    if (!result) {
      if (resultP) {
        promiseReferenced = true;
        return yield* (0, _async.waitFor)(resultP);
      }
      if (!(yield* (0, _async.isAsync)())) {
        try {
          result = {
            ok: true,
            value: yield* fn()
          };
        } catch (error) {
          result = {
            ok: false,
            value: error
          };
        }
      } else {
        let resolve, reject;
        resultP = new Promise((res, rej) => {
          resolve = res;
          reject = rej;
        });
        try {
          result = {
            ok: true,
            value: yield* fn()
          };
          resultP = null;
          if (promiseReferenced) resolve(result.value);
        } catch (error) {
          result = {
            ok: false,
            value: error
          };
          resultP = null;
          if (promiseReferenced) reject(error);
        }
      }
    }
    if (result.ok) return result.value;else throw result.value;
  };
}
0 && 0;

//# sourceMappingURL=functional.js.map

Version data entries

22 entries across 15 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.51 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.50 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.50 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.49 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.48 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.48 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.47 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.47 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.46 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.46 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.45 node_modules/jscodeshift/node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.45 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.44 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.43 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.42 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.41 node_modules/@babel/core/lib/gensync-utils/functional.js
immosquare-cleaner-0.1.40 node_modules/@babel/core/lib/gensync-utils/functional.js
wice_grid-7.1.0 node_modules/@babel/core/lib/gensync-utils/functional.js