Babel
  • Docs
  • Setup
  • Try it out
  • Videos
  • Blog
  • Donate
  • Team
  • GitHub
Edit

@babel/plugin-proposal-function-sent

Example

function* generator() {
    console.log("Sent", function.sent);
    console.log("Yield", yield);
}

const iterator = generator();
iterator.next(1); // Logs "Sent 1"
iterator.next(2); // Logs "Yield 2"

Is compiled roughly to

let generator = _skipFirstGeneratorNext(function* () {
    const _functionSent = yield;
    console.log("Sent", _functionSent);
    console.log("Yield", yield);
});

const iterator = generator();
iterator.next(1); // Logs "Sent 1"
iterator.next(2); // Logs "Yield 2"

Installation

npm install --save-dev @babel/plugin-proposal-function-sent

Usage

With a configuration file (Recommended)

{
  "plugins": ["@babel/plugin-proposal-function-sent"]
}

Via CLI

babel --plugins @babel/plugin-proposal-function-sent script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/plugin-proposal-function-sent"]
});

References

  • Proposal
  • Example
  • Installation
  • Usage
    • With a configuration file (Recommended)
    • Via CLI
    • Via Node API
  • References
Babel
Docs
Learn ES2015
Community
VideosUser ShowcaseStack OverflowSlack ChannelTwitter
More
BlogGitHub OrgGitHub RepoWebsite RepoOld 6.x SiteOld 5.x Site