debug icon indicating copy to clipboard operation
debug copied to clipboard

How to set max array length (`maxArrayLength`)?

Open FreePhoenix888 opened this issue 4 months ago • 1 comments

Description

How to set max array length (maxArrayLength)?

Code I run

import debug from 'debug'
const log = debug('myApp');

const justArray = new Array(10_000).fill(0);
log({justArray})

const objWithNestedLongArray = {
  nestedArray: justArray
}

log({ objWithNestedLongArray})

How I have tried to set max array length

DEBUG="myApp" DEPTH_MAX_ARRAY_LENGTH="30000" bun run index.ts 
DEBUG="myApp" DEPTH_MAXARRAYLENGTH="30000" bun run index.ts
DEBUG="myApp" DEPTH_maxArrayLength="30000" bun run index.ts

Result

Despite all the 3 methods I have tried to set max array length I get the same result:

  myApp {
  myApp   objWithNestedLongArray: {
  myApp     nestedArray: [
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp       0, 0, 0, 0,
  myApp       ... 9900 more items
  myApp     ]
  myApp   }
  myApp } +0ms
  myApp {
  myApp   justArray: [
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  myApp     0, 0, 0, 0,
  myApp     ... 9900 more items
  myApp   ]
  myApp } +15ms

Additional Info

https://www.npmjs.com/package/debug#environment-variables chapter in documentation tells that by using DEBUG_ I can set Options object that gets used with %o/%O formatters like DEBUG_DEPTH, do I misunderstand that part?

FreePhoenix888 avatar Mar 08 '24 16:03 FreePhoenix888