@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 +1 -1
- package/src/indent_utils.coffee +8 -5
- package/src/indent_utils.js +16 -21
package/package.json
CHANGED
package/src/indent_utils.coffee
CHANGED
@@ -49,13 +49,16 @@ export indented = (input, level=0) ->
|
|
49
49
|
|
50
50
|
toAdd = indentation(level)
|
51
51
|
if isArray(input)
|
52
|
-
|
53
|
-
"#{toAdd}#{line}"
|
54
|
-
return lLines
|
52
|
+
lInputLines = input
|
55
53
|
else
|
56
|
-
|
54
|
+
lInputLines = blockToArray(input)
|
55
|
+
|
56
|
+
lLines = for line in lInputLines
|
57
|
+
if isEmpty(line)
|
58
|
+
""
|
59
|
+
else
|
57
60
|
"#{toAdd}#{line}"
|
58
|
-
|
61
|
+
return arrayToBlock(lLines)
|
59
62
|
|
60
63
|
# ---------------------------------------------------------------------------
|
61
64
|
# undented - string with 1st line indentation removed for each line
|
package/src/indent_utils.js
CHANGED
@@ -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
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
}
|
79
|
+
return results;
|
80
|
+
})();
|
81
|
+
return arrayToBlock(lLines);
|
87
82
|
};
|
88
83
|
|
89
84
|
// ---------------------------------------------------------------------------
|