@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
28 lines (27 loc) • 867 B
JavaScript
const require_types = require("./types.cjs");
//#region src/richtext/wrapMapSerializer.ts
/**
* Wraps a map serializer into a regular function serializer
*
* @remarks
* This is a low level helper mainly intended to be used by higher level packages Most users
* aren't expected to this function directly
* @typeParam SerializerReturnType - Return type of the map serializer
* @param mapSerializer - Map serializer to wrap
* @returns A regular function serializer
*/
const wrapMapSerializer = (mapSerializer) => {
return (type, node, text, children, key) => {
const tagSerializer = mapSerializer[require_types.RichTextReversedNodeType[type] || type];
if (tagSerializer) return tagSerializer({
type,
node,
text,
children,
key
});
};
};
//#endregion
exports.wrapMapSerializer = wrapMapSerializer;
//# sourceMappingURL=wrapMapSerializer.cjs.map