@jdeighan/coffee-utils 11.0.1 → 11.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/package.json +14 -13
  2. package/src/DataStores.coffee +6 -15
  3. package/src/DataStores.js +8 -21
  4. package/src/Section.coffee +1 -1
  5. package/src/Section.js +1 -2
  6. package/src/SectionMap.coffee +5 -7
  7. package/src/SectionMap.js +6 -14
  8. package/src/arrow.coffee +1 -1
  9. package/src/arrow.js +1 -1
  10. package/src/{block_utils.coffee → block.coffee} +5 -5
  11. package/src/{block_utils.js → block.js} +4 -6
  12. package/src/{browser_utils.coffee → browser.coffee} +1 -1
  13. package/src/{browser_utils.js → browser.js} +1 -1
  14. package/src/{debug_utils.coffee → debug.coffee} +7 -12
  15. package/src/{debug_utils.js → debug.js} +6 -25
  16. package/src/{fs_utils.coffee → fs.coffee} +5 -40
  17. package/src/{fs_utils.js → fs.js} +9 -51
  18. package/src/fsa.coffee +1 -2
  19. package/src/fsa.js +2 -5
  20. package/src/{html_utils.coffee → html.coffee} +5 -6
  21. package/src/{html_utils.js → html.js} +5 -10
  22. package/src/{indent_utils.coffee → indent.coffee} +7 -9
  23. package/src/{indent_utils.js → indent.js} +7 -9
  24. package/src/{log_utils.coffee → log.coffee} +5 -44
  25. package/src/{log_utils.js → log.js} +6 -55
  26. package/src/placeholders.coffee +1 -1
  27. package/src/placeholders.js +1 -2
  28. package/src/{server_utils.coffee → server.coffee} +1 -1
  29. package/src/{server_utils.js → server.js} +1 -1
  30. package/src/{call_stack.coffee → stack.coffee} +2 -2
  31. package/src/{call_stack.js → stack.js} +2 -2
  32. package/src/{svelte_utils.coffee → svelte.coffee} +4 -5
  33. package/src/{svelte_utils.js → svelte.js} +6 -10
  34. package/src/taml.coffee +29 -30
  35. package/src/taml.js +39 -43
  36. package/src/{coffee_utils.coffee → utils.coffee} +14 -6
  37. package/src/{coffee_utils.js → utils.js} +25 -17
@@ -1,17 +1,15 @@
1
- # fs_utils.coffee
1
+ # fs.coffee
2
2
 
3
3
  import pathlib from 'path'
4
4
  import urllib from 'url'
5
5
  import fs from 'fs'
6
6
  import NReadLines from 'n-readlines'
7
7
 
8
- import {assert, error, croak} from '@jdeighan/unit-tester/utils'
8
+ import {LOG, assert, croak} from '@jdeighan/exceptions'
9
9
  import {
10
10
  undef, pass, defined, rtrim, isEmpty, nonEmpty,
11
11
  isString, isArray, isHash, isRegExp, isFunction, OL,
12
12
  } from '@jdeighan/coffee-utils'
13
- import {log, LOG} from '@jdeighan/coffee-utils/log'
14
- import {debug} from '@jdeighan/coffee-utils/debug'
15
13
  import {arrayToBlock} from '@jdeighan/coffee-utils/block'
16
14
 
17
15
  # ---------------------------------------------------------------------------
@@ -20,13 +18,9 @@ import {arrayToBlock} from '@jdeighan/coffee-utils/block'
20
18
 
21
19
  export mydir = (url) ->
22
20
 
23
- debug "url = #{url}"
24
21
  path = urllib.fileURLToPath(url)
25
- debug "path = #{path}"
26
22
  dir = pathlib.dirname(path)
27
- debug "dir = #{dir}"
28
23
  final = mkpath(dir)
29
- debug "final = #{final}"
30
24
  return final
31
25
 
32
26
  # ---------------------------------------------------------------------------
@@ -35,11 +29,8 @@ export mydir = (url) ->
35
29
 
36
30
  export myfile = (url) ->
37
31
 
38
- debug "url = #{url}"
39
32
  path = urllib.fileURLToPath(url)
40
- debug "path = #{path}"
41
33
  filename = pathlib.parse(path).base
42
- debug "filename = #{filename}"
43
34
  return filename
44
35
 
45
36
  # ---------------------------------------------------------------------------
@@ -48,9 +39,7 @@ export myfile = (url) ->
48
39
 
49
40
  export myfullpath = (url) ->
50
41
 
51
- debug "url = #{url}"
52
42
  path = urllib.fileURLToPath(url)
53
- debug "path = #{path}"
54
43
  return mkpath(path)
55
44
 
56
45
  # ---------------------------------------------------------------------------
@@ -140,7 +129,6 @@ export forEachLineInFile = (filepath, func) ->
140
129
 
141
130
  export slurp = (filepath, maxLines=undef) ->
142
131
 
143
- debug "enter slurp('#{filepath}')"
144
132
  if maxLines?
145
133
  lLines = []
146
134
  forEachLineInFile filepath, (line, nLines) ->
@@ -150,7 +138,6 @@ export slurp = (filepath, maxLines=undef) ->
150
138
  else
151
139
  filepath = filepath.replace(/\//g, "\\")
152
140
  contents = fs.readFileSync(filepath, 'utf8').toString()
153
- debug "return from slurp()", contents
154
141
  return contents
155
142
 
156
143
  # ---------------------------------------------------------------------------
@@ -158,9 +145,7 @@ export slurp = (filepath, maxLines=undef) ->
158
145
 
159
146
  export barf = (filepath, contents) ->
160
147
 
161
- debug "enter barf('#{filepath}')", contents
162
148
  if isEmpty(contents)
163
- debug "return from barf(): empty contents"
164
149
  return
165
150
  if isArray(contents)
166
151
  contents = arrayToBlock(contents)
@@ -168,7 +153,6 @@ export barf = (filepath, contents) ->
168
153
  croak "barf(): Invalid contents"
169
154
  contents = rtrim(contents) + "\n"
170
155
  fs.writeFileSync(filepath, contents, {encoding: 'utf8'})
171
- debug "return from barf()"
172
156
  return
173
157
 
174
158
  # ---------------------------------------------------------------------------
@@ -199,10 +183,10 @@ export removeFileWithExt = (path, newExt, hOptions={}) ->
199
183
  try
200
184
  fs.unlinkSync fullpath
201
185
  if hOptions.doLog
202
- log " unlink #{filename}"
186
+ LOG " unlink #{filename}"
203
187
  success = true
204
188
  catch err
205
- log " UNLINK FAILED: #{err.message}"
189
+ LOG " UNLINK FAILED: #{err.message}"
206
190
  success = false
207
191
  return success
208
192
 
@@ -277,7 +261,6 @@ export pathTo = (fname, searchDir, hOptions={}) ->
277
261
  if isEmpty(relative)
278
262
  relative = false
279
263
 
280
- debug "enter pathTo()", fname, searchDir, direction
281
264
  if ! searchDir
282
265
  searchDir = process.cwd()
283
266
  assert fs.existsSync(searchDir), "Dir #{searchDir} does not exist"
@@ -285,7 +268,6 @@ export pathTo = (fname, searchDir, hOptions={}) ->
285
268
  if fs.existsSync(filepath)
286
269
  if relative
287
270
  filepath = "./#{fname}"
288
- debug "return from pathTo() - file exists", filepath
289
271
  return filepath
290
272
 
291
273
  if (direction == 'down')
@@ -293,31 +275,24 @@ export pathTo = (fname, searchDir, hOptions={}) ->
293
275
  # getSubDirs() returns dirs sorted alphabetically
294
276
  for subdir in getSubDirs(searchDir)
295
277
  dirpath = mkpath(searchDir, subdir)
296
- debug "check #{subdir}"
297
278
  if defined(fpath = pathTo(fname, dirpath, hOptions))
298
279
  if relative
299
280
  fpath = fpath.replace('./', "./#{subdir}/")
300
- debug "return from pathTo()", fpath
301
281
  return fpath
302
282
  else if (direction == 'up')
303
283
  nLevels = 0
304
284
  while defined(dirPath = getParentDir(searchDir))
305
285
  nLevels += 1
306
- debug "check #{dirPath}"
307
286
  fpath = mkpath(dirPath, fname)
308
- debug "check for #{fpath}"
309
287
  if fs.existsSync(fpath)
310
288
  if relative
311
289
  fpath = "../".repeat(nLevels) + fname
312
- debug "return from pathTo()", fpath
313
290
  return fpath
314
291
  else
315
- debug "return from pathTo()", fpath
316
292
  return fpath
317
293
  searchDir = dirPath
318
294
  else
319
- error "pathTo(): Invalid direction '#{direction}'"
320
- debug "return undef from pathTo - file not found"
295
+ croak "pathTo(): Invalid direction '#{direction}'"
321
296
  return undef
322
297
 
323
298
  # ---------------------------------------------------------------------------
@@ -342,21 +317,13 @@ export allPathsTo = (fname, searchDir) ->
342
317
 
343
318
  export newerDestFileExists = (srcPath, destPath) ->
344
319
 
345
- debug "enter newerDestFileExists()"
346
320
  if ! fs.existsSync(destPath)
347
- debug "return false from newerDestFileExists() - no file"
348
321
  return false
349
322
  srcModTime = fs.statSync(srcPath).mtimeMs
350
323
  destModTime = fs.statSync(destPath).mtimeMs
351
- debug "srcModTime = #{srcModTime}"
352
- debug "destModTime = #{destModTime}"
353
324
  if destModTime >= srcModTime
354
- debug "#{destPath} is up to date"
355
- debug "return true from newerDestFileExists()"
356
325
  return true
357
326
  else
358
- debug "#{destPath} is old"
359
- debug "return false from newerDestFileExists()"
360
327
  return false
361
328
 
362
329
  # ---------------------------------------------------------------------------
@@ -386,7 +353,6 @@ export parseSource = (source) ->
386
353
  # }
387
354
  # --- NOTE: source may be a file URL, e.g. import.meta.url
388
355
 
389
- debug "enter parseSource()"
390
356
  assert isString(source),\
391
357
  "parseSource(): source not a string: #{OL(source)}"
392
358
  if source == 'unit test'
@@ -423,7 +389,6 @@ export parseSource = (source) ->
423
389
  ([A-Za-z_]+)
424
390
  $///)
425
391
  hSourceInfo.purpose = lMatches[1]
426
- debug "return from parseSource()", hSourceInfo
427
392
  return hSourceInfo
428
393
 
429
394
  # ---------------------------------------------------------------------------
@@ -1,5 +1,5 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
- // fs_utils.coffee
2
+ // fs.coffee
3
3
  var isSystemDir;
4
4
 
5
5
  import pathlib from 'path';
@@ -11,10 +11,10 @@ import fs from 'fs';
11
11
  import NReadLines from 'n-readlines';
12
12
 
13
13
  import {
14
+ LOG,
14
15
  assert,
15
- error,
16
16
  croak
17
- } from '@jdeighan/unit-tester/utils';
17
+ } from '@jdeighan/exceptions';
18
18
 
