cbor-edn
Version: 
Parse CBOR Extended Diagnostic Notation as defined by [draft-ietf-cbor-edn-literals-16](https://www.ietf.org/archive/id/draft-ietf-cbor-edn-literals-16.html) and some CBOR working group discussions.
31 lines (30 loc) • 804 B
JavaScript
import { parse, } from '../lib/edn.js';
export { version } from './version.js';
const source = 'parseEDN';
/**
 * Parse a CBOR Extended Diagnostic Notation (EDN) string.
 *
 * @param edn String to parse.
 * @param opts Encode options.
 * @returns Bytes corresponding to the EDN.
 * @throws On syntax error.
 */
export function parseEDN(edn, opts) {
    opts = {
        startRule: 'one_item',
        grammarSource: source,
        ...opts,
    };
    try {
        return parse(edn, opts);
    }
    catch (e) {
        const ef = e;
        if (typeof ef.format === 'function') {
            // @ts-expect-error message is not readonly
            ef.message = ef.format([{ source: opts.grammarSource, text: edn }]);
        }
        throw e;
    }
}
export { registerAppString, } from './string.js';