Socket
Socket
Sign inDemoInstall

babel-plugin-autobind-class-methods

Package Overview
Dependencies
0
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.3 to 1.0.4

48

index.js
'use strict'
// TODO REFACTOR, this was written as a hack
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
exports.__esModule = true;

@@ -9,2 +13,11 @@

module.exports = function (_ref) {
var findBareSupers = { /*istanbul ignore next*/
Super: function Super(path) {
if (path.parentPath.isCallExpression({ callee: path.node })) {
this.push(path.parentPath);
}
}
};
var t = _ref.types;

@@ -31,6 +44,7 @@ return {

var newNodes = methods.map((method)=> {
return template('THIS.METHOD = ()=> _makeJsClassGreatAgain(THIS, \'' + method.name + '\', arguments)')({THIS: t.thisExpression(), METHOD: method})
}
);
var newNodes = methods
.map((method)=> {
return template('THIS.METHOD = (...rest)=> _makeJsClassGreatAgain(THIS, \'' + method.name + '\', rest)')({THIS: t.thisExpression(), METHOD: method})
}
);

@@ -41,10 +55,26 @@ if (!constructor) {

newConstructor.params = [t.restElement(t.identifier("args"))];
newConstructor.body.body.push(t.callExpression(t.super(), [t.spreadElement(t.identifier("args"))]));
newConstructor.body.body.push(t.returnStatement(t.callExpression(t.super(), [t.spreadElement(t.identifier("args"))])));
}
constructor = body.unshiftContainer("body", newConstructor)[0];
}
var bareSupers = [];
constructor.traverse(findBareSupers, bareSupers);
for (var _iterator4 = bareSupers, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) {
var _ref5;
newNodes.forEach((node)=>{
constructor.get("body").pushContainer("body", node)
})
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref5 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref5 = _i4.value;
}
var bareSuper = _ref5;
newNodes.forEach((node)=>{
bareSuper.insertAfter(node);
})
}
}

@@ -54,1 +84,3 @@ }

};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

2

package.json
{
"name": "babel-plugin-autobind-class-methods",
"version": "1.0.3",
"version": "1.0.4",
"description": "Babel plugin that binds every class method to \"this\" with hot reload support",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc