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