@jdeighan/coffee-utils 7.0.11 → 7.0.14

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": "7.0.11",
4
+ "version": "7.0.14",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -49,7 +49,7 @@
49
49
  "js-yaml": "^4.1.0",
50
50
  "n-readlines": "^1.0.1",
51
51
  "readline-sync": "^1.4.10",
52
- "svelte": "^3.46.6"
52
+ "svelte": "^3.47.0"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@jdeighan/unit-tester": "^1.0.5"
@@ -379,3 +379,17 @@ export strcat = (lItems...) ->
379
379
  for item in lItems
380
380
  str += item.toString()
381
381
  return str
382
+
383
+ # ---------------------------------------------------------------------------
384
+
385
+ export replaceVars = (line, hVars) ->
386
+
387
+ replacerFunc = (match, prefix, name) =>
388
+ return if prefix then process.env[name] else hVars[name].toString()
389
+
390
+ return line.replace(///
391
+ __
392
+ (env\.)?
393
+ ([A-Za-z_]\w*)
394
+ __
395
+ ///g, replacerFunc)
@@ -408,3 +408,16 @@ export var strcat = function(...lItems) {
408
408
  }
409
409
  return str;
410
410
  };
411
+
412
+ // ---------------------------------------------------------------------------
413
+ export var replaceVars = function(line, hVars) {
414
+ var replacerFunc;
415
+ replacerFunc = (match, prefix, name) => {
416
+ if (prefix) {
417
+ return process.env[name];
418
+ } else {
419
+ return hVars[name].toString();
420
+ }
421
+ };
422
+ return line.replace(/__(env\.)?([A-Za-z_]\w*)__/g, replacerFunc);
423
+ };
@@ -15,23 +15,28 @@ putstr = undef
15
15
  export stringify = undef
16
16
 
17
17
  # ---------------------------------------------------------------------------
18
- # This is useful for debugging and easy to remove after debugging
18
+ # This is useful for debugging
19
19
 
20
20
  export LOG = (lArgs...) ->
21
21
 
22
22
  [label, item] = lArgs
23
23
  if lArgs.length > 1
24
- console.log sep_dash
25
- if item?
26
- console.log "#{label}:"
27
- console.log untabify(orderedStringify(item))
24
+ # --- There's both a label and an item
25
+ if ! item?
26
+ console.log "#{label}: UNDEFINED"
28
27
  else
29
- console.log "[#{label}]: UNDEFINED"
30
- console.log sep_dash
28
+ console.log sep_dash
29
+ console.log "#{label}:"
30
+ if isString(item)
31
+ console.log item
32
+ else
33
+ console.log untabify(orderedStringify(item))
34
+ console.log sep_dash
31
35
  else
32
36
  console.log label
33
37
  return
34
38
 
39
+ # --- Use this instead to make it easier to remove all instances
35
40
  export DEBUG = LOG # synonym
36
41
 
37
42
  # ---------------------------------------------------------------------------
@@ -93,7 +98,7 @@ export orderedStringify = (obj, escape=false) ->
93
98
  skipInvalid: true
94
99
  indent: 1
95
100
  sortKeys: true
96
- lineWidth: -1
101
+ lineWidth: 40
97
102
  replacer: if escape then escReplacer else (name,value) -> value
98
103
  })
99
104
 
package/src/log_utils.js CHANGED
@@ -34,24 +34,29 @@ putstr = undef;
34
34
  export var stringify = undef;
35
35
 
36
36
  // ---------------------------------------------------------------------------
37
- // This is useful for debugging and easy to remove after debugging
37
+ // This is useful for debugging
38
38
  export var LOG = function(...lArgs) {
39
39
  var item, label;
40
40
  [label, item] = lArgs;
41
41
  if (lArgs.length > 1) {
42
- console.log(sep_dash);
43
- if (item != null) {
44
- console.log(`${label}:`);
45
- console.log(untabify(orderedStringify(item)));
42
+ if (item == null) {
43
+ console.log(`${label}: UNDEFINED`);
46
44
  } else {
47
- console.log(`[${label}]: UNDEFINED`);
45
+ console.log(sep_dash);
46
+ console.log(`${label}:`);
47
+ if (isString(item)) {
48
+ console.log(item);
49
+ } else {
50
+ console.log(untabify(orderedStringify(item)));
51
+ }
52
+ console.log(sep_dash);
48
53
  }
49
- console.log(sep_dash);
50
54
  } else {
51
55
  console.log(label);
52
56
  }
53
57
  };
54
58
 
59
+ // --- Use this instead to make it easier to remove all instances
55
60
  export var DEBUG = LOG; // synonym
56
61
 
57
62
 
@@ -113,7 +118,7 @@ export var orderedStringify = function(obj, escape = false) {
113
118
  skipInvalid: true,
114
119
  indent: 1,
115
120
  sortKeys: true,
116
- lineWidth: -1,
121
+ lineWidth: 40,
117
122
  replacer: escape ? escReplacer : function(name, value) {
118
123
  return value;
119
124
  }