@jdeighan/coffee-utils 7.0.34 → 7.0.37

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": "7.0.34",
4
+ "version": "7.0.37",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -61,10 +61,11 @@ getCallers = (stackTrace, lExclude=[]) ->
61
61
  export assert = (cond, msg) ->
62
62
 
63
63
  if ! cond
64
- try
65
- throw new Error()
66
- catch e
67
- stackTrace = e.stack
64
+ # try
65
+ # throw new Error()
66
+ # catch e
67
+ # stackTrace = e.stack
68
+ stackTrace = new Error().stack
68
69
  lCallers = getCallers(stackTrace, ['assert'])
69
70
 
70
71
  # console.log 'STACK'
@@ -58,14 +58,13 @@ getCallers = function(stackTrace, lExclude = []) {
58
58
  // assert - mimic nodejs's assert
59
59
  // return true so we can use it in boolean expressions
60
60
  export var assert = function(cond, msg) {
61
- var caller, e, i, lCallers, len, stackTrace;
61
+ var caller, i, lCallers, len, stackTrace;
62
62
  if (!cond) {
63
- try {
64
- throw new Error();
65
- } catch (error1) {
66
- e = error1;
67
- stackTrace = e.stack;
68
- }
63
+ // try
64
+ // throw new Error()
65
+ // catch e
66
+ // stackTrace = e.stack
67
+ stackTrace = new Error().stack;
69
68
  lCallers = getCallers(stackTrace, ['assert']);
70
69
  // console.log 'STACK'
71
70
  // console.log stackTrace
@@ -176,12 +176,12 @@ export debug = (lArgs...) ->
176
176
  switch type
177
177
  when 'enter'
178
178
  log label, hOptions
179
- if item
179
+ if (nArgs==2)
180
180
  # --- don't repeat the label
181
181
  logItem undef, item, hOptions
182
182
  when 'return'
183
183
  log label, hOptions
184
- if item?
184
+ if (nArgs==2)
185
185
  # --- don't repeat the label
186
186
  logItem undef, item, hOptions
187
187
  when 'string'
@@ -186,14 +186,14 @@ export var debug = function(...lArgs) {
186
186
  switch (type) {
187
187
  case 'enter':
188
188
  log(label, hOptions);
189
- if (item) {
189
+ if (nArgs === 2) {
190
190
  // --- don't repeat the label
191
191
  logItem(undef, item, hOptions);
192
192
  }
193
193
  break;
194
194
  case 'return':
195
195
  log(label, hOptions);
196
- if (item != null) {
196
+ if (nArgs === 2) {
197
197
  // --- don't repeat the label
198
198
  logItem(undef, item, hOptions);
199
199
  }
@@ -13,8 +13,8 @@ import {arrayToBlock, blockToArray} from '@jdeighan/coffee-utils/block'
13
13
 
14
14
  export splitLine = (line) ->
15
15
 
16
- assert line?, "splitLine(): line is undef"
17
- assert isString(line), "splitLine(): line is not a string"
16
+ assert defined(line), "splitLine(): line is undef"
17
+ assert isString(line), "splitLine(): non-string #{OL(line)}"
18
18
  line = rtrim(line)
19
19
  lMatches = line.match(/^(\s*)(.*)$/)
20
20
  return [lMatches[1].length, lMatches[2]]
@@ -25,8 +25,8 @@ import {
25
25
  // splitLine - separate a line into [level, line]
26
26
  export var splitLine = function(line) {
27
27
  var lMatches;
28
- assert(line != null, "splitLine(): line is undef");
29
- assert(isString(line), "splitLine(): line is not a string");
28
+ assert(defined(line), "splitLine(): line is undef");
29
+ assert(isString(line), `splitLine(): non-string ${OL(line)}`);
30
30
  line = rtrim(line);
31
31
  lMatches = line.match(/^(\s*)(.*)$/);
32
32
  return [lMatches[1].length, lMatches[2]];