Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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));
}
break;
case node instanceof TypeBuilder.TypeName:
// name: string
node.typeName = node.name;
res = cb(node);
break;
case node instanceof TypeBuilder.GenericType:
// genericTypeName: string,
// parameterTypeUnions: Array.
node.typeName = node.genericTypeName.type;
res = cb(node) || [];
if (node.parameterTypeUnions) {
// node.parameterTypeUnions.collectionNode = node;
res.concat(node.parameterTypeUnions.map(function(subnode) {
subnode.parentElement = node;
_iterateDocTypes(subnode, cb);
}));
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));