🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

babel-plugin-comparison-chaining

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-comparison-chaining

Unlike the discipline of mathematics, JavaScript interpreters don't recognize chains of comparison operators as a linear sequence, but as recursive calls compare the right-most node and everything to the left of the operator. If a developer wishes to wri

latest
Source
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

babel-plugin-comparison-chaining

Unlike the discipline of mathematics, JavaScript interpreters don't recognize chains of comparison operators as a linear sequence, but as recursive calls compare the right-most node and everything to the left of the operator. If a developer wishes to write conditionally chained expressions that are linearly evaluated, this plugin is of use.

Examples

JavaScript will recursively evaluate the right-most node compared against whatever is on the left.

// written
1 < 6 < 4 < 2 < 7

//evaluated
   (1 < 6 < 4 < 2) < 7 
  ((1 < 6 < 4) < 2) < 7
 (((1 < 6) < 4) < 2) < 7
((((1) < 6) < 4) < 2) < 7

Written expression evaluated linearly

1 < 6 && 6 < 4 && 4 < 2 && 2 < 7;

Installation

$ npm install --save-dev babel-plugin-comparison-chaining

Usage

.babelrc

{
  "plugins": ["comparison-chaining"]
}

Via CLI

$ babel --plugins comparison-chaining script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['comparison-chaining']
});

License

MIT

Keywords

babel

FAQs

Package last updated on 01 Jan 2021

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