@babel/plugin-proposal-partial-application · Babel
https://babeljs.io/docs/babel-plugin-proposal-partial-application • 45 KB fetched Open original page
@babel/plugin-proposal-partial-application · Babel
Skip to main content
Docs Setup Try it out Videos Blog Search
Donate Team GitHub
* Modules
* TC39 Proposals
* Stage 3
* Early stages
* async-do-expressions
* destructuring-private
* discard-binding
* do-expressions
* export-default-from
* function-bind
* function-sent
* import-defer
* optional-chaining-assign
* partial-application
* pipeline-operator
* record-and-tuple
* throw-expressions
* syntax-module-blocks
* Web Compatibility
*
* TC39 Proposals
* Early stages
* partial-application On this page
@babel/plugin-proposal-partial-application
Example
(examples are from proposal)
JavaScript
function add ( x , y ) { return x + y ; }
const addOne = add ( 1 , ? ) ; // apply from the left
addOne ( 2 ) ; // 3
const addTen = add ( ? , 10 ) ; // apply from the right
addTen ( 2 ) ; // 12
let 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
JavaScript
f ( x , ? ) // partial application from left
f ( ? , x ) // partial application from right
f ( ? , x , ? ) // partial application for any arg
o . f ( x , ? ) // partial application from left
o . f ( ? , x ) // partial application from right
o . f ( ? , x , ? ) // partial application for any arg
super . f ( ? ) // partial application allowed for call on |SuperProperty|
Invalid Usage
JavaScript
f ( x + ? ) // `?` not in top-level Arguments of call
x + ? // `?` not in top-level Arguments of call
?. f ( ) // `?` not in top-level Arguments of call
new f ( ? ) // `?` not supported in `new`
super ( ? ) // `?` not supported in |SuperCall|
Installation
* npm
* Yarn
* pnpm
* Bun npm install --save-dev @babel/plugin-proposal-partial-application
yarn add --dev @babel/plugin-proposal-partial-application
pnpm add --save-dev @babel/plugin-proposal-partial-application
bun add --dev @babel/plugin-proposal-partial-application
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins" : [
[ "@babel/plugin-proposal-partial-application" , { "version" : "2018-07" } ]
]
}
Via Node API
JavaScript
require ( "@babel/core" ) . transformSync ( "code" , {
plugins : [
[ "@babel/plugin-proposal-partial-application" , { version : "2018-07" } ]
] ,
} ) ;
Options
History Version Changes v8.0.0 Added the version option with support for "2018-07"
version (required)
There is only one version currently supported:
* "2018-07" is the proposal version after the updates that was discussed in the July 2018 TC39 meeting.
References
* Proposal: Partial Application
Edit this page
Previous
optional-chaining-assign
Next
pipeline-operator
* Example
* Valid Usage
* Invalid Usage
* Installation
* Usage
* With a configuration file (Recommended)
* Via Node API
* Options
* version (required)
* References
Docs
* Learn ES2015
Community
* Videos
* User Showcase
* Stack Overflow
* Slack Channel
* X (Twitter)
* Bluesky
More
* Blog
* GitHub Org
* GitHub Repo
* Website Repo
* Old 7.x Site
* Old 6.x Site
* Old 5.x Site
Links found on this page
- Skip to main content [direct]
- Docs [direct]
- Setup [direct]
- Try it out [direct]
- Videos [direct]
- Blog [direct]
- Donate [direct]
- Team [direct]
- GitHub [direct]
- Modules [direct]
- TC39 Proposals [direct]
- Early stages [direct]
- destructuring-private [direct]
- discard-binding [direct]
- do-expressions [direct]
- export-default-from [direct]
- function-bind [direct]
- function-sent [direct]
- import-defer [direct]
- optional-chaining-assign [direct]
- pipeline-operator [direct]
- record-and-tuple [direct]
- throw-expressions [direct]
- syntax-module-blocks [direct]
- Web Compatibility [direct]
- Proposal: Partial Application [direct]
- Edit this page [direct]
- Learn ES2015 [direct]
- User Showcase [direct]
- Stack Overflow [direct]
- Slack Channel [direct]
- X (Twitter) [direct]
- Bluesky [direct]
- GitHub Org [direct]
- Website Repo [direct]
- Old 7.x Site [direct]
- Old 6.x Site [direct]
- Old 5.x Site [direct]
|
|