source: frontend/node_modules/webpack/lib/serialization/ArraySerializer.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1016 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 ArraySerializer {
11 /**
12 * Serializes this instance into the provided serializer context.
13 * @template T
14 * @param {T[]} array array
15 * @param {ObjectSerializerContext} context context
16 */
17 serialize(array, context) {
18 context.write(array.length);
19 for (const item of array) context.write(item);
20 }
21
22 /**
23 * Restores this instance from the provided deserializer context.
24 * @template T
25 * @param {ObjectDeserializerContext} context context
26 * @returns {T[]} array
27 */
28 deserialize(context) {
29 /** @type {number} */
30 const length = context.read();
31 /** @type {T[]} */
32 const array = [];
33 for (let i = 0; i < length; i++) {
34 array.push(context.read());
35 }
36 return array;
37 }
38}
39
40module.exports = ArraySerializer;
Note: See TracBrowser for help on using the repository browser.