next-text

1.0.4 • Public • Published

travis-build-status npm-dependencies standard-js npm-node-version npm-version license

nextText is a small utility function to get the next letter from a partial string.

api

nextText

nextText creates an instance of nextText.

Params

text : String (required)

The complete string the module should iterate incrementally.

options : Object (optional)

You can override these options:

Option name Default value Description
restart false Once the text has been iterated, restart from the beginning.

nextTextInstance

The return value of calling nextText(string[, options]).

Methods

.toString

Returns the current value of the instance.

.next

Returns the next instance, with the updated current value.

usage

See Tests.

const nextText = require('next-text')
let text = nextText('This is a test')
console.log(text.toString()) // ''
text = text.next()
console.log(text) // 'T'
text = text.next()
console.log(text) // 'Th'
text = text.next()
console.log(text) // 'Thi'
text = text.next()
console.log(text) // 'This'
text = text.next()
console.log(text) // 'This '
text = text.next()
console.log(text) // 'This i'
text = text.next()
console.log(text) // 'This is'
// you get the point

Package Sidebar

Install

npm i next-text

Weekly Downloads

39

Version

1.0.4

License

MIT

Unpacked Size

6.35 kB

Total Files

6

Last publish

Collaborators

  • christian_fei