-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path8-compare.js
38 lines (32 loc) · 1.05 KB
/
8-compare.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const v8 = require('node:v8');
const fs = require('node:fs');
const jstp = require('metarhia-jstp');
const bson = require('bson');
const persons = [
{ name: 'Marcus Aurelius', city: 'Rome', born: 121 },
{ name: 'Victor Glushkov', city: 'Rostov on Don', born: 1923 },
{ name: 'Ibn Arabi', city: 'Murcia', born: 1165 },
{ name: 'Mao Zedong', city: 'Shaoshan', born: 1893 },
{ name: 'Rene Descartes', city: 'La Haye en Touraine', born: 1596 }
];
const v8Data = v8.serialize(persons);
const v8File = './data.v8';
fs.writeFile(v8File, v8Data, () => {
console.log('Saved ' + v8File);
});
const jsonData = JSON.stringify(persons);
const jsonFile = './data.json';
fs.writeFile(jsonFile, jsonData, () => {
console.log('Saved ' + jsonFile);
});
const jstpData = jstp.stringify(persons);
const jstpFile = './data.jstp';
fs.writeFile(jstpFile, jstpData, () => {
console.log('Saved ' + jstpFile);
});
const bsonData = bson.serialize(persons);
const bsonFile = './data.bson';
fs.writeFile(bsonFile, bsonData, () => {
console.log('Saved ' + bsonFile);
});