How to use the jsdoctypeparser.Builder.TypeUnion function in jsdoctypeparser

To help you get started, we’ve selected a few jsdoctypeparser 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 jscs-dev / jscs-jsdoc / lib / jsdoc.js View on Github external
function _iterateDocTypes(node, cb) {
    var res;

    switch (true) {
        case node instanceof TypeBuilder.TypeUnion:
            // optional: boolean,
            // nullable: boolean,
            // variable: boolean,
            // nonNullable: boolean,
            // all: boolean,
            // unknown: boolean,
            // types: Array.
            res = node.types.map(function(subnode) {
                if (node.collectionNode) {
                    subnode.parentElement = node.collectionNode;
                }
                return _iterateDocTypes(subnode, cb);
            }) || [];
            if (node.nullable) {
                var subnode = {typeName: 'null', collectionNode: node};
                res.concat(cb(subnode));
github tj / dox / lib / dox.js View on Github external
var types = (function transform(type) {
    if(type instanceof Builder.TypeUnion) {
      return type.types.map(transform);
    } else if(type instanceof Builder.TypeName) {
      return type.name;
    } else if(type instanceof Builder.RecordType) {
      return type.entries.reduce(function(obj, entry) {
        obj[entry.name] = transform(entry.typeUnion);
        return obj;
      }, {});
    } else {
      return type.toString();
    }
  }(result));