@jdeighan/coffee-utils 8.0.6 → 8.0.7
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/Section.coffee +18 -12
- package/src/Section.js +17 -12
- package/src/SectionMap.coffee +2 -1
- package/src/SectionMap.js +2 -1
package/package.json
CHANGED
package/src/Section.coffee
CHANGED
@@ -12,34 +12,34 @@ export class Section
|
|
12
12
|
|
13
13
|
constructor: (@name) ->
|
14
14
|
|
15
|
-
@
|
15
|
+
@lParts = []
|
16
16
|
|
17
17
|
# ..........................................................
|
18
18
|
|
19
19
|
length: () ->
|
20
20
|
|
21
|
-
return @
|
21
|
+
return @lParts.length
|
22
22
|
|
23
23
|
# ..........................................................
|
24
24
|
|
25
25
|
indent: (level=1) ->
|
26
26
|
|
27
|
-
lNewLines = for line in @
|
27
|
+
lNewLines = for line in @lParts
|
28
28
|
indented(line, level)
|
29
|
-
@
|
29
|
+
@lParts = lNewLines
|
30
30
|
return
|
31
31
|
|
32
32
|
# ..........................................................
|
33
33
|
|
34
34
|
isEmpty: () ->
|
35
35
|
|
36
|
-
return (@
|
36
|
+
return (@lParts.length == 0)
|
37
37
|
|
38
38
|
# ..........................................................
|
39
39
|
|
40
40
|
nonEmpty: () ->
|
41
41
|
|
42
|
-
return (@
|
42
|
+
return (@lParts.length > 0)
|
43
43
|
|
44
44
|
# ..........................................................
|
45
45
|
|
@@ -47,9 +47,9 @@ export class Section
|
|
47
47
|
|
48
48
|
if isArray(data)
|
49
49
|
for line in data
|
50
|
-
@
|
50
|
+
@lParts.push line
|
51
51
|
else
|
52
|
-
@
|
52
|
+
@lParts.push data
|
53
53
|
return
|
54
54
|
|
55
55
|
# ..........................................................
|
@@ -57,16 +57,22 @@ export class Section
|
|
57
57
|
prepend: (data) ->
|
58
58
|
|
59
59
|
if isArray(data)
|
60
|
-
@
|
60
|
+
@lParts = [data..., @lParts...]
|
61
61
|
else
|
62
|
-
@
|
62
|
+
@lParts = [data, @lParts...]
|
63
63
|
return
|
64
64
|
|
65
65
|
# ..........................................................
|
66
66
|
|
67
|
+
getParts: () ->
|
68
|
+
|
69
|
+
return @lParts
|
70
|
+
|
71
|
+
# ..........................................................
|
72
|
+
|
67
73
|
getBlock: () ->
|
68
74
|
|
69
|
-
if (@
|
75
|
+
if (@lParts.length == 0)
|
70
76
|
return undef
|
71
77
|
else
|
72
|
-
return arrayToBlock(@
|
78
|
+
return arrayToBlock(@lParts)
|
package/src/Section.js
CHANGED
@@ -21,12 +21,12 @@ import {
|
|
21
21
|
export var Section = class Section {
|
22
22
|
constructor(name) {
|
23
23
|
this.name = name;
|
24
|
-
this.
|
24
|
+
this.lParts = [];
|
25
25
|
}
|
26
26
|
|
27
27
|
// ..........................................................
|
28
28
|
length() {
|
29
|
-
return this.
|
29
|
+
return this.lParts.length;
|
30
30
|
}
|
31
31
|
|
32
32
|
// ..........................................................
|
@@ -34,7 +34,7 @@ export var Section = class Section {
|
|
34
34
|
var lNewLines, line;
|
35
35
|
lNewLines = (function() {
|
36
36
|
var i, len, ref, results;
|
37
|
-
ref = this.
|
37
|
+
ref = this.lParts;
|
38
38
|
results = [];
|
39
39
|
for (i = 0, len = ref.length; i < len; i++) {
|
40
40
|
line = ref[i];
|
@@ -42,17 +42,17 @@ export var Section = class Section {
|
|
42
42
|
}
|
43
43
|
return results;
|
44
44
|
}).call(this);
|
45
|
-
this.
|
45
|
+
this.lParts = lNewLines;
|
46
46
|
}
|
47
47
|
|
48
48
|
// ..........................................................
|
49
49
|
isEmpty() {
|
50
|
-
return this.
|
50
|
+
return this.lParts.length === 0;
|
51
51
|
}
|
52
52
|
|
53
53
|
// ..........................................................
|
54
54
|
nonEmpty() {
|
55
|
-
return this.
|
55
|
+
return this.lParts.length > 0;
|
56
56
|
}
|
57
57
|
|
58
58
|
// ..........................................................
|
@@ -61,28 +61,33 @@ export var Section = class Section {
|
|
61
61
|
if (isArray(data)) {
|
62
62
|
for (i = 0, len = data.length; i < len; i++) {
|
63
63
|
line = data[i];
|
64
|
-
this.
|
64
|
+
this.lParts.push(line);
|
65
65
|
}
|
66
66
|
} else {
|
67
|
-
this.
|
67
|
+
this.lParts.push(data);
|
68
68
|
}
|
69
69
|
}
|
70
70
|
|
71
71
|
// ..........................................................
|
72
72
|
prepend(data) {
|
73
73
|
if (isArray(data)) {
|
74
|
-
this.
|
74
|
+
this.lParts = [...data, ...this.lParts];
|
75
75
|
} else {
|
76
|
-
this.
|
76
|
+
this.lParts = [data, ...this.lParts];
|
77
77
|
}
|
78
78
|
}
|
79
79
|
|
80
|
+
// ..........................................................
|
81
|
+
getParts() {
|
82
|
+
return this.lParts;
|
83
|
+
}
|
84
|
+
|
80
85
|
// ..........................................................
|
81
86
|
getBlock() {
|
82
|
-
if (this.
|
87
|
+
if (this.lParts.length === 0) {
|
83
88
|
return undef;
|
84
89
|
} else {
|
85
|
-
return arrayToBlock(this.
|
90
|
+
return arrayToBlock(this.lParts);
|
86
91
|
}
|
87
92
|
}
|
88
93
|
|
package/src/SectionMap.coffee
CHANGED
@@ -120,7 +120,8 @@ export class SectionMap
|
|
120
120
|
return
|
121
121
|
|
122
122
|
# ..........................................................
|
123
|
-
# --- procFunc should be (name,
|
123
|
+
# --- procFunc should be (name, block) ->
|
124
|
+
# return processed block
|
124
125
|
|
125
126
|
getBlock: (procFunc=undef, lTree=undef) ->
|
126
127
|
|
package/src/SectionMap.js
CHANGED
@@ -147,7 +147,8 @@ export var SectionMap = class SectionMap {
|
|
147
147
|
}
|
148
148
|
|
149
149
|
// ..........................................................
|
150
|
-
// --- procFunc should be (name,
|
150
|
+
// --- procFunc should be (name, block) ->
|
151
|
+
// return processed block
|
151
152
|
getBlock(procFunc = undef, lTree = undef) {
|
152
153
|
var j, lParts, len, part, result, text;
|
153
154
|
debug("enter getBlock()");
|