All files / parser/nodes argumentCall.js

80% Statements 4/5
100% Branches 4/4
66.67% Functions 2/3
80% Lines 4/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                        15x     15x     15x                   6x      
import Node from './node';
 
/**
 * Matches an argument inside a FunctionCall. This supports both the named
 * parameter's name and the value of parameter.
 *
 * @example
 * argument
 * name: argument
 */
 
export default class ArgumentCall extends Node {
    /**
     * Creates a argument
     * 
     * @param {Expression} value - the argument value
     * @param {?Identifier} name - the name of the argument
     * @param {Object} position a position from nearley
     */
    constructor (value: Expression, name: Identifier, position: Object) {
        super(position);
 
        /** @type {Expression} */
        this.value = value;
        
        /** @type {?Identifier} */
        this.name = name ? name[0] : name;
    }
    
    /** @override */
    get children () {
        return ['value'];
    }
    
    /** @override */
    toString() {
        return this.name ? `${this.name}: ${this.value}` : `${this.value}`;
    }
}