@jdeighan/coffee-utils 3.0.5 → 3.0.6

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": "3.0.5",
4
+ "version": "3.0.6",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -49,13 +49,16 @@ export indented = (input, level=0) ->
49
49
 
50
50
  toAdd = indentation(level)
51
51
  if isArray(input)
52
- lLines = for line in input
53
- "#{toAdd}#{line}"
54
- return lLines
52
+ lInputLines = input
55
53
  else
56
- lLines = for line in blockToArray(input)
54
+ lInputLines = blockToArray(input)
55
+
56
+ lLines = for line in lInputLines
57
+ if isEmpty(line)
58
+ ""
59
+ else
57
60
  "#{toAdd}#{line}"
58
- return arrayToBlock(lLines)
61
+ return arrayToBlock(lLines)
59
62
 
60
63
  # ---------------------------------------------------------------------------
61
64
  # undented - string with 1st line indentation removed for each line
@@ -54,36 +54,31 @@ export var indentLevel = function(str) {
54
54
  // ---------------------------------------------------------------------------
55
55
  // indented - add indentation to each string in a block
56
56
  export var indented = function(input, level = 0) {
57
- var lLines, line, toAdd;
57
+ var lInputLines, lLines, line, toAdd;
58
58
  assert(level >= 0, "indented(): negative level");
59
59
  if (level === 0) {
60
60
  return input;
61
61
  }
62
62
  toAdd = indentation(level);
63
63
  if (isArray(input)) {
64
- lLines = (function() {
65
- var i, len, results;
66
- results = [];
67
- for (i = 0, len = input.length; i < len; i++) {
68
- line = input[i];
69
- results.push(`${toAdd}${line}`);
70
- }
71
- return results;
72
- })();
73
- return lLines;
64
+ lInputLines = input;
74
65
  } else {
75
- lLines = (function() {
76
- var i, len, ref, results;
77
- ref = blockToArray(input);
78
- results = [];
79
- for (i = 0, len = ref.length; i < len; i++) {
80
- line = ref[i];
66
+ lInputLines = blockToArray(input);
67
+ }
68
+ lLines = (function() {
69
+ var i, len, results;
70
+ results = [];
71
+ for (i = 0, len = lInputLines.length; i < len; i++) {
72
+ line = lInputLines[i];
73
+ if (isEmpty(line)) {
74
+ results.push("");
75
+ } else {
81
76
  results.push(`${toAdd}${line}`);
82
77
  }
83
- return results;
84
- })();
85
- return arrayToBlock(lLines);
86
- }
78
+ }
79
+ return results;
80
+ })();
81
+ return arrayToBlock(lLines);
87
82
  };
88
83
 
89
84
  // ---------------------------------------------------------------------------