Last active
May 14, 2019 06:22
1Password 1pif data parser Node.js module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// cli usage: `node 1p-parser.js input.1pif` | |
'use strict'; | |
const getJSON = require('1pif-to-json'); | |
(async () => { | |
const items = await getJSON(process.argv.slice(2)[0]); | |
console.log(`${items.length} items`); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fs = require('fs'); | |
const readline = require('readline'); | |
async function getJSON (pathTo1pifFile) { | |
const lines = []; | |
const rl = readline.createInterface({ | |
input: fs.createReadStream(pathTo1pifFile), | |
crlfDelay: Infinity | |
}); | |
for await (const line of rl) { | |
if (line.startsWith('{')) { | |
lines.push(JSON.parse(line)); | |
} | |
} | |
return lines; | |
} | |
module.exports = getJSON; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "1pif-to-json", | |
"version": "1.0.0", | |
"description": "", | |
"engines": { | |
"node": ">=12.0.0" | |
}, | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Jesse Jackson <npm@jcksn.org> (https://jcksn.org)", | |
"license": "MIT" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment