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

Method deserialize

lib/cache/PackFileCacheStrategy.js:799–838  ·  view source on GitHub ↗

* Restores this instance from the provided deserializer context. * @param {ObjectDeserializerContext & { logger: Logger, profile: boolean | undefined }} context context

({ read, logger, profile })

Source from the content-addressed store, hash-verified

797 * @param {ObjectDeserializerContext & { logger: Logger, profile: boolean | undefined }} context context
798 */
799 deserialize({ read, logger, profile }) {
800 if (read()) {
801 this.map = read();
802 } else if (profile) {
803 /** @type {Content} */
804 const map = new Map();
805 let key = read();
806 while (key !== null) {
807 const start = process.hrtime();
808 const value = read();
809 const durationHr = process.hrtime(start);
810 const duration = durationHr[0] * 1000 + durationHr[1] / 1e6;
811 if (duration > 1) {
812 if (duration > 100) {
813 logger.error(`Deserialization of '${key}': ${duration} ms`);
814 } else if (duration > 20) {
815 logger.warn(`Deserialization of '${key}': ${duration} ms`);
816 } else if (duration > 5) {
817 logger.info(`Deserialization of '${key}': ${duration} ms`);
818 } else if (duration > 2) {
819 logger.log(`Deserialization of '${key}': ${duration} ms`);
820 } else {
821 logger.debug(`Deserialization of '${key}': ${duration} ms`);
822 }
823 }
824 map.set(key, value);
825 key = read();
826 }
827 this.map = map;
828 } else {
829 /** @type {Content} */
830 const map = new Map();
831 let key = read();
832 while (key !== null) {
833 map.set(key, read());
834 key = read();
835 }
836 this.map = map;
837 }
838 }
839}
840
841makeSerializable(

Callers

nothing calls this directly

Calls 7

warnMethod · 0.80
infoMethod · 0.80
logMethod · 0.80
debugMethod · 0.80
readFunction · 0.50
errorMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected