@wordpress/core-data
Version:
Access to and manipulation of core WordPress entities.
27 lines (26 loc) • 712 B
JavaScript
// packages/core-data/src/utils/crdt-text.ts
import { RichTextData } from "@wordpress/rich-text";
var RICH_TEXT_CACHE_MAX_SIZE = 500;
function createRichTextDataCache(maxSize) {
const cache = /* @__PURE__ */ new Map();
return function(value) {
const cached = cache.get(value);
if (cached) {
return cached;
}
const result = RichTextData.fromHTMLString(value);
if (cache.size >= maxSize) {
cache.delete(cache.keys().next().value);
}
cache.set(value, result);
return result;
};
}
var getCachedRichTextData = createRichTextDataCache(
RICH_TEXT_CACHE_MAX_SIZE
);
export {
createRichTextDataCache,
getCachedRichTextData
};
//# sourceMappingURL=crdt-text.mjs.map