MCPcopy
hub / github.com/webpack/webpack / serialize

Method serialize

lib/cache/PackFileCacheStrategy.js:620–648  ·  view source on GitHub ↗

* Serializes this instance into the provided serializer context. * @param {ObjectSerializerContext} context context

({ write, writeSeparate })

Source from the content-addressed store, hash-verified

618 * @param {ObjectSerializerContext} context context
619 */
620 serialize({ write, writeSeparate }) {
621 this._persistFreshContent();
622 this._optimizeSmallContent();
623 this._optimizeUnusedContent();
624 this._gcOldestContent();
625 for (const identifier of this.itemInfo.keys()) {
626 write(identifier);
627 }
628 write(null); // null as marker of the end of keys
629 for (const info of this.itemInfo.values()) {
630 write(info.etag);
631 }
632 for (const info of this.itemInfo.values()) {
633 write(info.lastAccess);
634 }
635 for (let i = 0; i < this.content.length; i++) {
636 const content = this.content[i];
637 if (content !== undefined) {
638 write(content.items);
639 content.writeLazy((lazy) =>
640 /** @type {NonNullable<ObjectSerializerContext["writeSeparate"]>} */
641 (writeSeparate)(lazy, { name: `${i}` })
642 );
643 } else {
644 write(undefined); // undefined marks an empty content slot
645 }
646 }
647 write(null); // null as marker of the end of items
648 }
649
650 /**
651 * Restores this instance from the provided deserializer context.

Callers 1

afterAllStoredMethod · 0.45

Calls 8

_persistFreshContentMethod · 0.95
_optimizeSmallContentMethod · 0.95
_gcOldestContentMethod · 0.95
writeFunction · 0.85
writeLazyMethod · 0.80
keysMethod · 0.65
valuesMethod · 0.45

Tested by

no test coverage detected