Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swc/helpers

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swc/helpers

External helpers for the swc project.

  • 0.4.36
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14M
increased by1.32%
Maintainers
1
Weekly downloads
 
Created

What is @swc/helpers?

The @swc/helpers package provides a set of helper functions designed to be used with the SWC compiler. These helpers are primarily used to polyfill or transform code in a way that makes newer JavaScript features compatible with older environments. This includes handling classes, async functions, spread operators, and more, ensuring that code utilizing modern JavaScript syntax can be transpiled for compatibility with environments that do not natively support these features.

What are @swc/helpers's main functionalities?

Class handling

This feature allows for the transformation of ES6 classes into a format that can be understood by older JavaScript engines. The code sample demonstrates how a class with a method is transformed using the @swc/helpers package.

"use strict";
var _createClass = require("@swc/helpers/lib/_create_class.js").default;
var MyClass = /*#__PURE__*/function () {
  function MyClass() {}
  _createClass(MyClass, [{
    key: "method",
    value: function method() {}
  }]);
  return MyClass;
}();

Async/Await handling

This feature transforms async functions into generator functions with a regenerator runtime, making it possible to use async/await syntax in environments that do not support it natively. The code sample shows how an async function is transformed using @swc/helpers.

"use strict";
var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default;
function exampleFunction() {
  return _asyncToGenerator(function* () {
    var data = yield fetchData();
    console.log(data);
  })();
}

Spread operator handling

This feature provides a way to transform the spread operator in arrays and function calls into equivalent ES5 code. The code sample demonstrates how an array is concatenated with another array using the spread operator, transformed by @swc/helpers.

"use strict";
var _toConsumableArray = require("@swc/helpers/lib/_to_consumable_array.js").default;
var arr1 = [1, 2, 3];
var arr2 = [4, 5].concat(_toConsumableArray(arr1));

Other packages similar to @swc/helpers

Keywords

FAQs

Package last updated on 17 Aug 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc