@jdeighan/coffee-utils 7.0.45 → 7.0.48

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "7.0.45",
4
+ "version": "7.0.48",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -52,6 +52,6 @@
52
52
  "svelte": "^3.48.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@jdeighan/unit-tester": "^2.0.2"
55
+ "@jdeighan/unit-tester": "^2.0.3"
56
56
  }
57
57
  }
package/src/DataStores.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // DataStores.coffee
3
3
  import pathlib from 'path';
4
4
 
package/src/arrow.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // arrow.coffee
3
3
  export var vbar = '│'; // unicode 2502
4
4
 
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // block_utils.coffee
3
3
  import fs from 'fs';
4
4
 
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // browser_utils.coffee
3
3
  var audio;
4
4
 
package/src/call_stack.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // call_stack.coffee
3
3
  var doDebugStack;
4
4
 
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // coffee_utils.coffee
3
3
  var LOG, getCallers,
4
4
  indexOf = [].indexOf;
@@ -143,7 +143,6 @@ adjustStack = (str) ->
143
143
  undef
144
144
  if shouldLogString(str) then 'string' else undef
145
145
  ]
146
- return
147
146
 
148
147
  # ---------------------------------------------------------------------------
149
148
 
@@ -159,15 +158,21 @@ export debug = (lArgs...) ->
159
158
 
160
159
  if doDebugDebug
161
160
  if nArgs==1
162
- LOG "debug('#{escapeStr(label)}')"
161
+ LOG "debug('#{escapeStr(label)}') - 1 arg"
163
162
  else
164
- LOG "debug('#{escapeStr(label)}', #{typeof item})"
163
+ LOG "debug('#{escapeStr(label)}', #{typeof item}) - 2 args"
165
164
 
166
165
  # --- We always need to manipulate the stack when we encounter
167
166
  # either "enter X" or "return from X", so we can't short-circuit
168
167
  # when debugging is off
169
168
 
