jsdoc:如何使用括号表示法记录属性?

时间:2015-10-23 11:02:32

标签: javascript properties documentation jsdoc

鉴于这个相当愚蠢的功能,应该如何编写文档" range" PARAM?

/**
* @param {number} value
 * @param {Object} range
 * @param {number} range['<']
 * @param {number} range['<=']
 * @param {number} range['>']
 * @param {number} range['>=']
 */
function testIsInRange(value, range) {
    var threshold;

    if ((threshold = range['<'], threshold !== undefined) && !(value < threshold)) {
        fail('Value must be less than ' + threshold);
    }

    if ((threshold = range['<='], threshold !== undefined) && !(value <= threshold)) {
        fail('Value must be less than or equal to ' + threshold);
    }

    if ((threshold = range['>'], threshold !== undefined) && !(value > threshold)) {
        fail('Value must be greater than ' + threshold);
    }

    if ((threshold = range['>='], threshold !== undefined) && !(value >= threshold)) {
        fail('Value must be greater than or equal to ' + threshold);
    }
}

点和括号表示法似乎都不起作用。属性类型(对象和数字)被识别,但它们的名称不是。

0 个答案:

没有答案