0.1.4 • Published 7 years ago

babel-plugin-transform-function-composition-name v0.1.4

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

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
    }]
  ]
});