source: imaps-frontend/node_modules/webpack/lib/serialization/SetObjectSerializer.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 893 bytes
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3*/
4
5"use strict";
6
7/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
8/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
9
10class SetObjectSerializer {
11 /**
12 * @template T
13 * @param {Set<T>} obj set
14 * @param {ObjectSerializerContext} context context
15 */
16 serialize(obj, context) {
17 context.write(obj.size);
18 for (const value of obj) {
19 context.write(value);
20 }
21 }
22
23 /**
24 * @template T
25 * @param {ObjectDeserializerContext} context context
26 * @returns {Set<T>} date
27 */
28 deserialize(context) {
29 /** @type {number} */
30 const size = context.read();
31 /** @type {Set<T>} */
32 const set = new Set();
33 for (let i = 0; i < size; i++) {
34 set.add(context.read());
35 }
36 return set;
37 }
38}
39
40module.exports = SetObjectSerializer;
Note: See TracBrowser for help on using the repository browser.