@babel/plugin-proposal-partial-application
Example
(examples are from proposal)
function add(x, y) { return x + y; }const addOne = add(1, ?); // apply from the leftaddOne(2); // 3const addTen = add(?, 10); // apply from the rightaddTen(2); // 12let newScore = player.score|> add(7, ?)|> clamp(0, 100, ?); // shallow stack, the pipe to `clamp` is the same frame as the pipe to `add`.
Valid Usage
f(x, ?) // partial application from leftf(?, x) // partial application from rightf(?, x, ?) // partial application for any argo.f(x, ?) // partial application from lefto.f(?, x) // partial application from righto.f(?, x, ?) // partial application for any argsuper.f(?) // partial application allowed for call on |SuperProperty|
Invalid Usage
f(x + ?) // `?` not in top-level Arguments of callx + ? // `?` not in top-level Arguments of call?.f() // `?` not in top-level Arguments of callnew f(?) // `?` not supported in `new`super(?) // `?` not supported in |SuperCall|
Installation
$ npm install --save-dev @babel/plugin-proposal-partial-application
Usage
Add the following line to your .babelrc file:
{"plugins": ["@babel/plugin-proposal-partial-application"]}
babel --plugins @babel/plugin-proposal-partial-application script.js
Via Node API
require("@babel/core").transform("code", {plugins: ["@babel/plugin-proposal-partial-application"]});