Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
map(([idx, nod]) => {
const mat = nodeStr(idx).match(re(`(?<=^|\\n)---${hspace}*\\n?$`));
if (!mat) {
return null;
}
// Offset of the actual separator line (this may deviate from the)
const offStart = mat.index + start(idx);
const offEnd = offStart + size(mat[0]);
// Is there a new line or EOF before/after the separator?
const before = Boolean(str.slice(0, offStart).match(re(`(^|(^|\\n)${hspace}*\\n)$`)));
const after = Boolean(str.slice(offEnd).match(re(`^(${hspace}*(\\n${hspace}*(\\n|$))|$)`)));
return {
idx, nod, offStart, offEnd, before, after,
};
}),
filter(identity),
function type(property) {
const types = Array.isArray(property[keyword`type`]) ? property[keyword`type`] : [property[keyword`type`]];
const realtypes = flist(filter(types, mytype => mytype !== 'null' && mytype !== undefined));
if (property[keyword`allOf`] || property[keyword`anyOf`] || property[keyword`oneOf`] || property[keyword`not`]) {
return text(i18n`Merged`);
} else if (size(realtypes) === 0) {
return text(i18n`Not specified`);
}
return (size(realtypes) === 1) ? inlineCode(realtypes[0]) : text(i18n`Multiple`);
}
function nullable(property) {
const types = Array.isArray(property[keyword`type`]) ? property[keyword`type`] : [property[keyword`type`]];
const nulltypes = flist(filter(types, mytype => mytype === keyword`null`));
if (size(nulltypes)) {
return text(i18n`can be null`);
}
return text(i18n`cannot be null`);
}
function type(property) {
const types = Array.isArray(property[keyword`type`]) ? property[keyword`type`] : [property[keyword`type`]];
const realtypes = flist(filter(types, mytype => mytype !== 'null' && mytype !== undefined));
if (property[keyword`allOf`] || property[keyword`anyOf`] || property[keyword`oneOf`] || property[keyword`not`]) {
return text(i18n`Merged`);
} else if (size(realtypes) === 0) {
return text(i18n`Not specified`);
}
return (size(realtypes) === 1) ? inlineCode(realtypes[0]) : text(i18n`Multiple`);
}