1- 'use strict'
2-
3- var assert = require ( 'assert' )
4- var test = require ( 'tape' )
5- var remark = require ( 'remark' )
6- var gfm = require ( 'remark-gfm' )
7- var visit = require ( '.' )
1+ import assert from 'assert'
2+ import test from 'tape'
3+ import remark from 'remark'
4+ import gfm from 'remark-gfm'
5+ import { visit , CONTINUE , EXIT , SKIP } from './index.js'
86
97var tree = remark ( ) . parse ( 'Some _emphasis_, **importance**, and `code`.' )
108
11- var STOP = 5
12- var SKIP = 7
13- var SKIP_REVERSE = 6
9+ var stopIndex = 5
10+ var skipIndex = 7
11+ var skipReverseIndex = 6
1412
1513var texts = 6
1614var codes = 1
@@ -146,7 +144,7 @@ test('unist-util-visit', function (t) {
146144 } )
147145
148146 t . test ( 'should accept an array of `is`-compatible tests' , function ( st ) {
149- var expected = [ 'root' , 'paragraph' , 'emphasis' , 'strong' ]
147+ var expected = new Set ( [ 'root' , 'paragraph' , 'emphasis' , 'strong' ] )
150148 var tests = [ test , 'paragraph' , { value : '.' } , [ 'emphasis' , 'strong' ] ]
151149 var n = 0
152150
@@ -157,7 +155,7 @@ test('unist-util-visit', function (t) {
157155 st . end ( )
158156
159157 function visitor ( node ) {
160- var ok = expected . includes ( node . type ) || node . value === '.'
158+ var ok = expected . has ( node . type ) || node . value === '.'
161159 assert . ok ( ok , 'should be a requested type: ' + node . type )
162160 n ++
163161 }
@@ -172,13 +170,13 @@ test('unist-util-visit', function (t) {
172170
173171 visit ( tree , visitor )
174172
175- st . equal ( n , STOP , 'should visit nodes until `visit. EXIT` is given' )
173+ st . equal ( n , stopIndex , 'should visit nodes until `EXIT` is given' )
176174
177175 st . end ( )
178176
179177 function visitor ( node ) {
180178 assert . strictEqual ( node . type , types [ n ++ ] , 'should be the expected type' )
181- return n === STOP ? visit . EXIT : visit . CONTINUE
179+ return n === stopIndex ? EXIT : CONTINUE
182180 }
183181 } )
184182
@@ -187,7 +185,7 @@ test('unist-util-visit', function (t) {
187185
188186 visit ( tree , visitor , true )
189187
190- st . equal ( n , STOP , 'should visit nodes until `visit. EXIT` is given' )
188+ st . equal ( n , stopIndex , 'should visit nodes until `EXIT` is given' )
191189
192190 st . end ( )
193191
@@ -197,7 +195,7 @@ test('unist-util-visit', function (t) {
197195 reverseTypes [ n ++ ] ,
198196 'should be the expected type'
199197 )
200- return n === STOP ? visit . EXIT : visit . CONTINUE
198+ return n === stopIndex ? EXIT : CONTINUE
201199 }
202200 } )
203201
@@ -210,7 +208,7 @@ test('unist-util-visit', function (t) {
210208 st . equal (
211209 count ,
212210 types . length - 1 ,
213- 'should visit nodes except when `visit. SKIP` is given'
211+ 'should visit nodes except when `SKIP` is given'
214212 )
215213
216214 st . end ( )
@@ -219,9 +217,9 @@ test('unist-util-visit', function (t) {
219217 assert . strictEqual ( node . type , types [ n ++ ] , 'should be the expected type' )
220218 count ++
221219
222- if ( n === SKIP ) {
220+ if ( n === skipIndex ) {
223221 n ++ // The one node inside it.
224- return visit . SKIP
222+ return SKIP
225223 }
226224 }
227225 } )
@@ -235,7 +233,7 @@ test('unist-util-visit', function (t) {
235233 st . equal (
236234 count ,
237235 reverseTypes . length - 1 ,
238- 'should visit nodes except when `visit. SKIP` is given'
236+ 'should visit nodes except when `SKIP` is given'
239237 )
240238
241239 st . end ( )
@@ -248,9 +246,9 @@ test('unist-util-visit', function (t) {
248246 )
249247 count ++
250248
251- if ( n === SKIP_REVERSE ) {
249+ if ( n === skipReverseIndex ) {
252250 n ++ // The one node inside it.
253- return visit . SKIP
251+ return SKIP
254252 }
255253 }
256254 } )
0 commit comments