UNPKG

firescript

Version:
60 lines (52 loc) 1.4 kB
const JSElement = require('./JSElement') const ALLOWED_LEFT_CHILDS = [ 'Identifier', 'ArrayPattern', 'ObjectPattern' ] const ALLOWED_RIGHTT_CHILDS = [ 'ThisExpression', 'Identifier', 'Literal', 'ArrayExpression', 'ObjectExpression', 'FunctionExpression', 'ArrowFunctionExpression', 'ClassExpression', 'TaggedTemplateExpression', 'MemberExpression', 'Super', 'MetaProperty', 'NewExpression', 'CallExpression', 'UpdateExpression', 'AwaitExpression', 'UnaryExpression', 'BinaryExpression', 'LogicalExpression', 'ConditionalExpression', 'YieldExpression', 'AssignmentExpression', 'SequenceExpression' ] /** * AssignmentPattern * * @class AssignmentPattern * @extends JSElement * * interface AssignmentPattern { * type: 'AssignmentPattern'; * left: Identifier | BindingPattern; * right: Expression; * } */ class AssignmentPattern extends JSElement { constructor (ast) { super(ast) this.left = this.createElement(ast.left, ALLOWED_LEFT_CHILDS) this.right = this.createElement(ast.right, ALLOWED_RIGHTT_CHILDS) } compile (buffer) { // buffer.registerItem(this.location) buffer.write(this.left) buffer.write(' = ') buffer.write(this.right) } toESString (ctx) { return this.renderElement( this.left.toESString(ctx) + ' = ' + this.right.toESString(ctx) ) } } module.exports = AssignmentPattern