From 25df1defd77996a25e00c16ca41a1280712f9980 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Mon, 4 May 2026 13:06:00 +0200 Subject: [PATCH 1/3] docs: add npm, license, build status and bundle size badges --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 246eac6..a2ce22a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # jsonkdiff -![Build status](https://github.com/grrtbrtr/jsonkdiff/actions/workflows/test.yml/badge.svg) -![NPM version](https://img.shields.io/npm/v/@grrtbrtr/jsonkdiff) +![NPM version](https://img.shields.io/npm/v/@grrtbrtr/jsonkdiff?color=blue) ![License](https://img.shields.io/github/license/grrtbrtr/jsonkdiff) ![Build](https://img.shields.io/github/actions/workflow/status/grrtbrtr/jsonkdiff/test.yml) ![Bundle size](https://img.shields.io/bundlephobia/min/@grrtbrtr/jsonkdiff) A lightweight, zero-dependency CLI tool to compare multiple JSON files and identify missing (non-common) keys. It generates a per-file report of unique keys to help identify schema drift. From 5ae44dae6e4210c8a69ac12d8cac1e912f3539a3 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Mon, 4 May 2026 13:06:08 +0200 Subject: [PATCH 2/3] 1.0.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c86a021..e7db798 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.1", + "version": "1.0.2", "license": "GPL-3.0-only", "bin": { "jsonkdiff": "bin/cli.js" diff --git a/package.json b/package.json index 54d1e6a..a894515 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@grrtbrtr/jsonkdiff", - "version": "1.0.1", + "version": "1.0.2", "description": "Compare multiple JSON files and find non-common keys. Generates a per-file report of unique keys to help identify schema drift.", "keywords": [ "json", From 19291d447ab3f5c59ae8a2375d8613baba1db241 Mon Sep 17 00:00:00 2001 From: Gerrit Bertier Date: Fri, 8 May 2026 16:51:25 +0200 Subject: [PATCH 3/3] refactor: use Object.keys and reduce for getDeepKeys traversal - Replace for...in loop with Object.keys for better prototype safety - Implement reduce for a more functional, immutable approach - Maintain recursive support for nested key path generation --- src/utils/object-utils.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/utils/object-utils.js b/src/utils/object-utils.js index 180dc3e..3019813 100644 --- a/src/utils/object-utils.js +++ b/src/utils/object-utils.js @@ -7,14 +7,17 @@ * @returns {Array.} An array of keys. */ export function getDeepKeys(obj, prefix = '') { - let keys = []; - for (const key in obj) { + return Object.keys(obj).reduce((allKeys, key) => { const fullPath = prefix ? `${prefix}.${key}` : key; - keys.push(fullPath); - - if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) { - keys = keys.concat(getDeepKeys(obj[key], fullPath)); + allKeys.push(fullPath); + + if ( + typeof obj[key] === 'object' && + obj[key] !== null && + !Array.isArray(obj[key]) + ) { + allKeys.push(...getDeepKeys(obj[key], fullPath)); } - } - return keys; + return allKeys; + }, []); } \ No newline at end of file