How to use babel-helper-function-name - 4 common examples

To help you get started, we’ve selected a few babel-helper-function-name examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github babel / babel / packages / babel-helper-define-map / src / index.js View on Github external
}

  if (t.isObjectProperty(node) || t.isClassProperty(node)) {
    value = node.value;
  } else if (t.isObjectMethod(node) || t.isClassMethod(node)) {
    value = t.functionExpression(null, node.params, node.body, node.generator, node.async);
  }

  let inheritedKind = toKind(node);
  if (!kind || inheritedKind !== "value") {
    kind = inheritedKind;
  }

  // infer function name
  if (scope && t.isStringLiteral(key) && (kind === "value" || kind === "initializer") && t.isFunctionExpression(value)) {
    value = nameFunction({ id: key, node: value, scope });
  }

  if (value) {
    t.inheritsComments(value, node);
    map[kind] = value;
  }

  return map;
}
github chpio / babel-plugin-transform-async-to-bluebird / main.es2015.js View on Github external
}).expression;

		if (isDeclaration) {
			const declar = t.variableDeclaration('let', [
				t.variableDeclarator(
					t.identifier(asyncFnId.name),
					t.callExpression(container, [])
				),
			]);
			declar._blockHoist = true;

			path.replaceWith(declar);
		} else {
			const retFunction = container.body.body[1].argument;
			if (!asyncFnId) {
				nameFunction({
					node: retFunction,
					parent: path.parent,
					scope: path.scope,
				});
			}

			if (!retFunction || retFunction.id || node.params.length) {
				// we have an inferred function id or params so we need this wrapper
				path.replaceWith(t.callExpression(container, []));
			} else {
				// we can omit this wrapper as the conditions it protects for do not apply
				path.replaceWith(built);
			}
		}
	}
github dtinth / babel-plugin-__coverage__ / src / index.js View on Github external
function coverFunction (path) {
    if (!path.node.loc) return
    const node = path.node
    const data = getData(this)
    const id = String(data.nextId.f++)
    const nameOf = (namedNode) => namedNode && namedNode.id && namedNode.id.name || null
    data.base.f[id] = 0
    data.base.fnMap[id] = {
      name: nameOf(nameFunction(path)), // I love Babel!
      line: node.loc.start.line,
      loc: locToObject(node.loc)
    }
    const increment = increase(this, 'f', id)
    const body = path.get('body')
    if (body.isBlockStatement()) {
      body.node.body.unshift(t.expressionStatement(increment))
    } else if (body.isExpression()) {
      const sid = nextStatementId(this, body.node.loc || path.node.loc)
      body.replaceWith(t.sequenceExpression([
        increment,
        increase(this, 's', sid),
        body.node
      ]))
    } else {
      throw new Error(`wtf?? Can’t cover function with ${body.node.type}`)
github TeamFleet / WhoCallsTheFleet / dev-output / js-source / node_modules / babel-core / lib / transformation / transformers / es6 / classes / index.js View on Github external
ClassExpression: function ClassExpression(path, file) {
    var inferred = _babelHelperFunctionName.bare(path);
    if (inferred) return inferred;

    if (file.isLoose("es6.classes")) {
      return new _loose2["default"](path, file).run();
    } else {
      return new _vanilla2["default"](path, file).run();
    }
  }
};

babel-helper-function-name

Helper function to change the property 'name' of every function

MIT
Latest version published 7 years ago

Package Health Score

82 / 100
Full package analysis

Popular babel-helper-function-name functions

Similar packages