You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

chc

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chc

Character Classes

0.0.2
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

chc

Character Class

Table of contents

  • Get Started
  • API
  • About

Get Started

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'

API

Create CharSet Instances

  • class | CharSet chc.CharSet( CHAR start, CHAR end ) throws Error

    Create a charset containing characters from start to end. Here CHAR 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.

About

Following packages depend on chc and offer predefined charsets:

Keywords

character-class

FAQs

Package last updated on 01 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts