@stencila/jesta
Version:
Stencila plugin for executable documents using JavaScript
34 lines (33 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.encode = exports.schema = void 0;
const errors_1 = require("./util/errors");
exports.schema = {
title: 'encode',
description: 'Encode a Stencila node to content of a specific format.',
required: ['node', 'format'],
properties: {
node: {
description: 'The node to be encoded',
},
format: {
description: 'The format to be encoded to',
enum: ['json'],
},
theme: {
description: 'The theme for the exported content (only applies to some formats)',
type: 'string',
},
},
interruptible: false,
};
async function encode(node, format, _theme) {
if (format === 'json') {
return Promise.resolve(JSON.stringify(node, null, ' '));
}
else {
throw new errors_1.CapabilityError(`encoding to format "${format}"`);
}
}
exports.encode = encode;
encode.schema = exports.schema;