@jdeighan/coffee-utils 7.0.59 → 7.0.62
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 +1 -1
- package/src/arrow.coffee +13 -22
- package/src/arrow.js +14 -27
- package/src/call_stack.coffee +40 -57
- package/src/call_stack.js +47 -60
- package/src/coffee_utils.coffee +20 -8
- package/src/coffee_utils.js +24 -8
- package/src/debug_utils.coffee +114 -172
- package/src/debug_utils.js +127 -177
- package/src/log_utils.coffee +41 -31
- package/src/log_utils.js +40 -32
package/src/log_utils.js
CHANGED
|
@@ -39,11 +39,6 @@ export var stringify = undef;
|
|
|
39
39
|
|
|
40
40
|
fourSpaces = ' ';
|
|
41
41
|
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
export var dashes = function(prefix, totalLen = 64, ch = '-') {
|
|
44
|
-
return prefix + ch.repeat(totalLen - prefix.length);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
42
|
// ---------------------------------------------------------------------------
|
|
48
43
|
export var debugLog = function(flag = true) {
|
|
49
44
|
doDebugLog = flag;
|
|
@@ -84,6 +79,16 @@ export var LOG = function(...lArgs) {
|
|
|
84
79
|
export var DEBUG = LOG; // synonym
|
|
85
80
|
|
|
86
81
|
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
export var LOGLINES = function(label, lLines) {
|
|
84
|
+
var i, len, line;
|
|
85
|
+
LOG(`${label}:`);
|
|
86
|
+
for (i = 0, len = lLines.length; i < len; i++) {
|
|
87
|
+
line = lLines[i];
|
|
88
|
+
LOG(`${OL(line)}`);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
87
92
|
// ---------------------------------------------------------------------------
|
|
88
93
|
export var setStringifier = function(func) {
|
|
89
94
|
var orgStringifier;
|
|
@@ -132,7 +137,7 @@ export var tamlStringify = function(obj, escape = false) {
|
|
|
132
137
|
return value;
|
|
133
138
|
}
|
|
134
139
|
});
|
|
135
|
-
return "---\n" +
|
|
140
|
+
return "---\n" + str;
|
|
136
141
|
};
|
|
137
142
|
|
|
138
143
|
// ---------------------------------------------------------------------------
|
|
@@ -147,21 +152,18 @@ export var orderedStringify = function(obj, escape = false) {
|
|
|
147
152
|
return value;
|
|
148
153
|
}
|
|
149
154
|
});
|
|
150
|
-
return "---\n" +
|
|
155
|
+
return "---\n" + str;
|
|
151
156
|
};
|
|
152
157
|
|
|
153
158
|
// ---------------------------------------------------------------------------
|
|
154
159
|
maxOneLine = 32;
|
|
155
160
|
|
|
156
161
|
// ---------------------------------------------------------------------------
|
|
157
|
-
export var log = function(str,
|
|
158
|
-
|
|
159
|
-
// --- valid options:
|
|
160
|
-
// prefix
|
|
162
|
+
export var log = function(str, prefix = '') {
|
|
163
|
+
assert(isString(prefix), `not a string: ${OL(prefix)}`);
|
|
161
164
|
assert(isString(str), `log(): not a string: ${OL(str)}`);
|
|
162
165
|
assert(isFunction(putstr), "putstr not properly set");
|
|
163
|
-
|
|
164
|
-
prefix = fixForTerminal(hOptions.prefix);
|
|
166
|
+
prefix = fixForTerminal(prefix);
|
|
165
167
|
if (doDebugLog) {
|
|
166
168
|
LOG(`CALL log(${OL(str)}), prefix = ${OL(prefix)}`);
|
|
167
169
|
}
|
|
@@ -171,45 +173,51 @@ export var log = function(str, hOptions = {}) {
|
|
|
171
173
|
|
|
172
174
|
|
|
173
175
|
// ---------------------------------------------------------------------------
|
|
174
|
-
export var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
export var logBareItem = function(item, pre = '') {
|
|
177
|
+
logItem(undef, item, pre);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
export var logItem = function(label, item, pre = '', itemPre = undef) {
|
|
182
|
+
var i, labelStr, len, ref, str;
|
|
183
|
+
assert(isString(pre), `not a string: ${OL(pre)}`);
|
|
178
184
|
assert(isFunction(putstr), "putstr not properly set");
|
|
179
185
|
assert(!label || isString(label), "label a non-string");
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
assert(
|
|
186
|
+
if (itemPre === undef) {
|
|
187
|
+
itemPre = pre;
|
|
188
|
+
}
|
|
189
|
+
assert(pre.indexOf("\t") === -1, "pre has TAB");
|
|
190
|
+
assert(itemPre.indexOf("\t") === -1, "itemPre has TAB");
|
|
184
191
|
if (doDebugLog) {
|
|
185
192
|
LOG(`CALL logItem(${OL(label)}, ${OL(item)})`);
|
|
186
|
-
LOG(`
|
|
193
|
+
LOG(`pre = ${OL(pre)}`);
|
|
194
|
+
LOG(`itemPre = ${OL(itemPre)}`);
|
|
187
195
|
}
|
|
188
196
|
labelStr = label ? `${label} = ` : "";
|
|
189
197
|
if (item === undef) {
|
|
190
|
-
putstr(`${
|
|
198
|
+
putstr(`${pre}${labelStr}undef`);
|
|
191
199
|
} else if (item === null) {
|
|
192
|
-
putstr(`${
|
|
200
|
+
putstr(`${pre}${labelStr}null`);
|
|
201
|
+
} else if (isNumber(item)) {
|
|
202
|
+
putstr(`${pre}${labelStr}${item}`);
|
|
193
203
|
} else if (isString(item)) {
|
|
194
204
|
if (item.length <= maxOneLine) {
|
|
195
|
-
putstr(`${
|
|
205
|
+
putstr(`${pre}${labelStr}'${escapeStr(item)}'`);
|
|
196
206
|
} else {
|
|
197
207
|
if (label) {
|
|
198
|
-
putstr(`${
|
|
208
|
+
putstr(`${pre}${label}:`);
|
|
199
209
|
}
|
|
200
|
-
putBlock(item,
|
|
210
|
+
putBlock(item, itemPre);
|
|
201
211
|
}
|
|
202
|
-
} else if (isNumber(item)) {
|
|
203
|
-
putstr(`${prefix}${labelStr}${item}`);
|
|
204
212
|
} else {
|
|
205
213
|
if (label) {
|
|
206
|
-
putstr(`${
|
|
214
|
+
putstr(`${pre}${label}:`);
|
|
207
215
|
}
|
|
208
216
|
ref = blockToArray(stringify(item, true));
|
|
209
|
-
// escape special chars
|
|
217
|
+
// --- escape special chars
|
|
210
218
|
for (i = 0, len = ref.length; i < len; i++) {
|
|
211
219
|
str = ref[i];
|
|
212
|
-
putstr(`${
|
|
220
|
+
putstr(`${itemPre}${str}`);
|
|
213
221
|
}
|
|
214
222
|
}
|
|
215
223
|
return true;
|