Skip to content

Commit 1b0bd19

Browse files
committed
Add improved docs
1 parent a643531 commit 1b0bd19

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function cont(code) {
2828
}
2929

3030
/**
31-
* Checks if the given string is a valid identifier name.
31+
* Checks if the given value is a valid identifier name.
3232
*
3333
* @param {string} name
3434
* Identifier to check.

readme.md

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`name(value)`](#namevalue)
21-
* [`start(code)`](#startcode)
2220
* [`cont(code)`](#contcode)
21+
* [`name(name)`](#namename)
22+
* [`start(code)`](#startcode)
2323
* [Types](#types)
2424
* [Compatibility](#compatibility)
2525
* [Related](#related)
@@ -39,7 +39,7 @@ You can use this utility when generating IDs from strings or parsing IDs.
3939
## Install
4040

4141
This package is [ESM only][esm].
42-
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
42+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
4343

4444
```sh
4545
npm install estree-util-is-identifier-name
@@ -62,7 +62,7 @@ In browsers with [`esm.sh`][esmsh]:
6262
## Use
6363

6464
```js
65-
import {name, start, cont} from 'estree-util-is-identifier-name'
65+
import {cont, name, start} from 'estree-util-is-identifier-name'
6666

6767
name('$something69') // => true
6868
name('69') // => false
@@ -74,22 +74,48 @@ cont(48) // => true (character code for `0`)
7474

7575
## API
7676

77-
This package exports the identifiers `name`, `start`, and `cont`.
77+
This package exports the identifiers [`cont`][cont], [`name`][name], and
78+
[`start`][start].
7879
There is no default export.
7980

80-
### `name(value)`
81+
### `cont(code)`
82+
83+
Checks if the given character code can continue an identifier.
84+
85+
###### Parameters
86+
87+
* `code` (`number`)
88+
— character code to check
89+
90+
###### Returns
91+
92+
Whether `code` can continue an identifier (`boolean`).
93+
94+
### `name(name)`
95+
96+
Checks if the given value is a valid identifier name.
8197

82-
Checks if `value` (`string`) is a valid identifier name (`boolean`).
98+
###### Parameters
99+
100+
* `name` (`string`)
101+
— identifier to check
102+
103+
###### Returns
104+
105+
Whether `name` can be an identifier (`boolean`).
83106

84107
### `start(code)`
85108

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

89-
### `cont(code)`
111+
###### Parameters
112+
113+
* `code` (`number`)
114+
— character code to check
90115

91-
Checks if the given character code (`number`) can continue an identifier
92-
(`boolean`).
116+
###### Returns
117+
118+
Whether `code` can start an identifier (`boolean`).
93119

94120
## Types
95121

@@ -100,7 +126,7 @@ It exports no additional types.
100126

101127
Projects maintained by the unified collective are compatible with all maintained
102128
versions of Node.js.
103-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
129+
As of now, that is Node.js 14.14+ and 16.0+.
104130
Our projects sometimes work with older versions, but this is not guaranteed.
105131

106132
## Related
@@ -171,3 +197,9 @@ abide by its terms.
171197
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
172198

173199
[estree]: https://github.com/estree/estree
200+
201+
[cont]: #contcode
202+
203+
[name]: #namename
204+
205+
[start]: #startcode

0 commit comments

Comments
 (0)