Socket
Socket
Sign inDemoInstall

@babel/helper-hoist-variables

Package Overview
Dependencies
4
Maintainers
4
Versions
71
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
Maintainers
4
Install size
2.39 MB
Created

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.24.7 (2024-06-05)

:bug: Bug Fix
  • babel-node
    • #16554 Allow extra flags in babel-node (@nicolo-ribaudo)
  • babel-traverse
  • babel-helper-transform-fixture-test-runner, babel-plugin-proposal-explicit-resource-management
:house: Internal
  • babel-helpers, babel-runtime-corejs2, babel-runtime-corejs3, babel-runtime

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 05 Jun 2024

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