@intlayer/core
Version:
Includes core Intlayer functions like translation, dictionary, and utility functions shared across multiple packages.
33 lines • 896 B
JavaScript
import {
formatNodeType,
NodeType
} from "../../types/index.mjs";
import { getInsertionValues } from "./getInsertionValues.mjs";
const insertion = (content) => {
const getInsertions = () => {
if (typeof content === "string") {
return getInsertionValues(content);
}
let stringContent = void 0;
if (typeof content === "function") {
stringContent = content();
} else if (typeof content.then === "function") {
stringContent = async () => getInsertionValues(await content);
}
if (typeof stringContent === "string") {
return getInsertionValues(stringContent);
}
try {
return getInsertionValues(JSON.stringify(content));
} catch (e) {
return [];
}
};
return formatNodeType(NodeType.Insertion, content, {
fields: getInsertions()
});
};
export {
insertion as insert
};
//# sourceMappingURL=insertion.mjs.map