bpt
babel-plugin-transform-ternary-to-if-else
npm i babel-plugin-transform-ternary-to-if-else
bpt

babel-plugin-transform-ternary-to-if-else

Transform ternary operators (conditional expressions) into if-else statements

by OpenGG

2.0.1 (see all)License:GPL-3.0TypeScript:Not Found
npm i babel-plugin-transform-ternary-to-if-else
Readme

babel-plugin-transform-ternary-to-if-else

Build Status Coverage Status

Transform ternary operators (conditional expressions) into if-else statements.

Demo

Live demo

Example

In

const val = a1 ? a2 : a3;

Out

const val = function() {
  if (a1) {
    return a2;
  }
  return a3;
}();

Installation

npm install babel-plugin-transform-ternary-to-if-else

Usage

.babelrc

{
  "plugins": ["transform-ternary-to-if-else"]
}

Via CLI

babel --plugins transform-ternary-to-if-else script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-ternary-to-if-else"]
});

Downloads/wk

4

GitHub Stars

10

LAST COMMIT

4mos ago

MAINTAINERS

1

CONTRIBUTORS

1

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
2.0.1
latest
4mos ago
No alternatives found
No tutorials found
Add a tutorial