recital / core / dist / lib / tools / parse-toml-meta.js
parse-toml-meta.js
Raw
"use strict";
/**
 * Copyright (c) 2022 Amorphous
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseTOMLMeta = void 0;
const parse_string_1 = __importDefault(require("@iarna/toml/parse-string"));
const parseTOMLMeta = (tomlString) => {
    try {
        const tomlObj = (0, parse_string_1.default)(tomlString);
        return tomlObj;
    }
    catch (err) {
        console.warn("TOML parser failed. String is instead being saved as one unit in the '_unparsed' field, where it can be processed later", err);
        return {
            _unparsed: tomlString,
        };
    }
};
exports.parseTOMLMeta = parseTOMLMeta;