How to use the @jsdoc/core.cast function in @jsdoc/core

To help you get started, we’ve selected a few @jsdoc/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jsdoc / jsdoc / packages / jsdoc / lib / jsdoc / tag / type.js View on Github external
function parseName(tagInfo) {
    // like '[foo]' or '[ foo ]' or '[foo=bar]' or '[ foo=bar ]' or '[ foo = bar ]'
    // or 'foo=bar' or 'foo = bar'
    if ( /^(\[)?\s*(.+?)\s*(\])?$/.test(tagInfo.name) ) {
        tagInfo.name = RegExp.$2;
        // were the "optional" brackets present?
        if (RegExp.$1 && RegExp.$3) {
            tagInfo.optional = true;
        }

        // like 'foo=bar' or 'foo = bar'
        if ( /^(.+?)\s*=\s*(.+)$/.test(tagInfo.name) ) {
            tagInfo.name = RegExp.$1;
            tagInfo.defaultvalue = cast(RegExp.$2);
        }
    }

    return tagInfo;
}
github jsdoc / jsdoc / packages / jsdoc / lib / jsdoc / src / astnode.js View on Github external
case Syntax.RestElement:
            str = nodeToValue(node.argument);
            break;

        case Syntax.ThisExpression:
            str = 'this';
            break;

        case Syntax.UnaryExpression:
            // like -1. in theory, operator can be prefix or postfix. in practice, any value with a
            // valid postfix operator (such as -- or ++) is not a UnaryExpression.
            str = nodeToValue(node.argument);

            if (node.prefix === true) {
                str = cast(node.operator + str);
            }
            else {
                // this shouldn't happen
                throw new Error(`Found a UnaryExpression with a postfix operator: ${node}`);
            }
            break;

        case Syntax.VariableDeclarator:
            str = nodeToValue(node.id);
            break;

        default:
            str = '';
    }

    return str;
github jsdoc / jsdoc / packages / jsdoc-cli / lib / flags.js View on Github external
        coerce: ((str) => cast(querystring.parse(str))),
        description: 'A query string to parse and store (for example, `foo=bar&baz=true`).',

@jsdoc/core

Core functionality for JSDoc.

Apache-2.0
Latest version published 7 months ago

Package Health Score

70 / 100
Full package analysis