Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mccann-hub/json-logger",
"version": "0.1.2",
"version": "0.2.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Consider updating the changelog.

While the version has been updated correctly, it would be good practice to also update a CHANGELOG.md file (if one exists) to document the array truncation functionality being added in this version.


🏁 Script executed:

#!/bin/bash
# Check if a CHANGELOG.md file exists and if it's been updated

# Check if CHANGELOG.md exists
if [ -f "CHANGELOG.md" ]; then
  echo "CHANGELOG.md exists. Checking for version 0.2.0 entry..."
  grep -A 10 "0.2.0" CHANGELOG.md || echo "No entry for version 0.2.0 found in CHANGELOG.md"
else
  echo "No CHANGELOG.md file found in the repository."
fi

Length of output: 126


Action Required: Add a CHANGELOG.md File

  • The repository currently does not have a CHANGELOG.md file.
  • To maintain proper documentation, please consider adding a CHANGELOG.md file. Document the new array truncation functionality along with the version update (0.2.0) so that future releases are clearly tracked.

"publishConfig": {
"access": "public"
},
Expand Down
10 changes: 8 additions & 2 deletions src/utils/sanitize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import process from 'node:process';

const ARRAY_LENGTH_LIMIT = 100;

type LogValue =
| string
| number
Expand Down Expand Up @@ -48,13 +50,17 @@ export function safeDeepClone(obj: LogValue, seen = new WeakMap()) {
* WeakMap pairs each seen object with its corresponding clone ({ original -> clone } mapping).
* This ensures consistency when a reference to the same object appears multiple times in the original structure.
*/
const cloned = Array.isArray(obj) ? [] : {} as LogObject;
const cloned = Array.isArray(obj) ? ([] as LogValue[]) : ({} as LogObject);
seen.set(obj, cloned);

if (Array.isArray(obj)) {
obj.forEach((item) => {
obj.slice(0, ARRAY_LENGTH_LIMIT).forEach((item) => {
(cloned as LogValue[]).push(safeDeepClone(item, seen));
});
const lengthDiff = obj.length - (cloned as LogValue[]).length;
if (lengthDiff > 0) {
(cloned as LogValue[]).push(`${lengthDiff} more...`);
}
} else {
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
Expand Down