1.0.0 • Published 5 years ago

babel-plugin-transform-opipe v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

babel-plugin-transform-opipe npm (scoped) NpmLicense David Travis (.com) Coveralls github

A babel parser and plugin implementing the opipe operator, to easily pipe an object.

const _ = require('lodash');
const ten = [1,2,3,4]
    :| _.filter( n=>n%2 ) // [1,3]
    :| _.map( n=>n**2 )   // [1,9]
    :| _.sum();           // 10

Installation

npm install --save-dev babel-plugin-transform-opipe

Opipe operator

The opipe operator is defined as following:

a :| b(...args) ≡ b(a, ...args)

It's handy to quickly and easily pipe objects through method-like-functions that accept their logical this as the first parameter.

Quickstart

Install the babel suite, enable this plugin, then use babel to transpile your code The easiest way to get started, is the following:

npm install --save babel-plugin-transform-opipe babel-meta
npx babel-node --plugins='babel-plugin-transform-opipe' your_opipeful_file.js