11( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . mdastZone = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
22'use strict' ;
33
4+ /*
5+ * Dependencies.
6+ */
7+
8+ var visit = require ( 'mdast-util-visit' ) ;
9+
410/*
511 * Methods.
612 */
@@ -84,32 +90,6 @@ function marker(name) {
8490 ) ;
8591}
8692
87- /**
88- * Visit.
89- *
90- * @param {Node } tree
91- * @param {function(node, parent) } callback
92- */
93- function visit ( tree , callback ) {
94- /**
95- * Visit one node.
96- *
97- * @param {Node } node
98- * @param {number } index
99- */
100- function one ( node , index ) {
101- var parent = this || null ;
102-
103- callback ( node , parent , index ) ;
104-
105- if ( node . children ) {
106- node . children . forEach ( one , node ) ;
107- }
108- }
109-
110- one ( tree ) ;
111- }
112-
11393/**
11494 * Parse `value` into an object.
11595 *
@@ -267,10 +247,10 @@ function run(settings) {
267247 * Passed intto `visit`.
268248 *
269249 * @param {Node } node
270- * @param {Node } parent
271250 * @param {number } index
251+ * @param {Node } parent
272252 */
273- function gather ( node , parent , index ) {
253+ function gather ( node , index , parent ) {
274254 var result = test ( node ) ;
275255 var type = result && result . type ;
276256
@@ -377,5 +357,120 @@ function wrapper(options) {
377357
378358module . exports = wrapper ;
379359
360+ } , { "mdast-util-visit" :2 } ] , 2 :[ function ( require , module , exports ) {
361+ /**
362+ * @author Titus Wormer
363+ * @copyright 2015 Titus Wormer. All rights reserved.
364+ * @module mdast-util-visit
365+ * @fileoverview Utility to recursively walk over mdast nodes.
366+ */
367+
368+ 'use strict' ;
369+
370+ /**
371+ * Walk forwards.
372+ *
373+ * @param {Array.<*> } values - Things to iterate over,
374+ * forwards.
375+ * @param {function(*, number): boolean } callback - Function
376+ * to invoke.
377+ * @return {boolean } - False if iteration stopped.
378+ */
379+ function forwards ( values , callback ) {
380+ var index = - 1 ;
381+ var length = values . length ;
382+
383+ while ( ++ index < length ) {
384+ if ( callback ( values [ index ] , index ) === false ) {
385+ return false ;
386+ }
387+ }
388+
389+ return true ;
390+ }
391+
392+ /**
393+ * Walk backwards.
394+ *
395+ * @param {Array.<*> } values - Things to iterate over,
396+ * backwards.
397+ * @param {function(*, number): boolean } callback - Function
398+ * to invoke.
399+ * @return {boolean } - False if iteration stopped.
400+ */
401+ function backwards ( values , callback ) {
402+ var index = values . length ;
403+ var length = - 1 ;
404+
405+ while ( -- index > length ) {
406+ if ( callback ( values [ index ] , index ) === false ) {
407+ return false ;
408+ }
409+ }
410+
411+ return true ;
412+ }
413+
414+ /**
415+ * Visit.
416+ *
417+ * @param {Node } tree - Root node
418+ * @param {string } [type] - Node type.
419+ * @param {function(node): boolean? } callback - Invoked
420+ * with each found node. Can return `false` to stop.
421+ * @param {boolean } [reverse] - By default, `visit` will
422+ * walk forwards, when `reverse` is `true`, `visit`
423+ * walks backwards.
424+ */
425+ function visit ( tree , type , callback , reverse ) {
426+ var iterate ;
427+ var one ;
428+ var all ;
429+
430+ if ( typeof type === 'function' ) {
431+ reverse = callback ;
432+ callback = type ;
433+ type = null ;
434+ }
435+
436+ iterate = reverse ? backwards : forwards ;
437+
438+ /**
439+ * Visit `children` in `parent`.
440+ */
441+ all = function ( children , parent ) {
442+ return iterate ( children , function ( child , index ) {
443+ return child && one ( child , index , parent ) ;
444+ } ) ;
445+ } ;
446+
447+ /**
448+ * Visit a single node.
449+ */
450+ one = function ( node , index , parent ) {
451+ var result ;
452+
453+ index = index || ( parent ? 0 : null ) ;
454+
455+ if ( ! type || node . type === type ) {
456+ result = callback ( node , index , parent || null ) ;
457+ }
458+
459+ if ( node . children && result !== false ) {
460+ return all ( node . children , node ) ;
461+ }
462+
463+ return result ;
464+ } ;
465+
466+ one ( tree ) ;
467+ }
468+
469+ /*
470+ * Expose.
471+ */
472+
473+ module . exports = visit ;
474+
380475} , { } ] } , { } , [ 1 ] ) ( 1 )
381476} ) ;
0 commit comments