You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
parttimejob/node_modules/webpack/lib/serialization/SetObjectSerializer.js

41 lines
893 B

/*
MIT License http://www.opensource.org/licenses/mit-license.php
*/
"use strict";
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
class SetObjectSerializer {
/**
* @template T
* @param {Set<T>} obj set
* @param {ObjectSerializerContext} context context
*/
serialize(obj, context) {
context.write(obj.size);
for (const value of obj) {
context.write(value);
}
}
/**
* @template T
* @param {ObjectDeserializerContext} context context
* @returns {Set<T>} date
*/
deserialize(context) {
/** @type {number} */
const size = context.read();
/** @type {Set<T>} */
const set = new Set();
for (let i = 0; i < size; i++) {
set.add(context.read());
}
return set;
}
}
module.exports = SetObjectSerializer;