- ReplaceInlineCallback ⇒
string
Callback for string replacement
Kind: global class
- Lines
- new Lines(content)
- .get() ⇒
string
- .changed() ⇒
boolean
- .length() ⇒
number
- .contains(search, start, end) ⇒
boolean
- .count(search, start, end) ⇒
number
- .index(search, start, end) ⇒
number
|null
- .indexes(search, start, end) ⇒
Array.<number>
- .before(search, insert, start, end) ⇒
Lines
- .after(search, insert, start, end) ⇒
Lines
- .append(insert) ⇒
Lines
- .prepend(insert) ⇒
Lines
- .remove(search, length, start, end) ⇒
Lines
- .replaceInline(search, replace, start, end) ⇒
Lines
Build an instance from a content
Throws:
Error
If content is not a string
Param | Type |
---|---|
content | string |
Get lines as a string
Kind: instance method of Lines
Denotes if the content has been changed
Kind: instance method of Lines
Get the current number of lines
Kind: instance method of Lines
Denotes if the data contains a string
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
Count how much lines match the search
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
Get the index of the first matching line
Kind: instance method of Lines
Returns: number
| null
- Return null if not found
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
Get the indexes of the matching lines
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
lines.before(search, insert, start, end) ⇒ Lines
Insert a content before a line
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
insert | string |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
lines.after(search, insert, start, end) ⇒ Lines
Insert a content after a line
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
insert | string |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
lines.append(insert) ⇒ Lines
Insert a block at the end of the content
Kind: instance method of Lines
Param | Type |
---|---|
insert | string |
lines.prepend(insert) ⇒ Lines
Insert a block at the beginning of the content
Kind: instance method of Lines
Param | Type |
---|---|
insert | string |
lines.remove(search, length, start, end) ⇒ Lines
Remove lines that match the pattern
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
length | number |
1 |
|
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
lines.replaceInline(search, replace, start, end) ⇒ Lines
Replace content within a line
Kind: instance method of Lines
Param | Type | Default | Description |
---|---|---|---|
search | string | RegExp |
||
replace | string | ReplaceInlineCallback |
||
start | number |
0 |
First line to process |
end | number | null |
|
Line to stop process (not included, null => until end) |
Callback for string replacement
Kind: global typedef
Param | Type |
---|---|
substring | string |
...args | Array.<any> |