MCPcopy
hub / github.com/webpack/webpack / deserialize

Method deserialize

lib/cache/PackFileCacheStrategy.js:654–700  ·  lib/cache/PackFileCacheStrategy.js::Pack.deserialize

* Restores this instance from the provided deserializer context. * @param {ObjectDeserializerContext & { logger: Logger }} context context

({ read, logger })

Source from the content-addressed store, hash-verified

652 * @param {ObjectDeserializerContext & { logger: Logger }} context context
653 */
654 deserialize({ read, logger }) {
655 this.logger = logger;
656 {
657 const items = [];
658 let item = read();
659 while (item !== null) {
660 items.push(item);
661 item = read();
662 }
663 this.itemInfo.clear();
664 const infoItems = items.map((identifier) => {
665 const info = new PackItemInfo(identifier, undefined, undefined);
666 this.itemInfo.set(identifier, info);
667 return info;
668 });
669 for (const info of infoItems) {
670 info.etag = read();
671 }
672 for (const info of infoItems) {
673 info.lastAccess = read();
674 }
675 }
676 this.content.length = 0;
677 let items = read();
678 while (items !== null) {
679 if (items === undefined) {
680 this.content.push(items);
681 } else {
682 const idx = this.content.length;
683 const lazy = read();
684 this.content.push(
685 new PackContent(
686 items,
687 new Set(),
688 lazy,
689 logger,
690 `${this.content.length}`
691 )
692 );
693 for (const identifier of items) {
694 /** @type {PackItemInfo} */
695 (this.itemInfo.get(identifier)).location = idx;
696 }
697 }
698 items = read();
699 }
700 }
701}
702
703makeSerializable(Pack, class="st">"webpack/lib/cache/PackFileCacheStrategy", class="st">"Pack");

Callers 1

_openPackMethod · 0.45

Calls 5

readFunction · 0.50
pushMethod · 0.45
clearMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected