Sha256: b3393ab729459f2a9f0e914f927910f88ab06089f219dfda9bce984df0826b85

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

"use strict";

var _interopRequireWildcard = require("babel-runtime/helpers/interop-require-wildcard")["default"];

exports.__esModule = true;

var _babelTypes = require("babel-types");

var t = _interopRequireWildcard(_babelTypes);

exports["default"] = function (decorators, scope) {
  for (var _i = 0; _i < decorators.length; _i++) {
    var decorator = decorators[_i];
    var expression = decorator.expression;
    if (!t.isMemberExpression(expression)) continue;

    var temp = scope.maybeGenerateMemoised(expression.object);
    var ref = undefined;

    var nodes = [];

    if (temp) {
      ref = temp;
      nodes.push(t.assignmentExpression("=", temp, expression.object));
    } else {
      ref = expression.object;
    }

    nodes.push(t.callExpression(t.memberExpression(t.memberExpression(ref, expression.property, expression.computed), t.identifier("bind")), [ref]));

    if (nodes.length === 1) {
      decorator.expression = nodes[0];
    } else {
      decorator.expression = t.sequenceExpression(nodes);
    }
  }

  return decorators;
};

module.exports = exports["default"];

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
babel-schmooze-sprockets-0.1.0 node_modules/babel-plugin-transform-es2015-classes/lib/lib/memoise-decorators.js
babel-schmooze-sprockets-0.1.0.alpha.3 node_modules/babel-plugin-transform-es2015-classes/lib/lib/memoise-decorators.js
babel-schmooze-sprockets-0.1.0.alpha.2 node_modules/babel-plugin-transform-es2015-classes/lib/lib/memoise-decorators.js