Skip to content

Commit 646ee55

Browse files
committed
Add improved docs
1 parent 791153b commit 646ee55

File tree

1 file changed

+87
-9
lines changed

1 file changed

+87
-9
lines changed

readme.md

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,57 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
Check if something can be an identifier name.
11+
[estree][] utility to check if something can be an identifier.
1212

13-
## Install
13+
## Contents
14+
15+
* [What is this?](#what-is-this)
16+
* [When should I use this?](#when-should-i-use-this)
17+
* [Install](#install)
18+
* [Use](#use)
19+
* [API](#api)
20+
* [`name(value)`](#namevalue)
21+
* [`start(code)`](#startcode)
22+
* [`cont(code)`](#contcode)
23+
* [Types](#types)
24+
* [Compatibility](#compatibility)
25+
* [Related](#related)
26+
* [Contribute](#contribute)
27+
* [License](#license)
28+
29+
## What is this?
30+
31+
This package is a utility that can be used to check if something can be an
32+
identifier name.
33+
For example, `a`, `_`, and `a1` are fine, but `1` and `-` are not.
1434

15-
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
16-
instead of `require`d.
35+
## When should I use this?
1736

18-
[npm][]:
37+
You can use this utility when generating IDs from strings or parsing IDs.
38+
39+
## Install
40+
41+
This package is [ESM only][esm].
42+
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
1943

2044
```sh
2145
npm install estree-util-is-identifier-name
2246
```
2347

48+
In Deno with [`esm.sh`][esmsh]:
49+
50+
```js
51+
import * as isIdentifierName from 'https://esm.sh/estree-util-is-identifier-name@2'
52+
```
53+
54+
In browsers with [`esm.sh`][esmsh]:
55+
56+
```html
57+
<script type="module">
58+
import * as isIdentifierName from 'https://esm.sh/estree-util-is-identifier-name@2?bundle'
59+
</script>
60+
```
61+
2462
## Use
2563

2664
```js
@@ -36,26 +74,50 @@ cont(48) // => true (character code for `0`)
3674

3775
## API
3876

39-
This package exports the following identifiers: `name`, `start`, and `cont`.
77+
This package exports the identifiers `name`, `start`, and `cont`.
4078
There is no default export.
4179

4280
### `name(value)`
4381

44-
Checks if the given string is a valid identifier name.
82+
Checks if `value` (`string`) is a valid identifier name (`boolean`).
4583

4684
### `start(code)`
4785

48-
Checks if the given character code can start an identifier.
86+
Checks if the given character code (`number`) can start an identifier
87+
(`boolean`).
4988

5089
### `cont(code)`
5190

52-
Checks if the given character code can continue an identifier.
91+
Checks if the given character code (`number`) can continue an identifier
92+
(`boolean`).
93+
94+
## Types
95+
96+
This package is fully typed with [TypeScript][].
97+
It exports no additional types.
98+
99+
## Compatibility
100+
101+
Projects maintained by the unified collective are compatible with all maintained
102+
versions of Node.js.
103+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
104+
Our projects sometimes work with older versions, but this is not guaranteed.
53105

54106
## Related
55107

56108
* [`goto-bus-stop/estree-is-identifier`](https://github.com/goto-bus-stop/estree-is-identifier)
57109
— check if an AST node is an identifier
58110

111+
## Contribute
112+
113+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
114+
ways to get started.
115+
See [`support.md`][support] for ways to get help.
116+
117+
This project has a [code of conduct][coc].
118+
By interacting with this repository, organization, or community you agree to
119+
abide by its terms.
120+
59121
## License
60122

61123
[MIT][license] © [Titus Wormer][author]
@@ -90,6 +152,22 @@ Checks if the given character code can continue an identifier.
90152

91153
[npm]: https://docs.npmjs.com/cli/install
92154

155+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
156+
157+
[esmsh]: https://esm.sh
158+
159+
[typescript]: https://www.typescriptlang.org
160+
93161
[license]: license
94162

95163
[author]: https://wooorm.com
164+
165+
[health]: https://github.com/syntax-tree/.github
166+
167+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
168+
169+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
170+
171+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
172+
173+
[estree]: https://github.com/estree/estree

0 commit comments

Comments
 (0)