Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qfox/reserved-words
:bookmark_tabs: ES reserved words checker
https://github.com/qfox/reserved-words
es2015 es2016 es2017 es5 es6 keywords reserved words
Last synced: 23 days ago
JSON representation
:bookmark_tabs: ES reserved words checker
- Host: GitHub
- URL: https://github.com/qfox/reserved-words
- Owner: qfox
- License: mit
- Created: 2015-07-20T10:00:07.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-26T12:51:16.000Z (over 4 years ago)
- Last Synced: 2024-04-09T15:37:36.531Z (7 months ago)
- Topics: es2015, es2016, es2017, es5, es6, keywords, reserved, words
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 10
- Watchers: 1
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# reserved-words
[![Build Status](https://secure.travis-ci.org/zxqfox/reserved-words.svg)](http://travis-ci.org/zxqfox/reserved-words)
## What is it?
Tiny package for detecting reserved words.
`Reserved Word` is either a `Keyword`, or a `Future Reserved Word`, or a `Null Literal`, or a `Boolean Literal`.
See: [ES5 #7.6.1](http://es5.github.io/#x7.6.1) and
[ES6 #11.6.2](http://www.ecma-international.org/ecma-262/6.0/#sec-reserved-words).## Installation
```
npm install reserved-words
```## API
### check(word, [dialect], [strict])
Returns `true` if provided identifier string is a Reserved Word
in some ECMAScript dialect (ECMA-262 edition).If the `strict` flag is truthy, this function additionally checks whether
`word` is a Keyword or Future Reserved Word under strict mode.#### Example
```
var reserved = require('reserved-words');
reserved.check('volatile', 'es3'); // true
reserved.check('volatile', 'es2015'); // false
reserved.check('yield', 3); // false
reserved.check('yield', 6); // true
```### dialects
#### es3 (or 3)
Represents [ECMA-262 3rd edition](http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf).
See section 7.5.1.
#### es5 (or 5)
Represents [ECMA-262 5th edition (ECMAScript 5.1)](http://es5.github.io/).
Reserved Words are formally defined in ECMA262 sections
[7.6.1.1](http://es5.github.io/#x7.6.1.1) and [7.6.1.2](http://es5.github.io/#x7.6.1.2).#### es2015 (or es6, 6)
Represents [ECMA-262 6th edition](ECMAScript 2015).
Reserved Words are formally defined in sections
[11.6.2.1](http://ecma-international.org/ecma-262/6.0/#sec-keywords) and
[11.6.2.2](http://ecma-international.org/ecma-262/6.0/#sec-future-reserved-words).### License
Licensed under [The MIT License](https://github.com/zxqfox/reserved-words/blob/master/LICENSE)