Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
398 bytes
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | */
|
---|
4 |
|
---|
5 | "use strict";
|
---|
6 |
|
---|
7 | class ArraySerializer {
|
---|
8 | serialize(array, { write }) {
|
---|
9 | write(array.length);
|
---|
10 | for (const item of array) write(item);
|
---|
11 | }
|
---|
12 | deserialize({ read }) {
|
---|
13 | const length = read();
|
---|
14 | const array = [];
|
---|
15 | for (let i = 0; i < length; i++) {
|
---|
16 | array.push(read());
|
---|
17 | }
|
---|
18 | return array;
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | module.exports = ArraySerializer;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.