@prismicio/client
Version:
The official JavaScript + TypeScript client library for Prismic
32 lines (30 loc) • 847 B
JavaScript
import { RichTextReversedNodeType } from "./types.js";
//#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[RichTextReversedNodeType[type] || type];
if (tagSerializer) return tagSerializer({
type,
node,
text,
children,
key
});
};
};
//#endregion
export { wrapMapSerializer };
//# sourceMappingURL=wrapMapSerializer.js.map