Socket
Socket
Sign inDemoInstall

@babel/helper-replace-supers

Package Overview
Dependencies
Maintainers
6
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-replace-supers - npm Package Compare versions

Comparing version 7.15.0 to 7.15.4

70

lib/index.js

@@ -15,8 +15,22 @@ "use strict";

var t = require("@babel/types");
var _t = require("@babel/types");
const {
VISITOR_KEYS,
assignmentExpression,
booleanLiteral,
callExpression,
cloneNode,
identifier,
memberExpression,
sequenceExpression,
staticBlock,
stringLiteral,
thisExpression
} = _t;
function getPrototypeOfExpression(objectRef, isStatic, file, isPrivateMethod) {
objectRef = t.cloneNode(objectRef);
const targetRef = isStatic || isPrivateMethod ? objectRef : t.memberExpression(objectRef, t.identifier("prototype"));
return t.callExpression(file.addHelper("getPrototypeOf"), [targetRef]);
objectRef = cloneNode(objectRef);
const targetRef = isStatic || isPrivateMethod ? objectRef : memberExpression(objectRef, identifier("prototype"));
return callExpression(file.addHelper("getPrototypeOf"), [targetRef]);
}

@@ -30,3 +44,3 @@

const keys = t.VISITOR_KEYS[path.type];
const keys = VISITOR_KEYS[path.type];

@@ -39,3 +53,3 @@ for (const key of keys) {

const environmentVisitor = {
[`${t.staticBlock ? "StaticBlock|" : ""}ClassPrivateProperty|TypeAnnotation`](path) {
[`${staticBlock ? "StaticBlock|" : ""}ClassPrivateProperty|TypeAnnotation`](path) {
path.skip();

@@ -115,10 +129,10 @@ },

if (this.memoiser.has(property)) {
return t.cloneNode(this.memoiser.get(property));
return cloneNode(this.memoiser.get(property));
}
if (computed) {
return t.cloneNode(property);
return cloneNode(property);
}
return t.stringLiteral(property.name);
return stringLiteral(property.name);
},

@@ -132,3 +146,3 @@

const proto = getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod);
return t.callExpression(this.file.addHelper("get"), [thisRefs.memo ? t.sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), thisRefs.this]);
return callExpression(this.file.addHelper("get"), [thisRefs.memo ? sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), thisRefs.this]);
},

@@ -139,3 +153,3 @@

return {
this: t.thisExpression()
this: thisExpression()
};

@@ -146,4 +160,4 @@ }

return {
memo: t.assignmentExpression("=", thisRef, t.thisExpression()),
this: t.cloneNode(thisRef)
memo: assignmentExpression("=", thisRef, thisExpression()),
this: cloneNode(thisRef)
};

@@ -156,3 +170,3 @@ },

const proto = getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod);
return t.callExpression(this.file.addHelper("set"), [thisRefs.memo ? t.sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), value, thisRefs.this, t.booleanLiteral(superMember.isInStrictMode())]);
return callExpression(this.file.addHelper("set"), [thisRefs.memo ? sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), value, thisRefs.this, booleanLiteral(superMember.isInStrictMode())]);
},

@@ -167,3 +181,3 @@

return (0, _helperOptimiseCallExpression.default)(this._get(superMember, thisRefs), t.cloneNode(thisRefs.this), args, false);
return (0, _helperOptimiseCallExpression.default)(this._get(superMember, thisRefs), cloneNode(thisRefs.this), args, false);
},

@@ -174,3 +188,3 @@

return (0, _helperOptimiseCallExpression.default)(this._get(superMember, thisRefs), t.cloneNode(thisRefs.this), args, true);
return (0, _helperOptimiseCallExpression.default)(this._get(superMember, thisRefs), cloneNode(thisRefs.this), args, true);
}

@@ -186,6 +200,6 @@

if (this.memoiser.has(property)) {
return t.cloneNode(this.memoiser.get(property));
return cloneNode(this.memoiser.get(property));
}
return t.cloneNode(property);
return cloneNode(property);
},

@@ -207,10 +221,10 @@

object = (_getSuperRef = getSuperRef()) != null ? _getSuperRef : t.memberExpression(t.identifier("Function"), t.identifier("prototype"));
object = (_getSuperRef = getSuperRef()) != null ? _getSuperRef : memberExpression(identifier("Function"), identifier("prototype"));
} else {
var _getSuperRef2;
object = t.memberExpression((_getSuperRef2 = getSuperRef()) != null ? _getSuperRef2 : t.identifier("Object"), t.identifier("prototype"));
object = memberExpression((_getSuperRef2 = getSuperRef()) != null ? _getSuperRef2 : identifier("Object"), identifier("prototype"));
}
return t.memberExpression(object, prop, computed);
return memberExpression(object, prop, computed);
},

@@ -223,3 +237,3 @@

const prop = this.prop(superMember);
return t.assignmentExpression("=", t.memberExpression(t.thisExpression(), prop, computed), value);
return assignmentExpression("=", memberExpression(thisExpression(), prop, computed), value);
},

@@ -232,11 +246,11 @@

const prop = this.prop(superMember);
return t.memberExpression(t.thisExpression(), prop, computed);
return memberExpression(thisExpression(), prop, computed);
},
call(superMember, args) {
return (0, _helperOptimiseCallExpression.default)(this.get(superMember), t.thisExpression(), args, false);
return (0, _helperOptimiseCallExpression.default)(this.get(superMember), thisExpression(), args, false);
},
optionalCall(superMember, args) {
return (0, _helperOptimiseCallExpression.default)(this.get(superMember), t.thisExpression(), args, true);
return (0, _helperOptimiseCallExpression.default)(this.get(superMember), thisExpression(), args, true);
}

@@ -263,8 +277,8 @@

getObjectRef() {
return t.cloneNode(this.opts.objectRef || this.opts.getObjectRef());
return cloneNode(this.opts.objectRef || this.opts.getObjectRef());
}
getSuperRef() {
if (this.opts.superRef) return t.cloneNode(this.opts.superRef);
if (this.opts.getSuperRef) return t.cloneNode(this.opts.getSuperRef());
if (this.opts.superRef) return cloneNode(this.opts.superRef);
if (this.opts.getSuperRef) return cloneNode(this.opts.getSuperRef());
}

@@ -271,0 +285,0 @@

10

package.json
{
"name": "@babel/helper-replace-supers",
"version": "7.15.0",
"version": "7.15.4",
"description": "Helper function to replace supers",

@@ -17,6 +17,6 @@ "repository": {

"dependencies": {
"@babel/helper-member-expression-to-functions": "^7.15.0",
"@babel/helper-optimise-call-expression": "^7.14.5",
"@babel/traverse": "^7.15.0",
"@babel/types": "^7.15.0"
"@babel/helper-member-expression-to-functions": "^7.15.4",
"@babel/helper-optimise-call-expression": "^7.15.4",
"@babel/traverse": "^7.15.4",
"@babel/types": "^7.15.4"
},

@@ -23,0 +23,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc