@jdeighan/coffee-utils 6.0.3 → 6.0.4

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "6.0.3",
4
+ "version": "6.0.4",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -1,7 +1,7 @@
1
1
  # call_stack.coffee
2
2
 
3
3
  import {undef, croak} from '@jdeighan/coffee-utils'
4
- import {log} from '@jdeighan/coffee-utils/log'
4
+ import {log, LOG} from '@jdeighan/coffee-utils/log'
5
5
 
6
6
  # ---------------------------------------------------------------------------
7
7
 
@@ -23,11 +23,12 @@ export class CallStack
23
23
  returnFrom: (fName) ->
24
24
 
25
25
  if @lStack.length == 0
26
- croak "returnFrom('#{fName}') but stack is empty"
26
+ LOG "returnFrom('#{fName}') but stack is empty"
27
+ return undef
27
28
  {funcName, hInfo} = @lStack.pop()
28
29
  if funcName != fName
29
30
  @dump()
30
- croak "returnFrom('#{fName}') but TOS is '#{funcName}'"
31
+ LOG "returnFrom('#{fName}') but TOS is '#{funcName}'"
31
32
  return hInfo
32
33
 
33
34
  # ........................................................................
@@ -42,5 +43,5 @@ export class CallStack
42
43
 
43
44
  console.log "#{label}:"
44
45
  for item, i in @lStack
45
- console.log "#{i}: #{JSON.stringify(item)}"
46
+ LOG "#{i}: #{JSON.stringify(item)}"
46
47
  return
package/src/call_stack.js CHANGED
@@ -6,7 +6,8 @@ import {
6
6
  } from '@jdeighan/coffee-utils';
7
7
 
8
8
  import {
9
- log
9
+ log,
10
+ LOG
10
11
  } from '@jdeighan/coffee-utils/log';
11
12
 
12
13
  // ---------------------------------------------------------------------------
@@ -24,12 +25,13 @@ export var CallStack = class CallStack {
24
25
  returnFrom(fName) {
25
26
  var funcName, hInfo;
26
27
  if (this.lStack.length === 0) {
27
- croak(`returnFrom('${fName}') but stack is empty`);
28
+ LOG(`returnFrom('${fName}') but stack is empty`);
29
+ return undef;
28
30
  }
29
31
  ({funcName, hInfo} = this.lStack.pop());
30
32
  if (funcName !== fName) {
31
33
  this.dump();
32
- croak(`returnFrom('${fName}') but TOS is '${funcName}'`);
34
+ LOG(`returnFrom('${fName}') but TOS is '${funcName}'`);
33
35
  }
34
36
  return hInfo;
35
37
  }
@@ -46,7 +48,7 @@ export var CallStack = class CallStack {
46
48
  ref = this.lStack;
47
49
  for (i = j = 0, len = ref.length; j < len; i = ++j) {
48
50
  item = ref[i];
49
- console.log(`${i}: ${JSON.stringify(item)}`);
51
+ LOG(`${i}: ${JSON.stringify(item)}`);
50
52
  }
51
53
  }
52
54
 
@@ -150,7 +150,7 @@ export debug = (lArgs...) ->
150
150
  returning = true
151
151
  curFunc = lMatches[1]
152
152
  hInfo = stack.returnFrom(curFunc)
153
- if DEBUGDEBUG
153
+ if DEBUGDEBUG && hInfo
154
154
  LOG "RETURN FROM #{curFunc}, debugging = #{hInfo.debugging}"
155
155
 
156
156
  if shouldLogString(label)
@@ -179,7 +179,8 @@ export debug = (lArgs...) ->
179
179
  if returning
180
180
  if debugLevel > 0
181
181
  debugLevel -= 1
182
- setEnv(hInfo)
182
+ if hInfo
183
+ setEnv(hInfo)
183
184
  else if entering
184
185
  if debugging
185
186
  debugLevel += 1
@@ -176,7 +176,7 @@ export var debug = function(...lArgs) {
176
176
  returning = true;
177
177
  curFunc = lMatches[1];
178
178
  hInfo = stack.returnFrom(curFunc);
179
- if (DEBUGDEBUG) {
179
+ if (DEBUGDEBUG && hInfo) {
180
180
  LOG(`RETURN FROM ${curFunc}, debugging = ${hInfo.debugging}`);
181
181
  }
182
182
  }
@@ -205,7 +205,9 @@ export var debug = function(...lArgs) {
205
205
  if (debugLevel > 0) {
206
206
  debugLevel -= 1;
207
207
  }
208
- setEnv(hInfo);
208
+ if (hInfo) {
209
+ setEnv(hInfo);
210
+ }
209
211
  } else if (entering) {
210
212
  if (debugging) {
211
213
  debugLevel += 1;