Socket
Socket
Sign inDemoInstall

@babel/helper-member-expression-to-functions

Package Overview
Dependencies
1
Maintainers
5
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-beta.49 to 7.0.0-beta.50

4

package.json
{
"name": "@babel/helper-member-expression-to-functions",
"version": "7.0.0-beta.49",
"version": "7.0.0-beta.50",
"description": "Helper function to replace certain member expressions with function calls",

@@ -10,4 +10,4 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-member-expression-to-functions",

"dependencies": {
"@babel/types": "7.0.0-beta.49"
"@babel/types": "7.0.0-beta.50"
}
}
# @babel/helper-member-expression-to-functions
Helper function to replace certain member expressions with function calls
> Helper function to replace certain member expressions with function calls
## Usage
See our website [@babel/helper-member-expression-to-functions](https://new.babeljs.io/docs/en/next/babel-helper-member-expression-to-functions.html) for more information.
> Designed for internal Babel use.
## Install
Traverses the `path` using the supplied `visitor` and an augmented `state`.
Using npm:
```js
const visitor = {
MemberExpression(memberPath, state) {
```sh
npm install --save @babel/helper-member-expression-to-functions
```
if (someCondition(memberPath)) {
or using yarn:
// The handle method is supplied by memberExpressionToFunctions.
// It should be called whenever a MemberExpression should be
// converted into the proper function calls.
state.handle(memberPath);
}
},
};
// The helper requires three special methods on state: `get`, `set`, and
// `call`.
// Optionally, a special `memoise` method may be defined, which gets
// called if the member is in a self-referential update expression.
// Everything else will be passed through as normal.
const state = {
get(memberPath) {
// Return some AST that will get the member
return t.callExpression(
this.file.addHelper('superGet'),
[t.thisExpression(), memberPath.node.property]
);
},
set(memberPath, value) {
// Return some AST that will set the member
return t.callExpression(
this.file.addHelper('superSet'),
[t.thisExpression(), memberPath.node.property, value]
);
},
call(memberPath, args) {
// Return some AST that will call the member with the proper context
// and args
return t.callExpression(
t.memberExpression(this.get(memberPath), t.identifier("apply")),
[t.thisExpression(), t.arrayExpression(args)]
);
},
memoise(memberPath) {
const { node } = memberPath;
if (node.computed) {
MEMOISED.set(node, ...);
}
},
// The handle method is provided by memberExpressionToFunctions.
// handle(memberPath) { ... }
// Other state stuff is left untouched.
someState: new Set(),
};
// Replace all the special MemberExpressions in rootPath, as determined
// by our visitor, using the state methods.
memberExpressionToFunctions(rootPath, visitor, state);
```sh
yarn add --save @babel/helper-member-expression-to-functions
```
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc