Implement LazyArray.splice(), implement unshift/shift/push/pop in terms of splice...
[logjson.git] / json_to_logjson.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.json database.logjson`)
8   process.exit(1)
9 }
10
11 let database = new logjson.Database()
12 await database.open(process.argv[3])
13 let transaction = await database.Transaction()
14 transaction.set_json(
15   JSON.parse((await fsPromises.readFile(process.argv[2])).toString('utf-8'))
16 )
17 transaction.commit()
18 await database.close()