@@ -36,7 +36,7 @@ import escape from 'escape-string-regexp'
36
36
import { visitParents } from 'unist-util-visit-parents'
37
37
import { convert } from 'unist-util-is'
38
38
39
- var own = { } . hasOwnProperty
39
+ const own = { } . hasOwnProperty
40
40
41
41
/**
42
42
* @param tree mdast tree
@@ -64,9 +64,9 @@ export const findAndReplace =
64
64
*/
65
65
function ( tree , find , replace , options ) {
66
66
/** @type {Options } */
67
- var settings
67
+ let settings
68
68
/** @type {FindAndReplaceSchema|FindAndReplaceList } */
69
- var schema
69
+ let schema
70
70
71
71
if ( typeof find === 'string' || find instanceof RegExp ) {
72
72
// @ts -expect-error don’t expect options twice.
@@ -82,9 +82,9 @@ export const findAndReplace =
82
82
settings = { }
83
83
}
84
84
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
88
88
89
89
while ( ++ pairIndex < pairs . length ) {
90
90
visitParents ( tree , 'text' , visitor )
@@ -94,11 +94,11 @@ export const findAndReplace =
94
94
95
95
/** @type {import('unist-util-visit-parents').Visitor<Text> } */
96
96
function visitor ( node , parents ) {
97
- var index = - 1
97
+ let index = - 1
98
98
/** @type {Parent } */
99
- var parent
99
+ let parent
100
100
/** @type {Parent } */
101
- var grandparent
101
+ let grandparent
102
102
103
103
while ( ++ index < parents . length ) {
104
104
// @ts -expect-error mdast vs. unist parent.
@@ -127,18 +127,18 @@ export const findAndReplace =
127
127
* @returns {VisitorResult }
128
128
*/
129
129
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 ]
132
132
/** @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 )
136
136
/** @type {number } */
137
- var position
137
+ let position
138
138
/** @type {RegExpMatchArray } */
139
- var match
139
+ let match
140
140
/** @type {Array.<PhrasingContent>|PhrasingContent|string|false|undefined|null } */
141
- var value
141
+ let value
142
142
143
143
find . lastIndex = 0
144
144
@@ -196,11 +196,11 @@ export const findAndReplace =
196
196
* @returns {Pairs }
197
197
*/
198
198
function toPairs ( schema ) {
199
- var index = - 1
199
+ let index = - 1
200
200
/** @type {Pairs } */
201
- var result = [ ]
201
+ const result = [ ]
202
202
/** @type {string } */
203
- var key
203
+ let key
204
204
205
205
if ( typeof schema !== 'object' ) {
206
206
throw new TypeError ( 'Expected array or object as schema' )
0 commit comments