@jdeighan/coffee-utils 14.0.17 → 14.0.18
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.coffee +6 -4
- package/src/block.js +11 -4
package/package.json
CHANGED
package/src/block.coffee
CHANGED
@@ -4,6 +4,7 @@ import fs from 'fs'
|
|
4
4
|
import readline from 'readline'
|
5
5
|
|
6
6
|
import {assert, croak} from '@jdeighan/base-utils/exceptions'
|
7
|
+
import {dbgEnter, dbgReturn, dbg} from '@jdeighan/base-utils/debug'
|
7
8
|
import {
|
8
9
|
undef, pass, defined, notdefined, rtrim, OL, isArrayOfStrings,
|
9
10
|
isEmpty, isString, isArray, nonEmpty, toArray, toBlock,
|
@@ -25,12 +26,13 @@ export splitBlock = (block) =>
|
|
25
26
|
|
26
27
|
export firstLine = (block) =>
|
27
28
|
|
29
|
+
dbgEnter 'firstLine', block
|
28
30
|
assert isString(block), "not a string"
|
29
31
|
pos = block.indexOf('\n')
|
30
|
-
if (pos
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
if (pos >= 0)
|
33
|
+
block = block.substring(0, pos)
|
34
|
+
dbgReturn 'firstLine', block
|
35
|
+
return block
|
34
36
|
|
35
37
|
# ---------------------------------------------------------------------------
|
36
38
|
|
package/src/block.js
CHANGED
@@ -9,6 +9,12 @@ import {
|
|
9
9
|
croak
|
10
10
|
} from '@jdeighan/base-utils/exceptions';
|
11
11
|
|
12
|
+
import {
|
13
|
+
dbgEnter,
|
14
|
+
dbgReturn,
|
15
|
+
dbg
|
16
|
+
} from '@jdeighan/base-utils/debug';
|
17
|
+
|
12
18
|
import {
|
13
19
|
undef,
|
14
20
|
pass,
|
@@ -40,13 +46,14 @@ export var splitBlock = (block) => {
|
|
40
46
|
// ---------------------------------------------------------------------------
|
41
47
|
export var firstLine = (block) => {
|
42
48
|
var pos;
|
49
|
+
dbgEnter('firstLine', block);
|
43
50
|
assert(isString(block), "not a string");
|
44
51
|
pos = block.indexOf('\n');
|
45
|
-
if (pos
|
46
|
-
|
47
|
-
} else {
|
48
|
-
return block.substring(0, pos);
|
52
|
+
if (pos >= 0) {
|
53
|
+
block = block.substring(0, pos);
|
49
54
|
}
|
55
|
+
dbgReturn('firstLine', block);
|
56
|
+
return block;
|
50
57
|
};
|
51
58
|
|
52
59
|
// ---------------------------------------------------------------------------
|