New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-preset-njs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-preset-njs

A Babel preset for njs - NGINX JavaScript.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65
decreased by-61.54%
Maintainers
1
Weekly downloads
 
Created
Source

A Babel preset for transforming JavaScript code with modern language features into code compatible with njs (NGINX JavaScript). This preset includes support for all the ECMAScript features that TypeScript supports (Stage 3+) — see Plugins for a complete list.

Installation

# using npm:
npm install --save-dev babel-preset-njs
# or using yarn:
yarn add --dev babel-preset-njs

Usage

{
  "presets": ["babel-preset-njs"]
}
{
  "presets": [
    ["babel-preset-njs", { "assumeArrayIterables": false }]
  ]
}

Via CLI

babel --presets babel-preset-njs script.js

Via Node API

require('@babel/core').transform('code', {
  presets: [require('babel-preset-njs')],
})

Options

assumeArrayIterables

boolean, defaults to true

Assume that all iterables used in for...of loops, array spread syntax and array destructuring are arrays. This produces more compact and significantly more performant code, but it will fail in runtime if the iterable is not an array.

TypeScript transpiler uses the same approach for ES5 target when downlevelIteration is disabled. It also indicates error when the iterable is not an array.

It sets the following plugin options:

asyncHelpers

'external', 'local', 'inline'

Toggles how async-to-promises injects its helpers:

  • 'external' — injects import from babel-plugin-transform-async-to-promises/helpers into each file with async/await

  • 'local' — injects the needed helper functions into each file with async/await

  • 'inline' — inlines the needed helper code in place of each occurrence of async/await

Defaults to 'external' if Rollup or webpack is detected, otherwise 'local'.

looseClasses

boolean, defaults to true

Define class methods and properties using a simple assignment expression instead of Object.defineProperty(). This produces more compact and performant code, but it might produce unexpected results in some (corner) cases. TypeScript transpiler uses the same approach.

It sets the following plugin options:

looseObjectRestSpread

boolean, defaults to true

Transform object rest/spread properties using Object.assign() instead of Babel’s objectSpread helper. This produces more compact and performant code, but it might produce unexpected results in some (corner) cases (when overwriting read-only target property). TypeScript transpiler uses the same approach.

It sets the following plugin options:

looseParameters

boolean, defaults to true

In loose mode, function parameters with default values will be counted into the arity of the function. This is not spec behaviour where these parameters do not add to function arity, but it produces more compact and performant code. TypeScript transpiler uses the same approach.

It sets the following plugin options:

Plugins

The list of included Babel plugins is available here.

References

License

This project is licensed under MIT License.

Keywords

FAQs

Package last updated on 28 Nov 2020

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