babel-plugin-pipe-operator npm

Overload the pipe operator (`|`) to provide Elixir/F#/Shell-like behavior

2 years after

babel-plugin-pipe-operator

Overload the pipe operator (|) to provide Elixir/F#/Shell-like behavior

Examples

import { map, filter } from 'lodash';

const array = [1, 2, 3, 4, 5];

array
| map(n => n * 2)
| filter(n => n % 3 == 0);

Disabling in current scope

If you want to use the original pipe operator, you can disable this plugin in current scope (and it children scopes) using "no pipe" directive

const fn = () => {
  const arr = [1, 2, 3] | map(n => n + 1);

  return () => {
    "no pipe";

    arr.map(n => n | 1);
  };
};

Installation

$ npm install --save-dev babel-plugin-pipe-operator

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["pipe-operator"]
}

Via CLI

$ babel --plugins pipe-operator script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["pipe-operator"]
});

License

MIT

Related Repositories

modernWebDevBuild

modernWebDevBuild

An opinionated Modern Web Development build ...

babel-plugin-operator-overload

babel-plugin-operator-overload

Babel plugin for overloading operators ...

babel-plugin-pipe-operator-curry

babel-plugin-pipe-operator-curry

Alternative to babel-plugin-pipe-operator ...


Top Contributors

miraks

Releases

-   1.0.0 zip tar