Socket
Socket
Sign inDemoInstall

@babel/helper-hoist-variables

Package Overview
Dependencies
4
Maintainers
4
Versions
66
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/helper-hoist-variables

Helper function to hoist variables


Version published
Weekly downloads
35M
decreased by-0.81%
Maintainers
4
Install size
2.37 MB
Created
Weekly downloads
 

Package description

What is @babel/helper-hoist-variables?

The @babel/helper-hoist-variables package is a utility that is used within the Babel compiler to hoist variable declarations to the top of their respective scopes during the code transformation process. This is part of the Babel's internal mechanism to ensure that the transformed code adheres to the scoping rules of ECMAScript and to avoid issues with variable declarations in the transpiled output.

What are @babel/helper-hoist-variables's main functionalities?

Variable Hoisting

This feature allows the package to traverse a given AST (Abstract Syntax Tree) path and find all variable declarations. It then hoists these declarations to the top of the function or program scope. The 'emitOnScope' parameter is a callback that is called with an identifier for each variable that needs to be hoisted.

function hoistVariables(path, emitOnScope) {
  const names = Object.create(null);
  path.traverse({
    VariableDeclarator({ node }) {
      if (node.id.type === 'Identifier') {
        names[node.id.name] = true;
      }
    }
  });
  Object.keys(names).forEach(name => {
    emitOnScope.push({ id: t.identifier(name) });
  });
}

Other packages similar to @babel/helper-hoist-variables

Changelog

Source

v7.22.5 (2023-06-08)

:bug: Bug Fix
  • babel-preset-env, babel-standalone
    • #15675 Fix using syntax-unicode-sets-regex in standalone (@nicolo-ribaudo)
:nail_care: Polish

Readme

Source

@babel/helper-hoist-variables

Helper function to hoist variables

See our website @babel/helper-hoist-variables for more information.

Install

Using npm:

npm install --save @babel/helper-hoist-variables

or using yarn:

yarn add @babel/helper-hoist-variables

FAQs

Last updated on 08 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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