@@ -39,7 +39,7 @@ about “monsieur”.
3939## Install  
4040
4141This package is [ ESM only] [ esm ] .
42- In Node.js (version 12.20+,  14.14+, 16.0+, 18 .0+), install with [ npm] [ ] :
42+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
4343
4444``` sh 
4545npm install nlcst-is-literal
@@ -48,14 +48,14 @@ npm install nlcst-is-literal
4848In Deno with [ ` esm.sh ` ] [ esmsh ] :
4949
5050``` js 
51- import  {isLiteral } from  " https://esm.sh/nlcst-is-literal@2" 
51+ import  {isLiteral } from  ' https://esm.sh/nlcst-is-literal@2' 
5252``` 
5353
5454In browsers with [ ` esm.sh ` ] [ esmsh ] :
5555
5656``` html 
5757<script  type =" module" 
58-   import  {isLiteral } from  " https://esm.sh/nlcst-is-literal@2?bundle"  
58+   import  {isLiteral } from  ' https://esm.sh/nlcst-is-literal@2?bundle'  
5959script >
6060``` 
6161
@@ -78,24 +78,20 @@ The word — quux — is meant as a literal.
7878…and our module ` example.js `  looks as follows:
7979
8080``` js 
81- import  {readSync } from  ' to-vfile' 
82- import  {unified } from  ' unified' 
83- import  retextEnglish  from  ' retext-english' 
81+ import  {read } from  ' to-vfile' 
82+ import  {ParseEnglish } from  ' parse-english' 
8483import  {visit } from  ' unist-util-visit' 
8584import  {toString } from  ' nlcst-to-string' 
8685import  {isLiteral } from  ' nlcst-is-literal' 
8786
88- const  file  =  readSync (' example.txt' 
87+ const  file  =  await  read (' example.txt' 
88+ const  tree  =  new  ParseEnglish ().parse (String (file))
8989
90- const  tree  =  unified ().use (retextEnglish).parse (file)
91- 
92- visit (tree, ' WordNode' 
93- 
94- function  visitor (node , index , parent ) {
90+ visit (tree, ' WordNode' function  (node , index , parent ) {
9591  if  (isLiteral (parent, index)) {
9692    console .log (toString (node))
9793  }
98- }
94+ }) 
9995``` 
10096
10197…now running ` node example.js `  yields:
@@ -110,20 +106,32 @@ quux
110106
111107## API  
112108
113- This package exports the identifier ` isLiteral ` .
109+ This package exports the identifier [ ` isLiteral ` ] [ isliteral ] .
114110There is no default export.
115111
116112### ` isLiteral(parent, index|child) `  
117113
118- Check if the ` child `  in ` parent `  is enclosed by matching delimiters.
119- If an ` index `  is given, the [ child] [ ]  of ` parent `  at that [ index] [ ]  is checked.
114+ Check if the child in ` parent `  at ` index `  is enclosed by matching delimiters.
120115
121116For example, ` foo `  is literal in the following samples:
122117
123118*    ` Foo - is meant as a literal. ` 
124119*    ` Meant as a literal is - foo. ` 
125120*    ` The word “foo” is meant as a literal. ` 
126121
122+ ###### Parameters  
123+ 
124+ *    ` parent `  ([ ` Node ` ] [ node ] )
125+     — parent node
126+ *    ` index `  (` number ` )
127+     — index of child in parent
128+ *    ` child `  ([ ` Node ` ] [ node ] )
129+     — child node of parent
130+ 
131+ ###### Returns  
132+ 
133+ Whether the child is a literal (` boolean ` ).
134+ 
127135## Types  
128136
129137This package is fully typed with [ TypeScript] [ ] .
@@ -133,7 +141,7 @@ It exports no additional types.
133141
134142Projects maintained by the unified collective are compatible with all maintained
135143versions of Node.js.
136- As of now, that is Node.js 12.20+,  14.14+, 16.0+,  and 18 .0+.
144+ As of now, that is Node.js 14.14+  and 16 .0+.
137145Our projects sometimes work with older versions, but this is not guaranteed.
138146
139147## Related  
@@ -207,6 +215,6 @@ abide by its terms.
207215
208216[ nlcst ] : https://github.com/syntax-tree/nlcst 
209217
210- [ index ] : https://github.com/syntax-tree/unist#index  
218+ [ node ] : https://github.com/syntax-tree/nlcst#nodes  
211219
212- [ child ] : https://github.com/syntax-tree/unist#child 
220+ [ isliteral ] : #isliteralparent-indexchild 
0 commit comments