JSPM

@putout/plugin-generators

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9110
  • Score
    100M100P100Q148524F
  • License MIT

🐊Putout plugin improves code related to generators

Package Exports

  • @putout/plugin-generators
  • @putout/plugin-generators/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@putout/plugin-generators) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@putout/plugin-generators NPM version

The function* declaration creates a binding of a new generator function to a given name. A generator function can be exited and later re-entered, with its context (variable bindings) saved across re-entrances.

(c) MDN

🐊Putout plugin improves Generator-related code.

Install

npm i @putout/plugin-generators -D

Rules

Config

{
    "rules": {
        "generators/add-missing-star": "on",
        "generators/convert-multiple-to-generator": "on"
    }
}

add-missing-star

The function* declaration creates a binding of a new generator function to a given name.

(c) MDN

❌ Example of incorrect code

function hello() {
    yield;
    'world';
}

function func2() {
    yield * func1();
}

βœ… Example of correct code

function* hello() {
    yield 'world';
}

function* func2() {
    yield* func1();
}

convert-multiply-to-generator

Checkout in 🐊Putout Editor.

❌ Example of incorrect code

const a = 5 * function hello() {};

βœ… Example of correct code

const a = 5;

function* hello() {}

License

MIT