Character Class
const chc = require('chc');
// Create an instance of CharSet.
const cs = new chc.CharSet('a', 'z');
// Get number of characters in the CharSet.
cs.length == 26;
// Get the next character in the CharSet.
cs.next();
// RETURN 'a'
// If all characters iterated.
cs.isEnd();
// RETURN false
// Reset the iteration state.
cs.reset();
cs.next();
// RETURN 'a'
-
class | CharSet chc.CharSet( CHAR start, CHAR end ) throws Error
�Create a charset containing characters from start to end. HereCHAR
maybe a code point number or a string containing one but only one character. When invalid arguments passed in, an error will be thrown.
To create an CharSet instance, this function supports both contrutor mode and factory mode.
Hereafter use <charset> to represent an instance of CharSet. -
class | CharSet chc.CharSet(String chars)
Create a charset containing every character in char. -
CharSet CharSet.concat( CHAR | string | CharSet | Array chars, ... )
Create a new charset. -
CharSet <charset>.concat( CHAR | string | CharSet | Array chars, ... )
Concatenate current charset with the character(s) or charsets, and return a new charset. -
boolean <charset>.isEnd()
If all characters in the charset have been iterated. -
number <charset>.length()
Number of characters in the charset. -
boolean <charset>.next()
Get the next character in the charset. -
boolean <charset>.reset()
Reset the iteration state of the charset. -
Array <charset>.toArray("string" | "number" type =
"string"
)
Return characters in the charset. If type equals "number", an array of code points will be returned.
Following packages depend on chc and offer predefined charsets: