Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Sep 4, 2023
1 parent a6c2f78 commit 68abb51
Show file tree
Hide file tree
Showing 59 changed files with 146 additions and 144 deletions.
4 changes: 3 additions & 1 deletion packages/babel-helper-wrap-function/src/index.ts
Expand Up @@ -122,7 +122,9 @@ function plainFunction(
params.push(path.scope.generateUidIdentifier("x"));
}

const ref = path.scope.generateUidIdentifier("ref");
const ref = path.scope.generateUidIdentifier(
functionId ? functionId.name : "ref",
);

if (isDeclaration) {
path.replaceWith(
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _fn;
function fn() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_fn = _fn || babelHelpers.asyncToGenerator(function* () {
yield 0;
try {
var _stack = [];
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _gen;
function gen() {
return (_ref = _ref || babelHelpers.skipFirstGeneratorNext(function* () {
return (_gen = _gen || babelHelpers.skipFirstGeneratorNext(function* () {
let _functionSent = yield;
let sent = _functionSent;
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _foo;
function foo() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(babelHelpers.skipFirstGeneratorNext(function* () {
return (_foo = _foo || babelHelpers.wrapAsyncGenerator(babelHelpers.skipFirstGeneratorNext(function* () {
let _functionSent = yield;
_functionSent = yield babelHelpers.awaitAsyncGenerator(_functionSent);
}))).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _gen;
export default function gen() {
return (_ref = _ref || babelHelpers.skipFirstGeneratorNext(function* () {
return (_gen = _gen || babelHelpers.skipFirstGeneratorNext(function* () {
let _functionSent = yield;
return _functionSent;
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _gen;
export function gen() {
return (_ref = _ref || babelHelpers.skipFirstGeneratorNext(function* () {
return (_gen = _gen || babelHelpers.skipFirstGeneratorNext(function* () {
let _functionSent = yield;
return _functionSent;
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _gen;
const foo = function gen() {
return (_ref = _ref || babelHelpers.skipFirstGeneratorNext(function* () {
return (_gen = _gen || babelHelpers.skipFirstGeneratorNext(function* () {
let _functionSent = yield;
return _functionSent;
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _gen;
function gen() {
return (_ref = _ref || babelHelpers.skipFirstGeneratorNext(function* () {
return (_gen = _gen || babelHelpers.skipFirstGeneratorNext(function* () {
let _functionSent = yield;
return _functionSent;
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _agf;
function agf() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_agf = _agf || babelHelpers.wrapAsyncGenerator(function* () {
this;
yield babelHelpers.awaitAsyncGenerator(1);
yield 2;
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _agf;
(function agf() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_agf = _agf || babelHelpers.wrapAsyncGenerator(function* () {
this;
yield babelHelpers.awaitAsyncGenerator(1);
yield 2;
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _fn;
function fn() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_fn = _fn || babelHelpers.wrapAsyncGenerator(function* () {
class A {
[yield 1]() {}
}
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _g;
function g() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_g = _g || babelHelpers.wrapAsyncGenerator(function* () {
yield* babelHelpers.asyncGeneratorDelegate(babelHelpers.asyncIterator([1, 2, 3]), babelHelpers.awaitAsyncGenerator);
yield* babelHelpers.asyncGeneratorDelegate(babelHelpers.asyncIterator(iterable), babelHelpers.awaitAsyncGenerator);
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _g;
function g() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_g = _g || babelHelpers.wrapAsyncGenerator(function* () {
yield* babelHelpers.asyncGeneratorDelegate(babelHelpers.asyncIterator([1, 2, 3]));
yield* babelHelpers.asyncGeneratorDelegate(babelHelpers.asyncIterator(iterable));
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _f;
function f() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_f = _f || babelHelpers.asyncToGenerator(function* () {
var _iteratorAbruptCompletion = false;
var _didIteratorError = false;
var _iteratorError;
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _g;
function g() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_g = _g || babelHelpers.wrapAsyncGenerator(function* () {
var _iteratorAbruptCompletion = false;
var _didIteratorError = false;
var _iteratorError;
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _fn;
function fn() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_fn = _fn || babelHelpers.wrapAsyncGenerator(function* () {
var _iteratorAbruptCompletion = false;
var _didIteratorError = false;
var _iteratorError;
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _f;
function f() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_f = _f || babelHelpers.asyncToGenerator(function* () {
var _iteratorAbruptCompletion = false;
var _didIteratorError = false;
var _iteratorError;
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _g;
function g() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_g = _g || babelHelpers.wrapAsyncGenerator(function* () {
var _this = this;
() => this;
function f() {
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _g;
function g() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* (x = /*#__PURE__*/babelHelpers.asyncToGenerator(function* () {
return (_g = _g || babelHelpers.wrapAsyncGenerator(function* (x = /*#__PURE__*/babelHelpers.asyncToGenerator(function* () {
yield 1;
})) {
yield babelHelpers.awaitAsyncGenerator(2);
Expand Down
@@ -1,10 +1,10 @@
var _ref2;
var _f;
function f() {
return (_ref2 = _ref2 || babelHelpers.asyncToGenerator(function* () {
var _ref;
return (_f = _f || babelHelpers.asyncToGenerator(function* () {
var _g;
yield 1;
function g() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_g = _g || babelHelpers.wrapAsyncGenerator(function* () {
yield babelHelpers.awaitAsyncGenerator(2);
yield 3;
})).apply(this, arguments);
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _fn;
function fn() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_fn = _fn || babelHelpers.wrapAsyncGenerator(function* () {
yield* babelHelpers.asyncGeneratorDelegate(babelHelpers.asyncIterator([Promise.resolve("ok")]), babelHelpers.awaitAsyncGenerator); // CreateAsyncFromSyncIterator
})).apply(this, arguments);
}
@@ -1,6 +1,6 @@
var _ref;
var _fn;
function fn() {
return (_ref = _ref || babelHelpers.wrapAsyncGenerator(function* () {
return (_fn = _fn || babelHelpers.wrapAsyncGenerator(function* () {
yield* babelHelpers.asyncGeneratorDelegate(babelHelpers.asyncIterator([Promise.resolve("ok")])); // CreateAsyncFromSyncIterator
})).apply(this, arguments);
}
@@ -1,9 +1,9 @@
var _ref2;
var _foo;
function mandatory(paramName) {
throw new Error(`Missing parameter: ${paramName}`);
}
function foo(_x) {
return (_ref2 = _ref2 || babelHelpers.asyncToGenerator(function* (_ref) {
return (_foo = _foo || babelHelpers.asyncToGenerator(function* (_ref) {
let {
a,
b = mandatory("b")
Expand Down
@@ -1,5 +1,5 @@
var _this = this,
_ref3;
_notIIFE;
babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee() {
return babelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
Expand All @@ -26,7 +26,7 @@ babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().ma
}, _callee2, this);
})).bind(this)();
(function notIIFE() {
return (_ref3 = _ref3 || babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee3() {
return (_notIIFE = _notIIFE || babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee3() {
return babelHelpers.regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
Expand Down
@@ -1,4 +1,4 @@
var _ref3;
var _notIIFE;
babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee() {
return babelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
Expand All @@ -24,7 +24,7 @@ babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().ma
}, _callee2);
}))();
(function notIIFE() {
return (_ref3 = _ref3 || babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee3() {
return (_notIIFE = _notIIFE || babelHelpers.asyncToGenerator( /*#__PURE__*/babelHelpers.regeneratorRuntime().mark(function _callee3() {
return babelHelpers.regeneratorRuntime().wrap(function _callee3$(_context3) {
while (1) switch (_context3.prev = _context3.next) {
case 0:
Expand Down
@@ -1,12 +1,12 @@
var _ref3;
var _notIIFE;
babelHelpers.asyncToGenerator(function* () {
yield 'ok';
})();
babelHelpers.asyncToGenerator(function* () {
yield 'ok';
})();
(function notIIFE() {
return (_ref3 = _ref3 || babelHelpers.asyncToGenerator(function* () {
return (_notIIFE = _notIIFE || babelHelpers.asyncToGenerator(function* () {
yield 'ok';
})).apply(this, arguments);
});
Expand Down
@@ -1,17 +1,17 @@
var _ref;
var _s;
function s(_x) {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* (x) {
return (_s = _s || babelHelpers.asyncToGenerator(function* (x) {
var _arguments = arguments,
_this = this,
_ref2;
_ref;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
let t = function t(_x2, _x3) {
return (_ref2 = _ref2 || babelHelpers.asyncToGenerator(function* (y, a) {
var _ref3;
return (_ref = _ref || babelHelpers.asyncToGenerator(function* (y, a) {
var _ref2;
let r = function r(_x4, _x5) {
return (_ref3 = _ref3 || babelHelpers.asyncToGenerator(function* (z, b) {
return (_ref2 = _ref2 || babelHelpers.asyncToGenerator(function* (z, b) {
yield z;
for (var _len2 = arguments.length, innerArgs = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
innerArgs[_key2 - 2] = arguments[_key2];
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _fn;
function fn() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_fn = _fn || babelHelpers.asyncToGenerator(function* () {
yield yield 1;
})).apply(this, arguments);
}
@@ -1,23 +1,23 @@
var _ref, _ref2, _ref3, _ref4, _ref5, _ref6;
var _one, _two, _three, _four, _five, _six;
function one(_x) {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* (a, b = 1) {})).apply(this, arguments);
return (_one = _one || babelHelpers.asyncToGenerator(function* (a, b = 1) {})).apply(this, arguments);
}
function two(_x2, _x3) {
return (_ref2 = _ref2 || babelHelpers.asyncToGenerator(function* (a, b, ...c) {})).apply(this, arguments);
return (_two = _two || babelHelpers.asyncToGenerator(function* (a, b, ...c) {})).apply(this, arguments);
}
function three(_x4) {
return (_ref3 = _ref3 || babelHelpers.asyncToGenerator(function* (a, b = 1, c, d = 3) {})).apply(this, arguments);
return (_three = _three || babelHelpers.asyncToGenerator(function* (a, b = 1, c, d = 3) {})).apply(this, arguments);
}
function four(_x5) {
return (_ref4 = _ref4 || babelHelpers.asyncToGenerator(function* (a, b = 1, c, ...d) {})).apply(this, arguments);
return (_four = _four || babelHelpers.asyncToGenerator(function* (a, b = 1, c, ...d) {})).apply(this, arguments);
}
function five(_x6, _x7) {
return (_ref5 = _ref5 || babelHelpers.asyncToGenerator(function* (a, {
return (_five = _five || babelHelpers.asyncToGenerator(function* (a, {
b
}) {})).apply(this, arguments);
}
function six(_x8) {
return (_ref6 = _ref6 || babelHelpers.asyncToGenerator(function* (a, {
return (_six = _six || babelHelpers.asyncToGenerator(function* (a, {
b
} = {}) {})).apply(this, arguments);
}
@@ -1,6 +1,6 @@
var _ref;
var _bar;
var foo = function bar() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_bar = _bar || babelHelpers.asyncToGenerator(function* () {
console.log(bar);
})).apply(this, arguments);
};
@@ -1,4 +1,4 @@
var _ref;
var _foo;
function foo(_x) {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* (bar) {})).apply(this, arguments);
return (_foo = _foo || babelHelpers.asyncToGenerator(function* (bar) {})).apply(this, arguments);
}
@@ -1,7 +1,7 @@
var _ref;
var _foo;
import Promise from 'somewhere';
function foo() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_foo = _foo || babelHelpers.asyncToGenerator(function* () {
yield Promise.resolve();
})).apply(this, arguments);
}
@@ -1,12 +1,12 @@
var _ref;
var _foo;
let Promise;
function foo() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
var _ref2;
return (_foo = _foo || babelHelpers.asyncToGenerator(function* () {
var _bar;
let Promise;
yield bar();
function bar() {
return (_ref2 = _ref2 || babelHelpers.asyncToGenerator(function* () {
return (_bar = _bar || babelHelpers.asyncToGenerator(function* () {
return Promise.resolve();
})).apply(this, arguments);
}
Expand Down
@@ -1,7 +1,7 @@
var _ref;
var _foo;
let Promise;
function foo() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_foo = _foo || babelHelpers.asyncToGenerator(function* () {
yield new Promise(resolve => {
resolve();
});
Expand Down
@@ -1,6 +1,6 @@
var _ref;
var _foo;
function foo() {
return (_ref = _ref || babelHelpers.asyncToGenerator(function* () {
return (_foo = _foo || babelHelpers.asyncToGenerator(function* () {
var wat = yield bar();
})).apply(this, arguments);
}
@@ -1,7 +1,7 @@
var _coroutine = require("bluebird").coroutine;
var _ref;
var _bar;
var foo = function bar() {
return (_ref = _ref || _coroutine(function* () {
return (_bar = _bar || _coroutine(function* () {
console.log(bar);
})).apply(this, arguments);
};

0 comments on commit 68abb51

Please sign in to comment.