8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- Check if something can be an identifier name .
11
+ [ estree ] [ ] utility to check if something can be an identifier.
12
12
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.
14
34
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?
17
36
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] [ ] :
19
43
20
44
``` sh
21
45
npm install estree-util-is-identifier-name
22
46
```
23
47
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
+
24
62
## Use
25
63
26
64
``` js
@@ -36,26 +74,50 @@ cont(48) // => true (character code for `0`)
36
74
37
75
## API
38
76
39
- This package exports the following identifiers: ` name ` , ` start ` , and ` cont ` .
77
+ This package exports the identifiers ` name ` , ` start ` , and ` cont ` .
40
78
There is no default export.
41
79
42
80
### ` name(value) `
43
81
44
- Checks if the given string is a valid identifier name.
82
+ Checks if ` value ` ( ` string ` ) is a valid identifier name ( ` boolean ` ) .
45
83
46
84
### ` start(code) `
47
85
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 ` ).
49
88
50
89
### ` cont(code) `
51
90
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.
53
105
54
106
## Related
55
107
56
108
* [ ` goto-bus-stop/estree-is-identifier ` ] ( https://github.com/goto-bus-stop/estree-is-identifier )
57
109
— check if an AST node is an identifier
58
110
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
+
59
121
## License
60
122
61
123
[ MIT] [ license ] © [ Titus Wormer] [ author ]
@@ -90,6 +152,22 @@ Checks if the given character code can continue an identifier.
90
152
91
153
[ npm ] : https://docs.npmjs.com/cli/install
92
154
155
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
156
+
157
+ [ esmsh ] : https://esm.sh
158
+
159
+ [ typescript ] : https://www.typescriptlang.org
160
+
93
161
[ license ] : license
94
162
95
163
[ 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