Implement LazyArray.splice(), implement unshift/shift/push/pop in terms of splice...
[logjson.git] / logjson_to_json.mjs
1 #!/usr/bin/env node
2
3 import fsPromises from 'fs/promises'
4 import logjson from './index.mjs'
5
6 if (process.argv.length < 4) {
7   console.log(`usage: ${process.argv[0]} ${process.argv[1]} database.logjson database.json`)
8   process.exit(1)
9 }
10
11 let database = new logjson.Database()
12 await database.open(process.argv[2])
13 let transaction = await database.Transaction()
14 await fsPromises.writeFile(
15   process.argv[3],
16   Buffer.from(
17     JSON.stringify(await transaction.get_json(), null, 2) + '\n',
18     'utf-8'
19   )
20 )
21 transaction.rollback()
22 await database.close()