cream-and-sugar
Version:
A deliciously functional syntax for JavaScript with native support for JSX
12 lines (10 loc) • 347 B
JavaScript
import { compile, nodes } from '../utils';
/*
* Translate parenwraps 1-1.
*/
compile(nodes.WrapNode, function () {
const dropParens = this.item.type === 'Fun' || this.item.type === 'FunctionCall';
const begin = dropParens ? '' : '(';
const end = dropParens ? '' : ')';
return `${begin}${this.item.compile(true)}${end}`;
});