You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					34 lines
				
				573 B
			
		
		
			
		
	
	
					34 lines
				
				573 B
			| 
											3 years ago
										 | import Node from '../core/Node.js'; | ||
|  | 
 | ||
|  | class SwitchNode extends Node { | ||
|  | 
 | ||
|  | 	constructor( node, components = 'x' ) { | ||
|  | 
 | ||
|  | 		super(); | ||
|  | 
 | ||
|  | 		this.node = node; | ||
|  | 		this.components = components; | ||
|  | 
 | ||
|  | 	} | ||
|  | 
 | ||
|  | 	getType( builder ) { | ||
|  | 
 | ||
|  | 		return builder.getTypeFromLength( this.components.length ); | ||
|  | 
 | ||
|  | 	} | ||
|  | 
 | ||
|  | 	generate( builder, output ) { | ||
|  | 
 | ||
|  | 		const nodeType = this.node.getType( builder ); | ||
|  | 		const nodeSnippet = this.node.build( builder, nodeType ); | ||
|  | 
 | ||
|  | 		const snippet = `${nodeSnippet}.${this.components}`; | ||
|  | 
 | ||
|  | 		return builder.format( snippet, this.getType( builder ), output ); | ||
|  | 
 | ||
|  | 	} | ||
|  | 
 | ||
|  | } | ||
|  | 
 | ||
|  | export default SwitchNode; |