170
- [mainPre, auxPre, hEnv, type] = adjustStack(label)
169
+ lResult = adjustStack(label)
170
+ if doDebugDebug
171
+ LOG 'lResult', lResult
172
+ [mainPre, auxPre, hEnv, type] = lResult
173
+ if doDebugDebug && (type == undef)
174
+ LOG "type is undef - NOT LOGGING"
175
+
171
176
  hOptions = {
172
177
  prefix: mainPre
173
178
  itemPrefix: auxPre
@@ -196,7 +201,7 @@ export debug = (lArgs...) ->
196
201
  if doDebugDebug
197
202
  trans = "#{orgDebugging} => #{debugging}"
198
203
  LOG " Restore hEnv: debugging: #{trans}"
199
- return
204
+ return true # allow use in boolean expressions
200
205
 
201
206
  # ---------------------------------------------------------------------------
202
207
 
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // debug_utils.coffee
3
3
  var adjustStack, doDebugDebug, reMethod, resetDebugging, shouldLogFunc, shouldLogString, stack;
4
4
 
@@ -161,7 +161,7 @@ adjustStack = function(str) {
161
161
 
162
162
  // ---------------------------------------------------------------------------
163
163
  export var debug = function(...lArgs) {
164
- var auxPre, hEnv, hOptions, item, label, mainPre, nArgs, orgDebugging, trans, type;
164
+ var auxPre, hEnv, hOptions, item, lResult, label, mainPre, nArgs, orgDebugging, trans, type;
165
165
  // --- We want to allow item to be undef. Therefore, we need to
166
166
  // distinguish between 1 arg sent vs. 2 args sent
167
167
  nArgs = lArgs.length;
@@ -170,15 +170,22 @@ export var debug = function(...lArgs) {
170
170
  assert(isString(label), `debug(): 1st arg ${OL(label)} should be a string`);
171
171
  if (doDebugDebug) {
172
172
  if (nArgs === 1) {
173
- LOG(`debug('${escapeStr(label)}')`);
173
+ LOG(`debug('${escapeStr(label)}') - 1 arg`);
174
174
  } else {
175
- LOG(`debug('${escapeStr(label)}', ${typeof item})`);
175
+ LOG(`debug('${escapeStr(label)}', ${typeof item}) - 2 args`);
176
176
  }
177
177
  }
178
178
  // --- We always need to manipulate the stack when we encounter
179
179
  // either "enter X" or "return from X", so we can't short-circuit
180
180
  // when debugging is off
181
- [mainPre, auxPre, hEnv, type] = adjustStack(label);
181
+ lResult = adjustStack(label);
182
+ if (doDebugDebug) {
183
+ LOG('lResult', lResult);
184
+ }
185
+ [mainPre, auxPre, hEnv, type] = lResult;
186
+ if (doDebugDebug && (type === undef)) {
187
+ LOG("type is undef - NOT LOGGING");
188
+ }
182
189
  hOptions = {
183
190
  prefix: mainPre,
184
191
  itemPrefix: auxPre
@@ -213,8 +220,10 @@ export var debug = function(...lArgs) {
213
220
  LOG(` Restore hEnv: debugging: ${trans}`);
214
221
  }
215
222
  }
223
+ return true; // allow use in boolean expressions
216
224
  };
217
225
 
226
+
218
227
  // ---------------------------------------------------------------------------
219
228
  reMethod = /^([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)$/;
220
229
 
package/src/fs_utils.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // fs_utils.coffee
3
3
  var isSystemDir;
4
4
 
@@ -38,6 +38,15 @@ export indentLevel = (line) ->
38
38
  lMatches = line.match(/^\t*/)
39
39
  return lMatches[0].length
40
40
 
41
+ # ---------------------------------------------------------------------------
42
+ # isUndented - true iff indentLevel(line) == 0
43
+
44
+ export isUndented = (line) ->
45
+
46
+ assert isString(line), "non-string #{OL(line)}"
47
+ lMatches = line.match(/^\t*/)
48
+ return (lMatches[0].length == 0)
49
+
41
50
  # ---------------------------------------------------------------------------
42
51
  # indented - add indentation to each string in a block
43
52
 
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // indent_utils.coffee
3
3
  import {
4
4
  assert,
@@ -50,6 +50,15 @@ export var indentLevel = function(line) {
50
50
  return lMatches[0].length;
51
51
  };
52
52
 
53
+ // ---------------------------------------------------------------------------
54
+ // isUndented - true iff indentLevel(line) == 0
55
+ export var isUndented = function(line) {
56
+ var lMatches;
57
+ assert(isString(line), `non-string ${OL(line)}`);
58
+ lMatches = line.match(/^\t*/);
59
+ return lMatches[0].length === 0;
60
+ };
61
+
53
62
  // ---------------------------------------------------------------------------
54
63
  // indented - add indentation to each string in a block
55
64
  export var indented = function(input, level = 1) {
@@ -36,7 +36,7 @@ export LOG = (lArgs...) ->
36
36
  console.log sep_dash
37
37
  else
38
38
  console.log label
39
- return
39
+ return true # to allow use in boolean expressions
40
40
 
41
41
  # --- Use this instead to make it easier to remove all instances
42
42
  export DEBUG = LOG # synonym
@@ -135,7 +135,7 @@ export log = (str, hOptions={}) ->
135
135
 
136
136
  prefix = fixStr(hOptions.prefix)
137
137
  putstr "#{prefix}#{str}"
138
- return
138
+ return true # to allow use in boolean expressions
139
139
 
140
140
  # ---------------------------------------------------------------------------
141
141
 
@@ -173,7 +173,7 @@ export logItem = (label, item, hOptions={}) ->
173
173
  putstr "#{prefix}#{indentation(1)}#{fixStr(str)}"
174
174
  putstr "#{prefix}#{sep_dash}"
175
175
 
176
- return
176
+ return true
177
177
 
178
178
  # ---------------------------------------------------------------------------
179
179
 
package/src/log_utils.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // log_utils.coffee
3
3
  var escReplacer, fixStr, loaded, maxOneLine, putBlock, putstr;
4
4
 
@@ -57,8 +57,10 @@ export var LOG = function(...lArgs) {
57
57
  } else {
58
58
  console.log(label);
59
59
  }
60
+ return true; // to allow use in boolean expressions
60
61
  };
61
62
 
63
+
62
64
  // --- Use this instead to make it easier to remove all instances
63
65
  export var DEBUG = LOG; // synonym
64
66
 
@@ -155,8 +157,10 @@ export var log = function(str, hOptions = {}) {
155
157
  assert(isHash(hOptions), "log(): arg 2 not a hash");
156
158
  prefix = fixStr(hOptions.prefix);
157
159
  putstr(`${prefix}${str}`);
160
+ return true; // to allow use in boolean expressions
158
161
  };
159
162
 
163
+
160
164
  // ---------------------------------------------------------------------------
161
165
  export var logItem = function(label, item, hOptions = {}) {
162
166
  var i, labelStr, len, prefix, ref, str;
@@ -197,6 +201,7 @@ export var logItem = function(label, item, hOptions = {}) {
197
201
  }
198
202
  putstr(`${prefix}${sep_dash}`);
199
203
  }
204
+ return true;
200
205
  };
201
206
 
202
207
  // ---------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // server_utils.coffee
3
3
  import getline from 'readline-sync';
4
4
 
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // svelte_utils.coffee
3
3
  import {
4
4
  assert,
package/src/taml.js CHANGED
@@ -1,4 +1,4 @@
1
- // Generated by CoffeeScript 2.6.1
1
+ // Generated by CoffeeScript 2.7.0
2
2
  // taml.coffee
3
3
  var squote;
4
4