Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const typefact = (() => {
if (nulltype) {
return [inlineCode(`null${isarray}`), text(i18n`, the value must be null`)];
} else if (singletype && firsttype && typeof firsttype === 'string') {
return [inlineCode(firsttype + isarray)];
} else if (!singletype) {
return [text(isarray ? i18n`an array of the following:` : i18n`any of the folllowing: `), ...flist(flat(realtypes.map((mytype, index) => [inlineCode(mytype || i18n`not defined`), text(index === realtypes.length - 1 ? '' : i18n` or `)])))];
} else if (merged) {
return [text(isarray ? 'an array of merged types' : i18n`merged type`)];
}
// console.log('unknown type', realtypes, singletype, merged, definition[s.pointer]);
return [text(i18n`unknown` + isarray)];
})();
static isPureScript(basename) {
// create pairwise combinations of extension and template name
const exts = into(flat(PURE_EXTENSIONS
.map((ext) => PURE_TEMPLATES
.map((template) => `${ext}.${template}`))), Array);
// use early termination, so that the rest of the statement doesn't
// have to be evaluated once the first match has been found.
const matches = exts.reduce((match, ext) => match
|| basename === ext
|| basename.endsWith(`_${ext}`), false);
return matches;
}
const description = definition[s.meta] && definition[s.meta].longdescription ? definition[s.meta].longdescription : paragraph(text(i18n`no description`));
return [
heading(level + 1, text(name)),
description,
...makecomment(definition),
paragraph(inlineCode(name)),
makefactlist(name, definition, required),
...maketypesection(definition, level + 1),
...makeconstraintssection(definition, level + 1),
...makedefault(definition, level + 1),
...makeexamples(definition, level + 1),
...makerestrictions(definition, level + 1),
];
}))),
...flist(flat(Object.entries(patternProperties || {}).map(([name, definition]) => {
const description = definition[s.meta].longdescription || paragraph(text(i18n`no description`));
return [
heading(level + 1, [text(i18n`Pattern: `), inlineCode(name)]),
description,
...makecomment(definition),
paragraph(inlineCode(name)),
makefactlist(name, definition, required),
...maketypesection(definition, level + 1),
...makeconstraintssection(definition, level + 1),
...makedefault(definition, level + 1),
...makeexamples(definition, level + 1),
...makerestrictions(definition, level + 1),
];
}))),
...((definition) => {
paragraph(text(i18n`Reference this group by using`)),
code('json', JSON.stringify({ $ref: `${subschema[s.id]}#${subschema[s.pointer]}` })),
grouptable,
...makeproplist(
subschema[keyword`properties`],
subschema[keyword`patternProperties`],
subschema[keyword`additionalProperties`],
subschema[keyword`required`],
2,
),
];
});
return [
heading(1, text(i18n`${gentitle(schema[s.titles], schema[keyword`type`])} Definitions`)),
...flist(flat(defgroups)),
];
}
return [];
}