@typeforce/identifier-regex
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

identifier-regex

NPM NPM CDN LICENSE

A regular expression (RegExp) that matches JavaScript identifiers.

Usage

    npm install @typeforce/identifier-regex --save   # Install package via NPM
    import { expect } from "chai";
    import identifier_regex from "@typeforce/identifier-regex";

    expect("foo").to.match(identifier_regex);
    expect("$foo").to.match(identifier_regex);
    expect("FooBar").to.match(identifier_regex);
    expect("_Baz").to.match(identifier_regex);
    expect("$_Baz_").to.match(identifier_regex);
    expect("Baz9").to.match(identifier_regex);
    expect("B9az$").to.match(identifier_regex);

    expect("9foo").not.to.match(identifier_regex);
    expect("!foo").not.to.match(identifier_regex);
    expect("@Bar").not.to.match(identifier_regex);
    expect("\"Bar\"").not.to.match(identifier_regex);

This package contains TypeScript type declarations.

Content Delivery Network (CDN)

This package can be imported via unpkg as demonstrated below.

    <script src="https://unpkg.com/@typeforce/identifier-regex/dist/index.min.js"></script>
    <script type="application/javascript">
        const str = "$foo";
        if (identifier_regex.test(str)) {
            // `str` matches the JavaScript identifier pattern!
        }
    </script>

Build & Test

When building the project, a folder named dist/ will be created if it does not already exist, where the compiled code will be outputted to. Type declaration files will also be generated and outputted to the dist/ folder.

A minified Javascript version of the entire project will be generated and outputted to dist/index.min.js.

    npm install     # Installs dependencies.
    npm run build   # Build the project.

This package uses Gulp for building, and Chai and Mocha for testing.

    npm test       # Run tests.

License

Refer to the LICENSE file for license information.

Readme

Keywords

Package Sidebar

Install

npm i @typeforce/identifier-regex

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

6.63 kB

Total Files

8

Last publish

Collaborators

  • mgthomas99