@akc42/server-utils 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/debug.js CHANGED
@@ -21,6 +21,7 @@
21
21
  import chalk from 'chalk';
22
22
  let config = '';
23
23
  let cache = [];
24
+ let cachelimit = 50;
24
25
 
25
26
  export function Debug (topic) {
26
27
  const t = topic;
@@ -42,7 +43,7 @@ export function Debug (topic) {
42
43
  console.log(output);
43
44
  }
44
45
  cache.push(output);
45
- cache.splice(0,cache.length - 50); //prevent it getting too big
46
+ if (cache.length > cachelimit) cache.splice(0,cache.length - cachelimit); //prevent it getting too big
46
47
  }
47
48
  };
48
49
  export function dumpDebugCache() {
@@ -54,7 +55,8 @@ export function dumpDebugCache() {
54
55
  cache.reverse();
55
56
  console.log(output);
56
57
  };
57
- export function setDebugConfig(con) {
58
+ export function setDebugConfig(con, limit = 50) {
59
+ cachelimit = limit;
58
60
  if (con !== config) {
59
61
  config = con;
60
62
  const output = `${chalk.greenBright('debug server config')} ${chalk.redBright(`new server config "${config}"`)}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akc42/server-utils",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "description": "A Set of Utilities to use on the Server Side of a Project",
6
6
  "main": "./utils.js",
@@ -23,7 +23,7 @@
23
23
  "homepage": "https://github.com/akc42/server-utils#readme",
24
24
  "dependencies": {
25
25
  "app-root-path": "^3.1.0",
26
- "chalk": "^5.1.2",
26
+ "chalk": "^5.3.0",
27
27
  "debug": "^4.3.4"
28
28
  }
29
29
 
package/responder.js CHANGED
@@ -20,9 +20,7 @@
20
20
 
21
21
  import Debug from 'debug';
22
22
 
23
-
24
-
25
- const debug = Debug('responder');
23
+ const debug = Debug('responder');
26
24
 
27
25
  export default class Responder {
28
26
  constructor(response) {
@@ -49,14 +47,14 @@ export default class Responder {
49
47
  this.response.write('{"' + name + '": ');
50
48
  }
51
49
 
52
- if (value !== undefined) {
50
+ if (typeof value !== 'undefined') {
53
51
  this.response.write(JSON.stringify(value));
54
52
  this.inSection = false;
55
- debug('Value section %s',name);
53
+ debug('Write conplete section',name, 'with' , JSON.stringify(value));
56
54
  } else {
57
55
  this.response.write('[');
58
56
  this.inSection = true;
59
- debug('In section %s',name);
57
+ debug('Started Section',name);
60
58
  }
61
59
  this.doneFirstSection = true;
62
60
  this.doneFirstRow = false;