* Restores this instance from the provided deserializer context. * @param {ObjectDeserializerContext & { logger: Logger, profile: boolean | undefined }} context context
({ read, logger, profile })
| 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 | |
| 841 | makeSerializable( |