Sha256: 0d1c1a324ac32f66bfecddc5ccc4ff264146ec1cbca7c6fc1f6c1c63b107c80c

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

const { concat, join } = require("../prettier");
const { literal } = require("../utils");

module.exports = {
  break: (path, opts, print) => {
    const content = path.getValue().body[0];

    if (content.body.length === 0) {
      return "break";
    }

    if (content.body[0].body[0].type === "paren") {
      return concat([
        "break ",
        path.call(print, "body", 0, "body", 0, "body", 0, "body", 0)
      ]);
    }

    return concat(["break ", join(", ", path.call(print, "body", 0))]);
  },
  next: (path, opts, print) => {
    const args = path.getValue().body[0].body[0];

    if (!args) {
      return "next";
    }

    if (args.body[0].type === "paren") {
      // Ignoring the parens node and just going straight to the content
      return concat([
        "next ",
        path.call(print, "body", 0, "body", 0, "body", 0, "body", 0)
      ]);
    }

    return concat(["next ", join(", ", path.call(print, "body", 0))]);
  },
  yield: (path, opts, print) => {
    if (path.getValue().body[0].type === "paren") {
      return concat(["yield", path.call(print, "body", 0)]);
    }

    return concat(["yield ", join(", ", path.call(print, "body", 0))]);
  },
  yield0: literal("yield")
};

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
prettier-0.20.1 src/nodes/flow.js
prettier-0.20.0 src/nodes/flow.js
prettier-0.19.1 src/nodes/flow.js
prettier-0.19.0 src/nodes/flow.js
prettier-0.18.2 src/nodes/flow.js
prettier-0.18.1 src/nodes/flow.js
prettier-0.18.0 src/nodes/flow.js
prettier-0.17.0 src/nodes/flow.js
prettier-0.16.0 src/nodes/flow.js