codepoint-scanner
v0.3.3
Published
UTF-16 code-point based lexical string scanner.
Downloads
8
Maintainers
Readme
codepoint-scanner
UTF-16 code-point based lexical string scanner.
npm install codepoint-scanner --save
You can also download the files manually.
npm stats
Usage
var scan = require('codepoint-scanner')
API
scanner.string()
var scanner = scan('Hello world!')
scanner.string()
// => 'Hello world!'
scanner.codepoints()
var scanner = scan('Hello world!')
scanner.codepoints()
// => [ 72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33 ]
scanner.index()
var scanner = scan('Hello world!')
scanner.index()
// => 0
scanner.next()
var scanner = scan('Hello world!')
scanner.next()
// => 101
scanner.next()
// => 108
scanner.index()
// => 2
scanner.bos()
var scanner = scan('Hello world!')
scanner.bos()
// => true
scanner.next()
// => 101
scanner.bos()
// => false
scanner.reset()
var scanner = scan('Hello world!')
scanner.next()
// => 101
scanner.reset().bos()
// => true
scanner.eos()
var scanner = scan('Hello world!')
scanner.eos()
// => false
scanner.index(scanner.length() - 1).eos()
// => true
scanner.$()
var scanner = scan('Hello world!')
scanner.eos()
// => false
scanner.$().eos()
// => true
scanner.peek()
var scanner = scan('Hello world!')
scanner.index()
// => 0
scanner.peek()
// => [ 72 ]
scanner.peek(5)
// => [ 32 ]
scanner.peek(5, 7)
// => [ 32, 119 ]
scanner.index()
// => 0
scanner.at()
var scanner = scan('Hello world!')
scanner.index()
// => 0
scanner.at(5)
// => 32
Contributing
SEE: contributing.md