19
19
  import {
20
20
  undef,
@@ -31,15 +31,6 @@ import {
31
31
  OL
32
32
  } from '@jdeighan/coffee-utils';
33
33
 
34
- import {
35
- log,
36
- LOG
37
- } from '@jdeighan/coffee-utils/log';
38
-
39
- import {
40
- debug
41
- } from '@jdeighan/coffee-utils/debug';
42
-
43
34
  import {
44
35
  arrayToBlock
45
36
  } from '@jdeighan/coffee-utils/block';
@@ -49,13 +40,9 @@ import {
49
40
  // the directory your file is in
50
41
  export var mydir = function(url) {
51
42
  var dir, final, path;
52
- debug(`url = ${url}`);
53
43
  path = urllib.fileURLToPath(url);
54
- debug(`path = ${path}`);
55
44
  dir = pathlib.dirname(path);
56
- debug(`dir = ${dir}`);
57
45
  final = mkpath(dir);
58
- debug(`final = ${final}`);
59
46
  return final;
60
47
  };
61
48
 
@@ -64,11 +51,8 @@ export var mydir = function(url) {
64
51
  // the name of your file
65
52
  export var myfile = function(url) {
66
53
  var filename, path;
67
- debug(`url = ${url}`);
68
54
  path = urllib.fileURLToPath(url);
69
- debug(`path = ${path}`);
70
55
  filename = pathlib.parse(path).base;
71
- debug(`filename = ${filename}`);
72
56
  return filename;
73
57
  };
74
58
 
@@ -77,9 +61,7 @@ export var myfile = function(url) {
77
61
  // the full path to your file
78
62
  export var myfullpath = function(url) {
79
63
  var path;
80
- debug(`url = ${url}`);
81
64
  path = urllib.fileURLToPath(url);
82
- debug(`path = ${path}`);
83
65
  return mkpath(path);
84
66
  };
85
67
 
@@ -97,7 +79,7 @@ export var isDir = function(fullpath) {
97
79
  return false;
98
80
  }
99
81
  return obj.isDirectory();
100
- } catch (error1) {
82
+ } catch (error) {
101
83
  return false;
102
84
  }
103
85
  };
@@ -175,7 +157,6 @@ export var forEachLineInFile = function(filepath, func) {
175
157
  // slurp - read an entire file into a string
176
158
  export var slurp = function(filepath, maxLines = undef) {
177
159
  var contents, lLines;
178
- debug(`enter slurp('${filepath}')`);
179
160
  if (maxLines != null) {
180
161
  lLines = [];
181
162
  forEachLineInFile(filepath, function(line, nLines) {
@@ -191,16 +172,13 @@ export var slurp = function(filepath, maxLines = undef) {
191
172
  filepath = filepath.replace(/\//g, "\\");
192
173
  contents = fs.readFileSync(filepath, 'utf8').toString();
193
174
  }
194
- debug("return from slurp()", contents);
195
175
  return contents;
196
176
  };
197
177
 
198
178
  // ---------------------------------------------------------------------------
199
179
  // barf - write a string to a file
200
180
  export var barf = function(filepath, contents) {
201
- debug(`enter barf('${filepath}')`, contents);
202
181
  if (isEmpty(contents)) {
203
- debug("return from barf(): empty contents");
204
182
  return;
205
183
  }
206
184
  if (isArray(contents)) {
@@ -212,7 +190,6 @@ export var barf = function(filepath, contents) {
212
190
  fs.writeFileSync(filepath, contents, {
213
191
  encoding: 'utf8'
214
192
  });
215
- debug("return from barf()");
216
193
  };
217
194
 
218
195
  // ---------------------------------------------------------------------------
@@ -243,12 +220,12 @@ export var removeFileWithExt = function(path, newExt, hOptions = {}) {
243
220
  try {
244
221
  fs.unlinkSync(fullpath);
245
222
  if (hOptions.doLog) {
246
- log(` unlink ${filename}`);
223
+ LOG(` unlink ${filename}`);
247
224
  }
248
225
  success = true;
249
- } catch (error1) {
250
- err = error1;
251
- log(` UNLINK FAILED: ${err.message}`);
226
+ } catch (error) {
227
+ err = error;
228
+ LOG(` UNLINK FAILED: ${err.message}`);
252
229
  success = false;
253
230
  }
254
231
  return success;
@@ -339,7 +316,6 @@ export var pathTo = function(fname, searchDir, hOptions = {}) {
339
316
  if (isEmpty(relative)) {
340
317
  relative = false;
341
318
  }
342
- debug("enter pathTo()", fname, searchDir, direction);
343
319
  if (!searchDir) {
344
320
  searchDir = process.cwd();
345
321
  }
@@ -349,7 +325,6 @@ export var pathTo = function(fname, searchDir, hOptions = {}) {
349
325
  if (relative) {
350
326
  filepath = `./${fname}`;
351
327
  }
352
- debug("return from pathTo() - file exists", filepath);
353
328
  return filepath;
354
329
  }
355
330
  if (direction === 'down') {
@@ -359,12 +334,10 @@ export var pathTo = function(fname, searchDir, hOptions = {}) {
359
334
  for (i = 0, len = ref.length; i < len; i++) {
360
335
  subdir = ref[i];
361
336
  dirpath = mkpath(searchDir, subdir);
362
- debug(`check ${subdir}`);
363
337
  if (defined(fpath = pathTo(fname, dirpath, hOptions))) {
364
338
  if (relative) {
365
339
  fpath = fpath.replace('./', `./${subdir}/`);
366
340
  }
367
- debug("return from pathTo()", fpath);
368
341
  return fpath;
369
342
  }
370
343
  }
@@ -372,25 +345,20 @@ export var pathTo = function(fname, searchDir, hOptions = {}) {
372
345
  nLevels = 0;
373
346
  while (defined(dirPath = getParentDir(searchDir))) {
374
347
  nLevels += 1;
375
- debug(`check ${dirPath}`);
376
348
  fpath = mkpath(dirPath, fname);
377
- debug(`check for ${fpath}`);
378
349
  if (fs.existsSync(fpath)) {
379
350
  if (relative) {
380
351
  fpath = "../".repeat(nLevels) + fname;
381
- debug("return from pathTo()", fpath);
382
352
  return fpath;
383
353
  } else {
384
- debug("return from pathTo()", fpath);
385
354
  return fpath;
386
355
  }
387
356
  }
388
357
  searchDir = dirPath;
389
358
  }
390
359
  } else {
391
- error(`pathTo(): Invalid direction '${direction}'`);
360
+ croak(`pathTo(): Invalid direction '${direction}'`);
392
361
  }
393
- debug("return undef from pathTo - file not found");
394
362
  return undef;
395
363
  };
396
364
 
@@ -420,22 +388,14 @@ export var allPathsTo = function(fname, searchDir) {
420
388
  // ---------------------------------------------------------------------------
421
389
  export var newerDestFileExists = function(srcPath, destPath) {
422
390
  var destModTime, srcModTime;
423
- debug("enter newerDestFileExists()");
424
391
  if (!fs.existsSync(destPath)) {
425
- debug("return false from newerDestFileExists() - no file");
426
392
  return false;
427
393
  }
428
394
  srcModTime = fs.statSync(srcPath).mtimeMs;
429
395
  destModTime = fs.statSync(destPath).mtimeMs;
430
- debug(`srcModTime = ${srcModTime}`);
431
- debug(`destModTime = ${destModTime}`);
432
396
  if (destModTime >= srcModTime) {
433
- debug(`${destPath} is up to date`);
434
- debug("return true from newerDestFileExists()");
435
397
  return true;
436
398
  } else {
437
- debug(`${destPath} is old`);
438
- debug("return false from newerDestFileExists()");
439
399
  return false;
440
400
  }
441
401
  };
@@ -465,7 +425,6 @@ export var parseSource = function(source) {
465
425
  // purpose
466
426
  // }
467
427
  // --- NOTE: source may be a file URL, e.g. import.meta.url
468
- debug("enter parseSource()");
469
428
  assert(isString(source), `parseSource(): source not a string: ${OL(source)}`);
470
429
  if (source === 'unit test') {
471
430
  croak("A source of 'unit test' is deprecated");
@@ -501,7 +460,6 @@ export var parseSource = function(source) {
501
460
  hSourceInfo.purpose = lMatches[1];
502
461
  }
503
462
  }
504
- debug("return from parseSource()", hSourceInfo);
505
463
  return hSourceInfo;
506
464
  };
507
465
 
package/src/fsa.coffee CHANGED
@@ -1,12 +1,11 @@
1
1
  # fsa.coffee
2
2
 
3
- import {assert, croak} from '@jdeighan/unit-tester/utils'
3
+ import {LOG, assert, croak} from '@jdeighan/exceptions'
4
4
  import {
5
5
  undef, defined, notdefined, words, isEmpty, nonEmpty,
6
6
  isString, OL,
7
7
  } from '@jdeighan/coffee-utils'
8
8
  import {toArray} from '@jdeighan/coffee-utils/block'
9
- import {LOG} from '@jdeighan/coffee-utils/log'
10
9
  import {debug} from '@jdeighan/coffee-utils/debug'
11
10
 
12
11
  # ---------------------------------------------------------------------------
package/src/fsa.js CHANGED
@@ -1,9 +1,10 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
2
  // fsa.coffee
3
3
  import {
4
+ LOG,
4
5
  assert,
5
6
  croak
6
- } from '@jdeighan/unit-tester/utils';
7
+ } from '@jdeighan/exceptions';
7
8
 
8
9
  import {
9
10
  undef,
@@ -20,10 +21,6 @@ import {
20
21
  toArray
21
22
  } from '@jdeighan/coffee-utils/block';
22
23
 
23
- import {
24
- LOG
25
- } from '@jdeighan/coffee-utils/log';
26
-
27
24
  import {
28
25
  debug
29
26
  } from '@jdeighan/coffee-utils/debug';
@@ -1,12 +1,11 @@
1
- # html_utils.coffee
1
+ # html.coffee
2
2
 
3
- import {assert, croak} from '@jdeighan/unit-tester/utils'
3
+ import {assert, croak} from '@jdeighan/exceptions'
4
4
  import {
5
5
  undef, pass, words, isEmpty, nonEmpty,
6
6
  } from '@jdeighan/coffee-utils'
7
- import {indented, enclose} from '@jdeighan/coffee-utils/indent'
8
- import {arrayToBlock} from '@jdeighan/coffee-utils/block'
9
- import {debug} from '@jdeighan/coffee-utils/debug'
7
+ import {indented} from '@jdeighan/coffee-utils/indent'
8
+ import {toBlock} from '@jdeighan/coffee-utils/block'
10
9
 
11
10
  hNoEnd = {}
12
11
  for tagName in words('area base br col command embed hr img input' \
@@ -210,7 +209,7 @@ export elem = (tagName, hAttr=undef, text=undef, oneIndent="\t") ->
210
209
  hAttr
211
210
  text
212
211
  }
213
- return arrayToBlock([
212
+ return toBlock([
214
213
  tag2str(hToken, 'begin')
215
214
  indented(text, 1, oneIndent)
216
215
  tag2str(hToken, 'end')
@@ -1,11 +1,11 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
- // html_utils.coffee
2
+ // html.coffee
3
3
  var hNoEnd, i, len, ref, tagName;
4
4
 
5
5
  import {
6
6
  assert,
7
7
  croak
8
- } from '@jdeighan/unit-tester/utils';
8
+ } from '@jdeighan/exceptions';
9
9
 
10
10
  import {
11
11
  undef,
@@ -16,18 +16,13 @@ import {
16
16
  } from '@jdeighan/coffee-utils';
17
17
 
18
18
  import {
19
- indented,
20
- enclose
19
+ indented
21
20
  } from '@jdeighan/coffee-utils/indent';
22
21
 
23
22
  import {
24
- arrayToBlock
23
+ toBlock
25
24
  } from '@jdeighan/coffee-utils/block';
26
25
 
27
- import {
28
- debug
29
- } from '@jdeighan/coffee-utils/debug';
30
-
31
26
  hNoEnd = {};
32
27
 
33
28
  ref = words('area base br col command embed hr img input' + ' keygen link meta param source track wbr');
@@ -218,5 +213,5 @@ export var elem = function(tagName, hAttr = undef, text = undef, oneIndent = "\t
218
213
  return undef;
219
214
  }
220
215
  hToken = {tagName, hAttr, text};
221
- return arrayToBlock([tag2str(hToken, 'begin'), indented(text, 1, oneIndent), tag2str(hToken, 'end')]);
216
+ return toBlock([tag2str(hToken, 'begin'), indented(text, 1, oneIndent), tag2str(hToken, 'end')]);
222
217
  };
@@ -1,13 +1,11 @@
1
- # indent_utils.coffee
1
+ # indent.coffee
2
2
 
3
- import {assert, error} from '@jdeighan/unit-tester/utils'
3
+ import {assert, croak} from '@jdeighan/exceptions'
4
4
  import {
5
- undef, escapeStr, defined,
5
+ undef, defined, notdefined,
6
6
  OL, isInteger, isString, isArray, isEmpty, rtrim,
7
7
  } from '@jdeighan/coffee-utils'
8
- import {
9
- arrayToBlock, blockToArray, toArray, toBlock,
10
- } from '@jdeighan/coffee-utils/block'
8
+ import {toArray, toBlock} from '@jdeighan/coffee-utils/block'
11
9
 
12
10
  # ---------------------------------------------------------------------------
13
11
 
@@ -143,7 +141,7 @@ export undented = (input, level=undef, oneIndent="\t") ->
143
141
  export tabify = (str, numSpaces=undef) ->
144
142
 
145
143
  lLines = []
146
- for str in blockToArray(str)
144
+ for str in toArray(str)
147
145
  [_, prefix, theRest] = str.match(/^(\s*)(.*)$/)
148
146
  prefixLen = prefix.length
149
147
  if prefixLen == 0
@@ -155,7 +153,7 @@ export tabify = (str, numSpaces=undef) ->
155
153
  assert (prefixLen % numSpaces == 0), "Bad prefix"
156
154
  level = prefixLen / numSpaces
157
155
  lLines.push '\t'.repeat(level) + theRest
158
- result = arrayToBlock(lLines)
156
+ result = toBlock(lLines)
159
157
  return result
160
158
 
161
159
  # ---------------------------------------------------------------------------
@@ -170,7 +168,7 @@ export untabify = (str, numSpaces=3) ->
170
168
 
171
169
  export enclose = (text, pre, post, oneIndent="\t") ->
172
170
 
173
- return arrayToBlock([
171
+ return toBlock([
174
172
  pre
175
173
  indented(text, 1, oneIndent)
176
174
  post
@@ -1,14 +1,14 @@
1
1
  // Generated by CoffeeScript 2.7.0
2
- // indent_utils.coffee
2
+ // indent.coffee
3
3
  import {
4
4
  assert,
5
- error
6
- } from '@jdeighan/unit-tester/utils';
5
+ croak
6
+ } from '@jdeighan/exceptions';
7
7
 
8
8
  import {
9
9
  undef,
10
- escapeStr,
11
10
  defined,
11
+ notdefined,
12
12
  OL,
13
13
  isInteger,
14
14
  isString,
@@ -18,8 +18,6 @@ import {
18
18
  } from '@jdeighan/coffee-utils';
19
19
 
20
20
  import {
21
- arrayToBlock,
22
- blockToArray,
23
21
  toArray,
24
22
  toBlock
25
23
  } from '@jdeighan/coffee-utils/block';
@@ -169,7 +167,7 @@ export var undented = function(input, level = undef, oneIndent = "\t") {
169
167
  export var tabify = function(str, numSpaces = undef) {
170
168
  var _, i, lLines, len1, level, prefix, prefixLen, ref, result, theRest;
171
169
  lLines = [];
172
- ref = blockToArray(str);
170
+ ref = toArray(str);
173
171
  for (i = 0, len1 = ref.length; i < len1; i++) {
174
172
  str = ref[i];
175
173
  [_, prefix, theRest] = str.match(/^(\s*)(.*)$/);
@@ -186,7 +184,7 @@ export var tabify = function(str, numSpaces = undef) {
186
184
  lLines.push('\t'.repeat(level) + theRest);
187
185
  }
188
186
  }
189
- result = arrayToBlock(lLines);
187
+ result = toBlock(lLines);
190
188
  return result;
191
189
  };
192
190
 
@@ -199,5 +197,5 @@ export var untabify = function(str, numSpaces = 3) {
199
197
  // ---------------------------------------------------------------------------
200
198
  // enclose - indent text, surround with pre and post
201
199
  export var enclose = function(text, pre, post, oneIndent = "\t") {
202
- return arrayToBlock([pre, indented(text, 1, oneIndent), post]);
200
+ return toBlock([pre, indented(text, 1, oneIndent), post]);
203
201
  };
@@ -1,14 +1,11 @@
1
- # log_utils.coffee
1
+ # log.coffee
2
2
 
3
- import {assert, error, croak} from '@jdeighan/unit-tester/utils'
3
+ import {LOG, assert, croak} from '@jdeighan/exceptions'
4
4
  import {
5
5
  undef, isNumber, isInteger, isString, isHash, isFunction,
6
6
  escapeStr, sep_eq, sep_dash, pass, OL,
7
7
  } from '@jdeighan/coffee-utils'
8
- import {blockToArray} from '@jdeighan/coffee-utils/block'
9
- import {
10
- tabify, untabify, indentation, indented,
11
- } from '@jdeighan/coffee-utils/indent'
8
+ import {toArray} from '@jdeighan/coffee-utils/block'
12
9
  import {toTAML} from '@jdeighan/coffee-utils/taml'
13
10
 
14
11
  # --- This logger only ever gets passed a single string argument
@@ -27,42 +24,6 @@ export debugLog = (flag=true) ->
27
24
  LOG "doDebugLog = #{flag}"
28
25
  return
29
26
 
30
- # ---------------------------------------------------------------------------
31
- # This is useful for debugging
32
-
33
- export LOG = (lArgs...) ->
34
-
35
- [label, item] = lArgs
36
- if lArgs.length > 1
37
- # --- There's both a label and an item
38
- if (item == undef)
39
- console.log "#{label} = undef"
40
- else if (item == null)
41
- console.log "#{label} = null"
42
- else
43
- console.log sep_dash
44
- console.log "#{label}:"
45
- if isString(item)
46
- console.log untabify(item)
47
- else
48
- console.log untabify(orderedStringify(item))
49
- console.log sep_dash
50
- else
51
- console.log label
52
- return true # to allow use in boolean expressions
53
-
54
- # --- Use this instead to make it easier to remove all instances
55
- export DEBUG = LOG # synonym
56
-
57
- # ---------------------------------------------------------------------------
58
-
59
- export LOGLINES = (label, lLines) ->
60
-
61
- LOG "#{label}:"
62
- for line in lLines
63
- LOG "#{OL(line)}"
64
- return
65
-
66
27
  # ---------------------------------------------------------------------------
67
28
 
68
29
  export setStringifier = (func) ->
@@ -185,7 +146,7 @@ export logItem = (label, item, pre='', itemPre=undef) ->
185
146
  putstr "#{pre}#{label}:"
186
147
 
187
148
  # --- escape special chars
188
- for str in blockToArray(stringify(item, true))
149
+ for str in toArray(stringify(item, true))
189
150
  putstr "#{itemPre}#{str}"
190
151
 
191
152
  return true
@@ -212,7 +173,7 @@ fixForTerminal = (str) ->
212
173
  putBlock = (item, prefix='') ->
213
174
 
214
175
  putstr "#{prefix}#{sep_eq}"
215
- for line in blockToArray(item)
176
+ for line in toArray(item)
216
177
  putstr "#{prefix}#{escapeStr(line)}"
217
178
  putstr "#{prefix}#{sep_eq}"
218
179
  return