@jdeighan/coffee-utils 7.0.3 → 7.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 +1 -1
- package/src/debug_utils.coffee +4 -1
- package/src/indent_utils.coffee +0 -16
- package/src/indent_utils.js +1 -23
- package/src/log_utils.coffee +7 -9
- package/src/log_utils.js +8 -9
package/package.json
CHANGED
package/src/debug_utils.coffee
CHANGED
@@ -168,7 +168,10 @@ export debug = (lArgs...) ->
|
|
168
168
|
# when debugging is off
|
169
169
|
|
170
170
|
[mainPre, auxPre, hEnv, type] = adjustStack(label)
|
171
|
-
hOptions = {
|
171
|
+
hOptions = {
|
172
|
+
prefix: mainPre
|
173
|
+
itemPrefix: auxPre
|
174
|
+
}
|
172
175
|
switch type
|
173
176
|
when 'enter'
|
174
177
|
log label, hOptions
|
package/src/indent_utils.coffee
CHANGED
@@ -130,22 +130,6 @@ export tabify = (str, numSpaces=undef) ->
|
|
130
130
|
lLines.push '\t'.repeat(prefixLen) + theRest
|
131
131
|
return arrayToBlock(lLines)
|
132
132
|
|
133
|
-
# ---------------------------------------------------------------------------
|
134
|
-
# untabify - convert leading TABs to spaces
|
135
|
-
|
136
|
-
untabify_old = (str, numSpaces=3) ->
|
137
|
-
|
138
|
-
oneIndent = ' '.repeat(numSpaces)
|
139
|
-
lLines = []
|
140
|
-
for str in blockToArray(str)
|
141
|
-
lMatches = str.match(/^(\t*)(.*)$/)
|
142
|
-
[_, prefix, theRest] = lMatches
|
143
|
-
if prefix == ''
|
144
|
-
lLines.push theRest
|
145
|
-
else
|
146
|
-
lLines.push oneIndent.repeat(prefix.length) + theRest
|
147
|
-
return arrayToBlock(lLines)
|
148
|
-
|
149
133
|
# ---------------------------------------------------------------------------
|
150
134
|
# untabify - convert ALL TABs to spaces
|
151
135
|
|
package/src/indent_utils.js
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
// Generated by CoffeeScript 2.6.1
|
2
|
-
// indent_utils.coffee
|
3
|
-
var untabify_old;
|
4
|
-
|
2
|
+
// indent_utils.coffee
|
5
3
|
import {
|
6
4
|
assert,
|
7
5
|
undef,
|
@@ -162,26 +160,6 @@ export var tabify = function(str, numSpaces = undef) {
|
|
162
160
|
return arrayToBlock(lLines);
|
163
161
|
};
|
164
162
|
|
165
|
-
// ---------------------------------------------------------------------------
|
166
|
-
// untabify - convert leading TABs to spaces
|
167
|
-
untabify_old = function(str, numSpaces = 3) {
|
168
|
-
var _, i, lLines, lMatches, len, oneIndent, prefix, ref, theRest;
|
169
|
-
oneIndent = ' '.repeat(numSpaces);
|
170
|
-
lLines = [];
|
171
|
-
ref = blockToArray(str);
|
172
|
-
for (i = 0, len = ref.length; i < len; i++) {
|
173
|
-
str = ref[i];
|
174
|
-
lMatches = str.match(/^(\t*)(.*)$/);
|
175
|
-
[_, prefix, theRest] = lMatches;
|
176
|
-
if (prefix === '') {
|
177
|
-
lLines.push(theRest);
|
178
|
-
} else {
|
179
|
-
lLines.push(oneIndent.repeat(prefix.length) + theRest);
|
180
|
-
}
|
181
|
-
}
|
182
|
-
return arrayToBlock(lLines);
|
183
|
-
};
|
184
|
-
|
185
163
|
// ---------------------------------------------------------------------------
|
186
164
|
// untabify - convert ALL TABs to spaces
|
187
165
|
export var untabify = function(str, numSpaces = 3) {
|
package/src/log_utils.coffee
CHANGED
@@ -134,17 +134,15 @@ export log = (str, hOptions={}) ->
|
|
134
134
|
|
135
135
|
export logItem = (label, item, hOptions={}) ->
|
136
136
|
# --- valid options:
|
137
|
-
# prefix
|
138
|
-
# itemPrefix
|
137
|
+
# prefix - not used
|
138
|
+
# itemPrefix - always used
|
139
139
|
|
140
140
|
assert isFunction(putstr), "putstr not properly set"
|
141
141
|
assert !label || isString(label), "label a non-string"
|
142
142
|
assert isHash(hOptions), "arg 3 not a hash"
|
143
143
|
|
144
144
|
label = fixStr(label)
|
145
|
-
prefix = fixStr(hOptions.prefix)
|
146
|
-
itemPrefix = fixStr(hOptions.itemPrefix || prefix)
|
147
|
-
|
145
|
+
prefix = fixStr(hOptions.itemPrefix || hOptions.prefix)
|
148
146
|
labelStr = if label then "#{label} = " else ""
|
149
147
|
|
150
148
|
if (item == undef)
|
@@ -155,16 +153,16 @@ export logItem = (label, item, hOptions={}) ->
|
|
155
153
|
else
|
156
154
|
if label
|
157
155
|
putstr "#{prefix}#{label}:"
|
158
|
-
putBlock item,
|
156
|
+
putBlock item, prefix
|
159
157
|
else if isNumber(item)
|
160
158
|
putstr "#{prefix}#{labelStr}#{item}"
|
161
159
|
else
|
162
|
-
putstr "#{
|
160
|
+
putstr "#{prefix}#{sep_dash}"
|
163
161
|
if label
|
164
162
|
putstr "#{prefix}#{label}:"
|
165
163
|
for str in blockToArray(stringify(item, true)) # escape special chars
|
166
|
-
putstr "#{
|
167
|
-
putstr "#{
|
164
|
+
putstr "#{prefix}#{indentation(1)}#{fixStr(str)}"
|
165
|
+
putstr "#{prefix}#{sep_dash}"
|
168
166
|
|
169
167
|
return
|
170
168
|
|
package/src/log_utils.js
CHANGED
@@ -151,16 +151,15 @@ export var log = function(str, hOptions = {}) {
|
|
151
151
|
|
152
152
|
// ---------------------------------------------------------------------------
|
153
153
|
export var logItem = function(label, item, hOptions = {}) {
|
154
|
-
var i,
|
154
|
+
var i, labelStr, len, prefix, ref, str;
|
155
155
|
// --- valid options:
|
156
|
-
// prefix
|
157
|
-
// itemPrefix
|
156
|
+
// prefix - not used
|
157
|
+
// itemPrefix - always used
|
158
158
|
assert(isFunction(putstr), "putstr not properly set");
|
159
159
|
assert(!label || isString(label), "label a non-string");
|
160
160
|
assert(isHash(hOptions), "arg 3 not a hash");
|
161
161
|
label = fixStr(label);
|
162
|
-
prefix = fixStr(hOptions.prefix);
|
163
|
-
itemPrefix = fixStr(hOptions.itemPrefix || prefix);
|
162
|
+
prefix = fixStr(hOptions.itemPrefix || hOptions.prefix);
|
164
163
|
labelStr = label ? `${label} = ` : "";
|
165
164
|
if (item === undef) {
|
166
165
|
putstr(`${prefix}${labelStr}undef`);
|
@@ -171,12 +170,12 @@ export var logItem = function(label, item, hOptions = {}) {
|
|
171
170
|
if (label) {
|
172
171
|
putstr(`${prefix}${label}:`);
|
173
172
|
}
|
174
|
-
putBlock(item,
|
173
|
+
putBlock(item, prefix);
|
175
174
|
}
|
176
175
|
} else if (isNumber(item)) {
|
177
176
|
putstr(`${prefix}${labelStr}${item}`);
|
178
177
|
} else {
|
179
|
-
putstr(`${
|
178
|
+
putstr(`${prefix}${sep_dash}`);
|
180
179
|
if (label) {
|
181
180
|
putstr(`${prefix}${label}:`);
|
182
181
|
}
|
@@ -184,9 +183,9 @@ export var logItem = function(label, item, hOptions = {}) {
|
|
184
183
|
// escape special chars
|
185
184
|
for (i = 0, len = ref.length; i < len; i++) {
|
186
185
|
str = ref[i];
|
187
|
-
putstr(`${
|
186
|
+
putstr(`${prefix}${indentation(1)}${fixStr(str)}`);
|
188
187
|
}
|
189
|
-
putstr(`${
|
188
|
+
putstr(`${prefix}${sep_dash}`);
|
190
189
|
}
|
191
190
|
};
|
192
191
|
|