@jdeighan/coffee-utils 7.0.34 → 7.0.37
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/coffee_utils.coffee +5 -4
- package/src/coffee_utils.js +6 -7
- package/src/debug_utils.coffee +2 -2
- package/src/debug_utils.js +2 -2
- package/src/indent_utils.coffee +2 -2
- package/src/indent_utils.js +2 -2
package/package.json
CHANGED
package/src/coffee_utils.coffee
CHANGED
@@ -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'
|
package/src/coffee_utils.js
CHANGED
@@ -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,
|
61
|
+
var caller, i, lCallers, len, stackTrace;
|
62
62
|
if (!cond) {
|
63
|
-
try
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
package/src/debug_utils.coffee
CHANGED
@@ -176,12 +176,12 @@ export debug = (lArgs...) ->
|
|
176
176
|
switch type
|
177
177
|
when 'enter'
|
178
178
|
log label, hOptions
|
179
|
-
if
|
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
|
184
|
+
if (nArgs==2)
|
185
185
|
# --- don't repeat the label
|
186
186
|
logItem undef, item, hOptions
|
187
187
|
when 'string'
|
package/src/debug_utils.js
CHANGED
@@ -186,14 +186,14 @@ export var debug = function(...lArgs) {
|
|
186
186
|
switch (type) {
|
187
187
|
case 'enter':
|
188
188
|
log(label, hOptions);
|
189
|
-
if (
|
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 (
|
196
|
+
if (nArgs === 2) {
|
197
197
|
// --- don't repeat the label
|
198
198
|
logItem(undef, item, hOptions);
|
199
199
|
}
|
package/src/indent_utils.coffee
CHANGED
@@ -13,8 +13,8 @@ import {arrayToBlock, blockToArray} from '@jdeighan/coffee-utils/block'
|
|
13
13
|
|
14
14
|
export splitLine = (line) ->
|
15
15
|
|
16
|
-
assert line
|
17
|
-
assert isString(line), "splitLine(): line
|
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]]
|
package/src/indent_utils.js
CHANGED
@@ -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
|
29
|
-
assert(isString(line),
|
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]];
|