Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Latest commit

 

History

History
211 lines (148 loc) · 7.25 KB

API.md

File metadata and controls

211 lines (148 loc) · 7.25 KB

Classes

Lines

Typedefs

ReplaceInlineCallbackstring

Callback for string replacement

Lines

Kind: global class

new Lines(content)

Build an instance from a content

Throws:

  • Error If content is not a string
Param Type
content string

lines.get() ⇒ string

Get lines as a string

Kind: instance method of Lines

lines.changed() ⇒ boolean

Denotes if the content has been changed

Kind: instance method of Lines

lines.length() ⇒ number

Get the current number of lines

Kind: instance method of Lines

lines.contains(search, start, end) ⇒ boolean

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)

lines.count(search, start, end) ⇒ number

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)

lines.index(search, start, end) ⇒ number | null

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)

lines.indexes(search, start, end) ⇒ Array.<number>

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)

ReplaceInlineCallback ⇒ string

Callback for string replacement

Kind: global typedef

Param Type
substring string
...args Array.<any>