Class: TextFeed

lib/md-fence~TextFeed(str)

Simple String wrapper class to help navigate the characters within the String.

Constructor

new TextFeed(str)

Parameters:
Name Type Description
str String input string.
Source:
Example
var feed = new TextFeed('some random text here!');
console.log(feed.peek());  // prints 's'
console.log(feed.peek(1)); // prints 'o'
console.log(feed.next());  // prints 's'
console.log(feed.next());  // prints 'o'
console.log(feed.next(2)); // prints 'me'
console.log(feed.skip(1)); // skip ' '
console.log(feed.next());  // prints 'r'

Methods

next(nopt) → {String}

Return the next `n` characters and update the internal pointer.
Parameters:
Name Type Attributes Default Description
n Number <optional>
0 next `n` characters to return.
Source:
Returns:
Type
String

peek(nopt) → {String}

Return the next `n` characters but do not update the internal pointer.
Parameters:
Name Type Attributes Default Description
n Number <optional>
0 next `n` characters to peek.
Source:
Returns:
Type
String

skip(nopt) → {TextFeed}

Skip the next `n` characters and return a reference to itself.
Parameters:
Name Type Attributes Default Description
n Number <optional>
1 number of characters to skip.
Source:
Returns:
Type
TextFeed

toString() → {String}

Return the internal string.
Source:
Returns:
Type
String