# is-valid-var-name

> Determines whether a string is a valid javascript variable name. ES2015 and ES5 compatibility. Strict mode evaluation by default.

Latest version **1.0.2** (published 2017-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-valid-var-name
pnpm add is-valid-var-name
yarn add is-valid-var-name
bun add is-valid-var-name
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2017-01-28 |
| First published | 2017-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Steven Westbrook |
| Maintainers | stevewestbrook |
| Keywords | var, name, identifier, variable, check, valid, validation, string, unicode |

## Links

- npm: https://www.npmjs.com/package/is-valid-var-name
- Repository: https://github.com/SteveWestbrook/is-valid-var-name
- Issues: https://github.com/SteveWestbrook/is-valid-var-name/issues
- npm.io page: https://npm.io/package/is-valid-var-name

## Dependencies (1)

- [unicode-categories](https://npm.io/package/unicode-categories.md) ^0.9.1

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2017-01-28
- 1.0.1 — 2017-01-27
- 1.0.0 — 2017-01-27

## README

# is-valid-var-name

Single-purpose [node](https://nodejs.org) module that determines whether a string is a valid javascript variable.

This implementation has been optimized for performance.

The primary function is ES6 compatible; ES5 variable names can also be validated.

```
const isVarName = require('is-valid-var-name');

// true
var isValid = isVarName('x');

// false
isValid = isVarName(' not a var ');

// win the respect of your colleagues with this highly maintainable code
isValid = isVarName('ᚢᚫᚱ');
```

**Installation**

```
$ npm install is-valid-var-name
```

**Options**

By default, the validation function assumes ES2015 strict mode.  These values can be overridden.

To provide ES5 evaluation:

```
const isVarName = require('is-valid-var-name').es5;

// valid under ES5
isValid = isVarName('await');
```

To turn off strict mode evaluation:
```
// Turn off strict mode evaluation
isVarName.strict = false;

// valid when strict mode is off
isValid = isVarName('arguments');
```

**What about other identifiers?**

This module validates variable names, but is not intended to validate more complex identifiers such as multi-part values (a.b.c) or string-accessible properties (a["null"]).

## Special Thanks/Acknowledgements
This implementation draws heavily on the excellent research of Matthias Bynens, who did the legwork in explaining valid variable names for [ES5](https://mathiasbynens.be/notes/javascript-identifiers) and [ES6](https://mathiasbynens.be/notes/javascript-identifiers-es6).

## License
Copyright (c) 2017 Steve Westbrook

[MIT](LICENSE)

---
_Source: https://npm.io/package/is-valid-var-name · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
