Skip to content

Intai/babel-plugin-transform-function-composition-name

Repository files navigation

babel-plugin-transform-function-composition-name

A Babel transform plugin to name composition of functions.

Build Status Coverage Status Codacy Badge

Want to achieve

For example when debugging the following code with Ramda:

const getValue = R.prop(
  'value'
);

const getValues = R.map(
  getValue
);

const calc = R.pipe(
  R.unapply(R.identity),
  getValues,
  R.sum
);

calc(
  { value: 1 },
  { value: 2 },
  undefined
);

The call stack from browser is not very useful:

It would be easier to debug with variable names:

Installation

$ npm install babel-plugin-transform-function-composition-name

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": [
    ["transform-function-composition-name", {
      "callee": "^R$",
      "variable": "^(?!(construct))"
    }]
  ]
}

Via Node API

require("babel-core").transform("code", {
  plugins: [
    ["transform-function-composition-name", {
      // configure function composition to be transformed.
      "callee": /^R$/, // optional function callee
      "variable": /^(?!(construct))/ // optional variable name
    }]
  ]
});

About

A Babel transform plugin for function composition

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages