@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
28 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.codeBlock = codeBlock;
exports.codeInline = codeInline;
exports.jsonWithLimit = jsonWithLimit;
const json_1 = require("../../util/json");
const environment_1 = require("../../dataflow/environments/environment");
function codeBlock(language, code) {
return `\n\`\`\`${language}\n${code?.trim() ?? ''}\n\`\`\`\n`;
}
function codeInline(code) {
return `<code>${code}</code>`;
}
function jsonWithLimit(object, maxLength = 5_000, tooLongText = '_As the code is pretty long, we inhibit pretty printing and syntax highlighting (JSON, hiding built-in):_') {
const prettyPrinted = JSON.stringify(object, json_1.jsonReplacer, 2);
return `
${prettyPrinted.length > maxLength ? tooLongText : ''}
${codeBlock(prettyPrinted.length > maxLength ? 'text' : 'json', prettyPrinted.length > 5_000 ? JSON.stringify(object, (k, v) => {
if (typeof v === 'object' && v !== null && 'id' in v && v['id'] === 0 && 'memory' in v && v['memory']) {
return '<BuiltInEnvironment>';
}
else {
return (0, environment_1.builtInEnvJsonReplacer)(k, v);
}
}) : prettyPrinted)}
`;
}
//# sourceMappingURL=doc-code.js.map