@@ -36,7 +36,7 @@ import escape from 'escape-string-regexp'
3636import { visitParents } from 'unist-util-visit-parents'
3737import { convert } from 'unist-util-is'
3838
39- var own = { } . hasOwnProperty
39+ const own = { } . hasOwnProperty
4040
4141/**
4242 * @param tree mdast tree
@@ -64,9 +64,9 @@ export const findAndReplace =
6464 */
6565 function ( tree , find , replace , options ) {
6666 /** @type {Options } */
67- var settings
67+ let settings
6868 /** @type {FindAndReplaceSchema|FindAndReplaceList } */
69- var schema
69+ let schema
7070
7171 if ( typeof find === 'string' || find instanceof RegExp ) {
7272 // @ts -expect-error don’t expect options twice.
@@ -82,9 +82,9 @@ export const findAndReplace =
8282 settings = { }
8383 }
8484
85- var ignored = convert ( settings . ignore || [ ] )
86- var pairs = toPairs ( schema )
87- var pairIndex = - 1
85+ const ignored = convert ( settings . ignore || [ ] )
86+ const pairs = toPairs ( schema )
87+ let pairIndex = - 1
8888
8989 while ( ++ pairIndex < pairs . length ) {
9090 visitParents ( tree , 'text' , visitor )
@@ -94,11 +94,11 @@ export const findAndReplace =
9494
9595 /** @type {import('unist-util-visit-parents').Visitor<Text> } */
9696 function visitor ( node , parents ) {
97- var index = - 1
97+ let index = - 1
9898 /** @type {Parent } */
99- var parent
99+ let parent
100100 /** @type {Parent } */
101- var grandparent
101+ let grandparent
102102
103103 while ( ++ index < parents . length ) {
104104 // @ts -expect-error mdast vs. unist parent.
@@ -127,18 +127,18 @@ export const findAndReplace =
127127 * @returns {VisitorResult }
128128 */
129129 function handler ( node , parent ) {
130- var find = pairs [ pairIndex ] [ 0 ]
131- var replace = pairs [ pairIndex ] [ 1 ]
130+ const find = pairs [ pairIndex ] [ 0 ]
131+ const replace = pairs [ pairIndex ] [ 1 ]
132132 /** @type {Array.<PhrasingContent> } */
133- var nodes = [ ]
134- var start = 0
135- var index = parent . children . indexOf ( node )
133+ let nodes = [ ]
134+ let start = 0
135+ let index = parent . children . indexOf ( node )
136136 /** @type {number } */
137- var position
137+ let position
138138 /** @type {RegExpMatchArray } */
139- var match
139+ let match
140140 /** @type {Array.<PhrasingContent>|PhrasingContent|string|false|undefined|null } */
141- var value
141+ let value
142142
143143 find . lastIndex = 0
144144
@@ -196,11 +196,11 @@ export const findAndReplace =
196196 * @returns {Pairs }
197197 */
198198function toPairs ( schema ) {
199- var index = - 1
199+ let index = - 1
200200 /** @type {Pairs } */
201- var result = [ ]
201+ const result = [ ]
202202 /** @type {string } */
203- var key
203+ let key
204204
205205 if ( typeof schema !== 'object' ) {
206206 throw new TypeError ( 'Expected array or object as schema' )
0 commit comments