@jdeighan/coffee-utils 2.1.14 → 3.0.0

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": "2.1.14",
4
+ "version": "3.0.0",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -4,9 +4,10 @@ import {strict as assert} from 'assert'
4
4
  import test from 'ava'
5
5
 
6
6
  import {
7
- undef, pass, error, stringToArray,
7
+ undef, pass, error,
8
8
  isString, isFunction, isInteger, isArray,
9
9
  } from '@jdeighan/coffee-utils'
10
+ import {blockToArray} from '@jdeighan/coffee-utils/block'
10
11
  import {log, currentLogger, setLogger} from '@jdeighan/coffee-utils/log'
11
12
  import {
12
13
  debug, debugging, setDebugging,
@@ -163,7 +164,7 @@ export class UnitTester
163
164
  # Remove empty lines
164
165
 
165
166
  if isString(input)
166
- lLines = for line in stringToArray(input)
167
+ lLines = for line in blockToArray(input)
167
168
  line = line.trim()
168
169
  line.replace(/\s+/g, ' ')
169
170
  lLines = lLines.filter (line) -> line != ''
package/src/UnitTester.js CHANGED
@@ -10,13 +10,16 @@ import {
10
10
  undef,
11
11
  pass,
12
12
  error,
13
- stringToArray,
14
13
  isString,
15
14
  isFunction,
16
15
  isInteger,
17
16
  isArray
18
17
  } from '@jdeighan/coffee-utils';
19
18
 
19
+ import {
20
+ blockToArray
21
+ } from '@jdeighan/coffee-utils/block';
22
+
20
23
  import {
21
24
  log,
22
25
  currentLogger,
@@ -163,7 +166,7 @@ export var UnitTester = class UnitTester {
163
166
  if (isString(input)) {
164
167
  lLines = (function() {
165
168
  var i, len, ref, results;
166
- ref = stringToArray(input);
169
+ ref = blockToArray(input);
167
170
  results = [];
168
171
  for (i = 0, len = ref.length; i < len; i++) {
169
172
  line = ref[i];
@@ -6,10 +6,60 @@ import {
6
6
  import {createInterface} from 'readline'
7
7
 
8
8
  import {
9
- isEmpty, nonEmpty, error, isComment,
9
+ isEmpty, nonEmpty, error, isComment, rtrim,
10
10
  } from '@jdeighan/coffee-utils'
11
11
  import {log} from '@jdeighan/coffee-utils/log'
12
12
 
13
+ # ---------------------------------------------------------------------------
14
+ # blockToArray - split a block into lines
15
+
16
+ export blockToArray = (block) ->
17
+
18
+ if isEmpty(block)
19
+ return []
20
+ else
21
+ lLines = block.split(/\r?\n/)
22
+
23
+ # --- remove trailing empty lines
24
+ len = lLines.length
25
+ while (len > 0) && isEmpty(lLines[len-1])
26
+ lLines.pop()
27
+ len -= 1
28
+ return lLines
29
+
30
+ # ---------------------------------------------------------------------------
31
+ # arrayToBlock - block will have no trailing whitespace
32
+
33
+ export arrayToBlock = (lLines) ->
34
+
35
+ if lLines.length == 0
36
+ return ''
37
+ else
38
+ return rtrim(lLines.join('\n'))
39
+
40
+ # ---------------------------------------------------------------------------
41
+ # normalizeBlock - remove blank lines, trim each line
42
+ # - collapse internal whitespace to ' '
43
+
44
+ export normalizeBlock = (content) ->
45
+
46
+ if typeof content != 'string'
47
+ throw new Error("normalizeBlock(): not a string")
48
+ lLines = for line in blockToArray(content)
49
+ line = line.trim()
50
+ line.replace(/\s+/g, ' ')
51
+ lLines = lLines.filter (line) -> line != ''
52
+ return lLines.join('\n')
53
+
54
+ # ---------------------------------------------------------------------------
55
+ # truncateBlock - limit block to a certain number of lines
56
+
57
+ export truncateBlock = (str, numLines) ->
58
+
59
+ lLines = blockToArray str
60
+ lLines.length = numLines
61
+ return arrayToBlock lLines
62
+
13
63
  # ---------------------------------------------------------------------------
14
64
 
15
65
  export joinBlocks = (lBlocks...) ->
@@ -14,18 +14,81 @@ import {
14
14
  isEmpty,
15
15
  nonEmpty,
16
16
  error,
17
- isComment
17
+ isComment,
18
+ rtrim
18
19
  } from '@jdeighan/coffee-utils';
19
20
 
20
21
  import {
21
22
  log
22
23
  } from '@jdeighan/coffee-utils/log';
23
24
 
25
+ // ---------------------------------------------------------------------------
26
+ // blockToArray - split a block into lines
27
+ export var blockToArray = function(block) {
28
+ var lLines, len;
29
+ if (isEmpty(block)) {
30
+ return [];
31
+ } else {
32
+ lLines = block.split(/\r?\n/);
33
+ // --- remove trailing empty lines
34
+ len = lLines.length;
35
+ while ((len > 0) && isEmpty(lLines[len - 1])) {
36
+ lLines.pop();
37
+ len -= 1;
38
+ }
39
+ return lLines;
40
+ }
41
+ };
42
+
43
+ // ---------------------------------------------------------------------------
44
+ // arrayToBlock - block will have no trailing whitespace
45
+ export var arrayToBlock = function(lLines) {
46
+ if (lLines.length === 0) {
47
+ return '';
48
+ } else {
49
+ return rtrim(lLines.join('\n'));
50
+ }
51
+ };
52
+
53
+ // ---------------------------------------------------------------------------
54
+ // normalizeBlock - remove blank lines, trim each line
55
+ // - collapse internal whitespace to ' '
56
+ export var normalizeBlock = function(content) {
57
+ var lLines, line;
58
+ if (typeof content !== 'string') {
59
+ throw new Error("normalizeBlock(): not a string");
60
+ }
61
+ lLines = (function() {
62
+ var i, len1, ref, results;
63
+ ref = blockToArray(content);
64
+ results = [];
65
+ for (i = 0, len1 = ref.length; i < len1; i++) {
66
+ line = ref[i];
67
+ line = line.trim();
68
+ results.push(line.replace(/\s+/g, ' '));
69
+ }
70
+ return results;
71
+ })();
72
+ lLines = lLines.filter(function(line) {
73
+ return line !== '';
74
+ });
75
+ return lLines.join('\n');
76
+ };
77
+
78
+ // ---------------------------------------------------------------------------
79
+ // truncateBlock - limit block to a certain number of lines
80
+ export var truncateBlock = function(str, numLines) {
81
+ var lLines;
82
+ lLines = blockToArray(str);
83
+ lLines.length = numLines;
84
+ return arrayToBlock(lLines);
85
+ };
86
+
24
87
  // ---------------------------------------------------------------------------
25
88
  export var joinBlocks = function(...lBlocks) {
26
- var blk, i, len, str;
89
+ var blk, i, len1, str;
27
90
  str = '';
28
- for (i = 0, len = lBlocks.length; i < len; i++) {
91
+ for (i = 0, len1 = lBlocks.length; i < len1; i++) {
29
92
  blk = lBlocks[i];
30
93
  if (nonEmpty(blk)) {
31
94
  str += "\n" + blk;
@@ -233,45 +233,6 @@ export firstLine = (input) ->
233
233
  else
234
234
  return input.substring(0, pos)
235
235
 
236
- # ---------------------------------------------------------------------------
237
- # stringToArray - split a string into lines
238
-
239
- export stringToArray = (str) ->
240
-
241
- if isEmpty(str)
242
- return []
243
- else
244
- lLines = str.split(/\r?\n/)
245
- len = lLines.length
246
- while (len > 0) && isEmpty(lLines[len-1])
247
- lLines.pop()
248
- len -= 1
249
- return lLines
250
-
251
- # ---------------------------------------------------------------------------
252
- # arrayToString - every line has trailing newline
253
-
254
- export arrayToString = (lLines) ->
255
-
256
- if lLines.length == 0
257
- return ''
258
- else
259
- return rtrim(lLines.join('\n'))
260
-
261
- # ---------------------------------------------------------------------------
262
- # normalize - remove blank lines, trim each line
263
- # - collapse internal whitespace to ' '
264
-
265
- export normalize = (content) ->
266
-
267
- if typeof content != 'string'
268
- throw new Error("normalize(): not a string")
269
- lLines = for line in stringToArray(content)
270
- line = line.trim()
271
- line.replace(/\s+/g, ' ')
272
- lLines = lLines.filter (line) -> line != ''
273
- return lLines.join('\n')
274
-
275
236
  # ---------------------------------------------------------------------------
276
237
 
277
238
  export titleLine = (title, char='=', padding=2, linelen=42) ->
@@ -353,15 +314,6 @@ export oneline = (obj) ->
353
314
 
354
315
  export OL = oneline
355
316
 
356
- # ---------------------------------------------------------------------------
357
- # truncateBlock - limit block to a certain number of lines
358
-
359
- export truncateBlock = (str, numLines) ->
360
-
361
- lLines = stringToArray str
362
- lLines.length = numLines
363
- return arrayToString lLines
364
-
365
317
  # ---------------------------------------------------------------------------
366
318
 
367
319
  export removeCR = (block) ->
@@ -162,11 +162,11 @@ export var words = function(str) {
162
162
 
163
163
  // ---------------------------------------------------------------------------
164
164
  export var isArrayOfHashes = function(lItems) {
165
- var i, item, len1;
165
+ var i, item, len;
166
166
  if (!isArray(lItems)) {
167
167
  return false;
168
168
  }
169
- for (i = 0, len1 = lItems.length; i < len1; i++) {
169
+ for (i = 0, len = lItems.length; i < len; i++) {
170
170
  item = lItems[i];
171
171
  if (!isHash(item)) {
172
172
  return false;
@@ -177,11 +177,11 @@ export var isArrayOfHashes = function(lItems) {
177
177
 
178
178
  // ---------------------------------------------------------------------------
179
179
  export var isArrayOfStrings = function(lItems) {
180
- var i, item, len1;
180
+ var i, item, len;
181
181
  if (!isArray(lItems)) {
182
182
  return false;
183
183
  }
184
- for (i = 0, len1 = lItems.length; i < len1; i++) {
184
+ for (i = 0, len = lItems.length; i < len; i++) {
185
185
  item = lItems[i];
186
186
  if (!isString(item)) {
187
187
  return false;
@@ -242,58 +242,6 @@ export var firstLine = function(input) {
242
242
  }
243
243
  };
244
244
 
245
- // ---------------------------------------------------------------------------
246
- // stringToArray - split a string into lines
247
- export var stringToArray = function(str) {
248
- var lLines, len;
249
- if (isEmpty(str)) {
250
- return [];
251
- } else {
252
- lLines = str.split(/\r?\n/);
253
- len = lLines.length;
254
- while ((len > 0) && isEmpty(lLines[len - 1])) {
255
- lLines.pop();
256
- len -= 1;
257
- }
258
- return lLines;
259
- }
260
- };
261
-
262
- // ---------------------------------------------------------------------------
263
- // arrayToString - every line has trailing newline
264
- export var arrayToString = function(lLines) {
265
- if (lLines.length === 0) {
266
- return '';
267
- } else {
268
- return rtrim(lLines.join('\n'));
269
- }
270
- };
271
-
272
- // ---------------------------------------------------------------------------
273
- // normalize - remove blank lines, trim each line
274
- // - collapse internal whitespace to ' '
275
- export var normalize = function(content) {
276
- var lLines, line;
277
- if (typeof content !== 'string') {
278
- throw new Error("normalize(): not a string");
279
- }
280
- lLines = (function() {
281
- var i, len1, ref, results;
282
- ref = stringToArray(content);
283
- results = [];
284
- for (i = 0, len1 = ref.length; i < len1; i++) {
285
- line = ref[i];
286
- line = line.trim();
287
- results.push(line.replace(/\s+/g, ' '));
288
- }
289
- return results;
290
- })();
291
- lLines = lLines.filter(function(line) {
292
- return line !== '';
293
- });
294
- return lLines.join('\n');
295
- };
296
-
297
245
  // ---------------------------------------------------------------------------
298
246
  export var titleLine = function(title, char = '=', padding = 2, linelen = 42) {
299
247
  var nLeft, nRight, strLeft, strMiddle, strRight, titleLen;
@@ -352,10 +300,10 @@ export var escapeStr = function(str) {
352
300
  croak("escapeStr(): not a string", str, 'STRING');
353
301
  }
354
302
  lParts = (function() {
355
- var i, len1, ref, results;
303
+ var i, len, ref, results;
356
304
  ref = str.split('');
357
305
  results = [];
358
- for (i = 0, len1 = ref.length; i < len1; i++) {
306
+ for (i = 0, len = ref.length; i < len; i++) {
359
307
  ch = ref[i];
360
308
  if (ch === '\n') {
361
309
  results.push('\\n');
@@ -385,15 +333,6 @@ export var oneline = function(obj) {
385
333
 
386
334
  export var OL = oneline;
387
335
 
388
- // ---------------------------------------------------------------------------
389
- // truncateBlock - limit block to a certain number of lines
390
- export var truncateBlock = function(str, numLines) {
391
- var lLines;
392
- lLines = stringToArray(str);
393
- lLines.length = numLines;
394
- return arrayToString(lLines);
395
- };
396
-
397
336
  // ---------------------------------------------------------------------------
398
337
  export var removeCR = function(block) {
399
338
  return block.replace(/\r/g, '');
@@ -3,8 +3,9 @@
3
3
  import {strict as assert} from 'assert'
4
4
  import {
5
5
  undef, error, croak, warn, words, isString, isFunction,
6
- stringToArray, oneline, escapeStr, isNumber, isArray,
6
+ oneline, escapeStr, isNumber, isArray,
7
7
  } from '@jdeighan/coffee-utils'
8
+ import {blockToArray} from '@jdeighan/coffee-utils/block'
8
9
  import {log} from '@jdeighan/coffee-utils/log'
9
10
  import {slurp} from '@jdeighan/coffee-utils/fs'
10
11
 
@@ -203,7 +204,7 @@ export checkTrace = (block) ->
203
204
 
204
205
  lStack = []
205
206
 
206
- for line in stringToArray(block)
207
+ for line in blockToArray(block)
207
208
  if lMatches = line.match(///
208
209
  enter
209
210
  \s+
@@ -14,13 +14,16 @@ import {
14
14
  words,
15
15
  isString,
16
16
  isFunction,
17
- stringToArray,
18
17
  oneline,
19
18
  escapeStr,
20
19
  isNumber,
21
20
  isArray
22
21
  } from '@jdeighan/coffee-utils';
23
22
 
23
+ import {
24
+ blockToArray
25
+ } from '@jdeighan/coffee-utils/block';
26
+
24
27
  import {
25
28
  log
26
29
  } from '@jdeighan/coffee-utils/log';
@@ -197,7 +200,7 @@ export var funcMatch = function(curFunc) {
197
200
  export var checkTrace = function(block) {
198
201
  var funcName, i, lMatches, lStack, len, len1, line, ref;
199
202
  lStack = [];
200
- ref = stringToArray(block);
203
+ ref = blockToArray(block);
201
204
  for (i = 0, len1 = ref.length; i < len1; i++) {
202
205
  line = ref[i];
203
206
  if (lMatches = line.match(/enter\s+([A-Za-z_][A-Za-z0-9_\.]*)/)) {
@@ -2,9 +2,10 @@
2
2
 
3
3
  import {strict as assert} from 'assert'
4
4
  import {
5
- undef, error, arrayToString, stringToArray, escapeStr,
5
+ undef, error, escapeStr,
6
6
  oneline, isInteger, isString, isArray, isEmpty, rtrim,
7
7
  } from '@jdeighan/coffee-utils'
8
+ import {arrayToBlock, blockToArray} from '@jdeighan/coffee-utils/block'
8
9
 
9
10
  # ---------------------------------------------------------------------------
10
11
  # NOTE: Currently, only TAB indentation is supported
@@ -30,6 +31,7 @@ export indentation = (level) ->
30
31
 
31
32
  # ---------------------------------------------------------------------------
32
33
  # indentLevel - determine indent level of a string
34
+ # it's OK if the string is ONLY indentation
33
35
 
34
36
  export indentLevel = (str) ->
35
37
 
@@ -51,9 +53,9 @@ export indented = (input, level=0) ->
51
53
  "#{toAdd}#{line}"
52
54
  return lLines
53
55
  else
54
- lLines = for line in stringToArray(input)
56
+ lLines = for line in blockToArray(input)
55
57
  "#{toAdd}#{line}"
56
- return arrayToString(lLines)
58
+ return arrayToBlock(lLines)
57
59
 
58
60
  # ---------------------------------------------------------------------------
59
61
  # undented - string with 1st line indentation removed for each line
@@ -67,7 +69,7 @@ export undented = (text, level=undef) ->
67
69
  return text
68
70
 
69
71
  if isString(text)
70
- lLines = stringToArray(text)
72
+ lLines = blockToArray(text)
71
73
  if (lLines.length == 0)
72
74
  return ''
73
75
  else if isArray(text)
@@ -97,7 +99,7 @@ export undented = (text, level=undef) ->
97
99
  lNewLines.push(line.substr(nToRemove))
98
100
 
99
101
  if isString(text)
100
- return arrayToString(lNewLines)
102
+ return arrayToBlock(lNewLines)
101
103
  else
102
104
  return lNewLines
103
105
 
@@ -109,7 +111,7 @@ export undented = (text, level=undef) ->
109
111
  export tabify = (str, numSpaces=undef) ->
110
112
 
111
113
  lLines = []
112
- for str in stringToArray(str)
114
+ for str in blockToArray(str)
113
115
  lMatches = str.match(/^(\s*)(.*)$/)
114
116
  [_, prefix, theRest] = lMatches
115
117
  if prefix == ''
@@ -123,7 +125,7 @@ export tabify = (str, numSpaces=undef) ->
123
125
  if (n % numSpaces != 0)
124
126
  error "tabify(): Invalid # of leading space chars"
125
127
  lLines.push '\t'.repeat(n / numSpaces) + theRest
126
- return arrayToString(lLines)
128
+ return arrayToBlock(lLines)
127
129
 
128
130
  # ---------------------------------------------------------------------------
129
131
  # untabify - convert leading TABs to spaces
@@ -132,11 +134,11 @@ export untabify = (str, numSpaces=3) ->
132
134
 
133
135
  oneIndent = ' '.repeat(numSpaces)
134
136
  lLines = []
135
- for str in stringToArray(str)
137
+ for str in blockToArray(str)
136
138
  lMatches = str.match(/^(\t*)(.*)$/)
137
139
  [_, prefix, theRest] = lMatches
138
140
  if prefix == ''
139
141
  lLines.push theRest
140
142
  else
141
143
  lLines.push oneIndent.repeat(prefix.length) + theRest
142
- return arrayToString(lLines)
144
+ return arrayToBlock(lLines)
@@ -7,8 +7,6 @@ import {
7
7
  import {
8
8
  undef,
9
9
  error,
10
- arrayToString,
11
- stringToArray,
12
10
  escapeStr,
13
11
  oneline,
14
12
  isInteger,
@@ -18,6 +16,11 @@ import {
18
16
  rtrim
19
17
  } from '@jdeighan/coffee-utils';
20
18
 
19
+ import {
20
+ arrayToBlock,
21
+ blockToArray
22
+ } from '@jdeighan/coffee-utils/block';
23
+
21
24
  // ---------------------------------------------------------------------------
22
25
  // NOTE: Currently, only TAB indentation is supported
23
26
  // ---------------------------------------------------------------------------
@@ -41,6 +44,7 @@ export var indentation = function(level) {
41
44
 
42
45
  // ---------------------------------------------------------------------------
43
46
  // indentLevel - determine indent level of a string
47
+ // it's OK if the string is ONLY indentation
44
48
  export var indentLevel = function(str) {
45
49
  var lMatches;
46
50
  lMatches = str.match(/^\t*/);
@@ -70,7 +74,7 @@ export var indented = function(input, level = 0) {
70
74
  } else {
71
75
  lLines = (function() {
72
76
  var i, len, ref, results;
73
- ref = stringToArray(input);
77
+ ref = blockToArray(input);
74
78
  results = [];
75
79
  for (i = 0, len = ref.length; i < len; i++) {
76
80
  line = ref[i];
@@ -78,7 +82,7 @@ export var indented = function(input, level = 0) {
78
82
  }
79
83
  return results;
80
84
  })();
81
- return arrayToString(lLines);
85
+ return arrayToBlock(lLines);
82
86
  }
83
87
  };
84
88
 
@@ -93,7 +97,7 @@ export var undented = function(text, level = undef) {
93
97
  return text;
94
98
  }
95
99
  if (isString(text)) {
96
- lLines = stringToArray(text);
100
+ lLines = blockToArray(text);
97
101
  if (lLines.length === 0) {
98
102
  return '';
99
103
  }
@@ -125,7 +129,7 @@ export var undented = function(text, level = undef) {
125
129
  }
126
130
  }
127
131
  if (isString(text)) {
128
- return arrayToString(lNewLines);
132
+ return arrayToBlock(lNewLines);
129
133
  } else {
130
134
  return lNewLines;
131
135
  }
@@ -138,7 +142,7 @@ export var undented = function(text, level = undef) {
138
142
  export var tabify = function(str, numSpaces = undef) {
139
143
  var _, i, lLines, lMatches, len, n, prefix, ref, theRest;
140
144
  lLines = [];
141
- ref = stringToArray(str);
145
+ ref = blockToArray(str);
142
146
  for (i = 0, len = ref.length; i < len; i++) {
143
147
  str = ref[i];
144
148
  lMatches = str.match(/^(\s*)(.*)$/);
@@ -159,7 +163,7 @@ export var tabify = function(str, numSpaces = undef) {
159
163
  lLines.push('\t'.repeat(n / numSpaces) + theRest);
160
164
  }
161
165
  }
162
- return arrayToString(lLines);
166
+ return arrayToBlock(lLines);
163
167
  };
164
168
 
165
169
  // ---------------------------------------------------------------------------
@@ -168,7 +172,7 @@ export var untabify = function(str, numSpaces = 3) {
168
172
  var _, i, lLines, lMatches, len, oneIndent, prefix, ref, theRest;
169
173
  oneIndent = ' '.repeat(numSpaces);
170
174
  lLines = [];
171
- ref = stringToArray(str);
175
+ ref = blockToArray(str);
172
176
  for (i = 0, len = ref.length; i < len; i++) {
173
177
  str = ref[i];
174
178
  lMatches = str.match(/^(\t*)(.*)$/);
@@ -179,5 +183,5 @@ export var untabify = function(str, numSpaces = 3) {
179
183
  lLines.push(oneIndent.repeat(prefix.length) + theRest);
180
184
  }
181
185
  }
182
- return arrayToString(lLines);
186
+ return arrayToBlock(lLines);
183
187
  };
@@ -4,9 +4,9 @@ import {strict as assert} from 'assert'
4
4
  import yaml from 'js-yaml'
5
5
 
6
6
  import {
7
- undef, isNumber, isString, isHash, isFunction,
8
- escapeStr, stringToArray,
7
+ undef, isNumber, isString, isHash, isFunction, escapeStr,
9
8
  } from '@jdeighan/coffee-utils'
9
+ import {blockToArray} from '@jdeighan/coffee-utils/block'
10
10
  import {tabify} from '@jdeighan/coffee-utils/indent'
11
11
 
12
12
  logger = console.log # for strings
@@ -120,7 +120,7 @@ export log = (lArgs...) ->
120
120
  logger "#{prefix}#{str} = '#{esc}'"
121
121
  else
122
122
  logger "#{prefix}#{str}:"
123
- for line in stringToArray(item)
123
+ for line in blockToArray(item)
124
124
  logger "#{itemPrefix} #{escapeStr(line)}"
125
125
  else
126
126
  # --- It's some type of object
@@ -129,7 +129,7 @@ export log = (lArgs...) ->
129
129
  logger "#{prefix}#{str} = #{json}"
130
130
  else
131
131
  logger "#{prefix}#{str}:"
132
- for str in stringToArray(stringify(item))
132
+ for str in blockToArray(stringify(item))
133
133
  logger "#{itemPrefix} #{str}"
134
134
  return
135
135
 
package/src/log_utils.js CHANGED
@@ -14,10 +14,13 @@ import {
14
14
  isString,
15
15
  isHash,
16
16
  isFunction,
17
- escapeStr,
18
- stringToArray
17
+ escapeStr
19
18
  } from '@jdeighan/coffee-utils';
20
19
 
20
+ import {
21
+ blockToArray
22
+ } from '@jdeighan/coffee-utils/block';
23
+
21
24
  import {
22
25
  tabify
23
26
  } from '@jdeighan/coffee-utils/indent';
@@ -133,7 +136,7 @@ export var log = function(...lArgs) {
133
136
  logger(`${prefix}${str} = '${esc}'`);
134
137
  } else {
135
138
  logger(`${prefix}${str}:`);
136
- ref = stringToArray(item);
139
+ ref = blockToArray(item);
137
140
  for (i = 0, len = ref.length; i < len; i++) {
138
141
  line = ref[i];
139
142
  logger(`${itemPrefix} ${escapeStr(line)}`);
@@ -146,7 +149,7 @@ export var log = function(...lArgs) {
146
149
  logger(`${prefix}${str} = ${json}`);
147
150
  } else {
148
151
  logger(`${prefix}${str}:`);
149
- ref1 = stringToArray(stringify(item));
152
+ ref1 = blockToArray(stringify(item));
150
153
  for (j = 0, len1 = ref1.length; j < len1; j++) {
151
154
  str = ref1[j];
152
155
  logger(`${itemPrefix} ${str}`);