Doodle3D-API/jspm_packages/npm/babel-core@5.6.20/lib/babel/generation/generators/comprehensions.js

51 lines
1.1 KiB
JavaScript

/* */
"format cjs";
"use strict";
var _toolsProtectJs2 = require("./../../tools/protect.js");
var _toolsProtectJs3 = _interopRequireDefault(_toolsProtectJs2);
exports.__esModule = true;
exports.ComprehensionBlock = ComprehensionBlock;
exports.ComprehensionExpression = ComprehensionExpression;
_toolsProtectJs3["default"](module);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**
* Prints ComprehensionBlock, prints left and right.
*/
function ComprehensionBlock(node, print) {
this.keyword("for");
this.push("(");
print.plain(node.left);
this.push(" of ");
print.plain(node.right);
this.push(")");
}
/**
* Prints ComprehensionExpression, prints blocks, filter, and body. Handles generators.
*/
function ComprehensionExpression(node, print) {
this.push(node.generator ? "(" : "[");
print.join(node.blocks, { separator: " " });
this.space();
if (node.filter) {
this.keyword("if");
this.push("(");
print.plain(node.filter);
this.push(")");
this.space();
}
print.plain(node.body);
this.push(node.generator ? ")" : "]");
}