@jdeighan/coffee-utils 10.0.16 → 10.0.17
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/block_utils.coffee +5 -4
- package/src/block_utils.js +6 -3
- package/src/coffee_utils.coffee +6 -0
- package/src/coffee_utils.js +5 -0
- package/src/indent_utils.coffee +2 -1
- package/src/indent_utils.js +2 -1
package/package.json
CHANGED
package/src/block_utils.coffee
CHANGED
@@ -5,8 +5,9 @@ import readline from 'readline'
|
|
5
5
|
|
6
6
|
import {assert, error, croak} from '@jdeighan/unit-tester/utils'
|
7
7
|
import {
|
8
|
-
undef, pass, defined,
|
9
|
-
|
8
|
+
undef, pass, defined, notdefined,
|
9
|
+
isEmpty, isString, isArray, nonEmpty, isArrayOfStrings,
|
10
|
+
escapeStr, rtrim, OL,
|
10
11
|
} from '@jdeighan/coffee-utils'
|
11
12
|
|
12
13
|
# ---------------------------------------------------------------------------
|
@@ -90,9 +91,9 @@ export arrayToBlock = (lLines) ->
|
|
90
91
|
|
91
92
|
export toBlock = (lLines) ->
|
92
93
|
|
93
|
-
if (lLines
|
94
|
+
if notdefined(lLines)
|
94
95
|
return undef
|
95
|
-
assert
|
96
|
+
assert isArrayOfStrings(lLines), "lLines is not an array: #{OL(lLines)}"
|
96
97
|
lNewLines = []
|
97
98
|
for line in lLines
|
98
99
|
if defined(line)
|
package/src/block_utils.js
CHANGED
@@ -14,12 +14,15 @@ import {
|
|
14
14
|
undef,
|
15
15
|
pass,
|
16
16
|
defined,
|
17
|
+
notdefined,
|
17
18
|
isEmpty,
|
18
19
|
isString,
|
19
20
|
isArray,
|
20
21
|
nonEmpty,
|
22
|
+
isArrayOfStrings,
|
23
|
+
escapeStr,
|
21
24
|
rtrim,
|
22
|
-
|
25
|
+
OL
|
23
26
|
} from '@jdeighan/coffee-utils';
|
24
27
|
|
25
28
|
// ---------------------------------------------------------------------------
|
@@ -113,10 +116,10 @@ export var arrayToBlock = function(lLines) {
|
|
113
116
|
// but undef items are ignored
|
114
117
|
export var toBlock = function(lLines) {
|
115
118
|
var i, lNewLines, len1, line;
|
116
|
-
if (lLines
|
119
|
+
if (notdefined(lLines)) {
|
117
120
|
return undef;
|
118
121
|
}
|
119
|
-
assert(
|
122
|
+
assert(isArrayOfStrings(lLines), `lLines is not an array: ${OL(lLines)}`);
|
120
123
|
lNewLines = [];
|
121
124
|
for (i = 0, len1 = lLines.length; i < len1; i++) {
|
122
125
|
line = lLines[i];
|
package/src/coffee_utils.coffee
CHANGED
@@ -647,3 +647,9 @@ export getOptions = (hOptions, hDefault={}) ->
|
|
647
647
|
return hOptions
|
648
648
|
else
|
649
649
|
return hDefault
|
650
|
+
|
651
|
+
# ---------------------------------------------------------------------------
|
652
|
+
|
653
|
+
export timestamp = () ->
|
654
|
+
|
655
|
+
return new Date().toLocaleTimeString("en-US")
|
package/src/coffee_utils.js
CHANGED
@@ -731,3 +731,8 @@ export var getOptions = function(hOptions, hDefault = {}) {
|
|
731
731
|
return hDefault;
|
732
732
|
}
|
733
733
|
};
|
734
|
+
|
735
|
+
// ---------------------------------------------------------------------------
|
736
|
+
export var timestamp = function() {
|
737
|
+
return new Date().toLocaleTimeString("en-US");
|
738
|
+
};
|
package/src/indent_utils.coffee
CHANGED
@@ -68,7 +68,8 @@ export isUndented = (line) ->
|
|
68
68
|
return (lMatches[0].length == 0)
|
69
69
|
|
70
70
|
# ---------------------------------------------------------------------------
|
71
|
-
# indented - add indentation to each string in a block
|
71
|
+
# indented - add indentation to each string in a block or array
|
72
|
+
# - always returns a string
|
72
73
|
|
73
74
|
export indented = (input, level=1, oneIndent="\t") ->
|
74
75
|
|
package/src/indent_utils.js
CHANGED
@@ -81,7 +81,8 @@ export var isUndented = function(line) {
|
|
81
81
|
};
|
82
82
|
|
83
83
|
// ---------------------------------------------------------------------------
|
84
|
-
// indented - add indentation to each string in a block
|
84
|
+
// indented - add indentation to each string in a block or array
|
85
|
+
// - always returns a string
|
85
86
|
export var indented = function(input, level = 1, oneIndent = "\t") {
|
86
87
|
var lInputLines, lLines, line, toAdd;
|
87
88
|
assert(level >= 0, "indented(): negative level");
|