From fdf721c2b63523e3b4dded55852eaa1f322a48f6 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Tue, 28 Sep 2021 16:22:21 +0200 Subject: [PATCH] Add script to count json objects --- .bin/count-json-objects.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 .bin/count-json-objects.js diff --git a/.bin/count-json-objects.js b/.bin/count-json-objects.js new file mode 100755 index 0000000..2c6e0ef --- /dev/null +++ b/.bin/count-json-objects.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node + +const fs = require('fs') + +const objLength = obj => Object.keys(obj).length + +fs.readFile(process.argv[2], (err, data) => (err ? console.error(err) : console.log(objLength(JSON.parse(data)))))