codepoint-scanner

0.3.3 • Public • Published

codepoint-scanner

UTF-16 code-point based lexical string scanner.

Build Status Code Climate js-standard-style

npm install codepoint-scanner --save

You can also download the files manually.

npm stats

npm NPM downloads David

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

Licenses

GitHub license

Package Sidebar

Install

npm i codepoint-scanner

Weekly Downloads

1

Version

0.3.3

License

MIT

Last publish

Collaborators

  • wilmoore