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.
22 lines
398 B
22 lines
398 B
/* |
|
MIT License http://www.opensource.org/licenses/mit-license.php |
|
*/ |
|
|
|
"use strict"; |
|
|
|
class ArraySerializer { |
|
serialize(array, { write }) { |
|
write(array.length); |
|
for (const item of array) write(item); |
|
} |
|
deserialize({ read }) { |
|
const length = read(); |
|
const array = []; |
|
for (let i = 0; i < length; i++) { |
|
array.push(read()); |
|
} |
|
return array; |
|
} |
|
} |
|
|
|
module.exports = ArraySerializer;
|
|
|