UNPKG

@stencila/jesta

Version:

Stencila plugin for executable documents using JavaScript

31 lines (30 loc) 930 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decode = exports.schema = void 0; const errors_1 = require("./util/errors"); exports.schema = { title: 'decode', description: 'Decode content of a specific format into a Stencila node.', required: ['content', 'format'], properties: { content: { description: 'The content to be decoded', type: 'string', }, format: { description: 'The format to be decoded from', enum: ['json'], }, }, interruptible: false, }; function decode(content, format) { if (format === 'json') { return Promise.resolve(JSON.parse(content)); } else { throw new errors_1.CapabilityError(`decoding from format "${format !== null && format !== void 0 ? format : 'undefined'}"`); } } exports.decode = decode; decode.schema = exports.schema;