@@ -39,14 +39,13 @@ function pipelineRun(p, ctx, next) {
3939
4040function pipelineStringify ( p , ctx ) {
4141 var result = p . stringify ( ctx . tree , ctx . file )
42- var file = ctx . file
4342
4443 if ( result === undefined || result === null ) {
4544 // Empty.
4645 } else if ( typeof result === 'string' || buffer ( result ) ) {
47- file . contents = result
46+ ctx . file . contents = result
4847 } else {
49- file . result = result
48+ ctx . file . result = result
5049 }
5150}
5251
@@ -55,8 +54,8 @@ function unified() {
5554 var attachers = [ ]
5655 var transformers = trough ( )
5756 var namespace = { }
58- var frozen = false
5957 var freezeIndex = - 1
58+ var frozen
6059
6160 // Data management.
6261 processor . data = data
@@ -82,10 +81,9 @@ function unified() {
8281 // Create a new processor based on the processor in the current scope.
8382 function processor ( ) {
8483 var destination = unified ( )
85- var length = attachers . length
8684 var index = - 1
8785
88- while ( ++ index < length ) {
86+ while ( ++ index < attachers . length ) {
8987 destination . use . apply ( null , attachers [ index ] )
9088 }
9189
@@ -103,8 +101,6 @@ function unified() {
103101 // In essence, always invoke this when exporting a processor.
104102 function freeze ( ) {
105103 var values
106- var plugin
107- var options
108104 var transformer
109105
110106 if ( frozen ) {
@@ -113,19 +109,16 @@ function unified() {
113109
114110 while ( ++ freezeIndex < attachers . length ) {
115111 values = attachers [ freezeIndex ]
116- plugin = values [ 0 ]
117- options = values [ 1 ]
118- transformer = null
119112
120- if ( options === false ) {
113+ if ( values [ 1 ] === false ) {
121114 continue
122115 }
123116
124- if ( options === true ) {
117+ if ( values [ 1 ] === true ) {
125118 values [ 1 ] = undefined
126119 }
127120
128- transformer = plugin . apply ( processor , values . slice ( 1 ) )
121+ transformer = values [ 0 ] . apply ( processor , values . slice ( 1 ) )
129122
130123 if ( typeof transformer === 'function' ) {
131124 transformers . use ( transformer )
@@ -145,9 +138,7 @@ function unified() {
145138 // Set `key`.
146139 if ( arguments . length === 2 ) {
147140 assertUnfrozen ( 'data' , frozen )
148-
149141 namespace [ key ] = value
150-
151142 return processor
152143 }
153144
@@ -221,16 +212,12 @@ function unified() {
221212 }
222213
223214 function addList ( plugins ) {
224- var length
225- var index
215+ var index = - 1
226216
227217 if ( plugins === null || plugins === undefined ) {
228218 // Empty.
229219 } else if ( typeof plugins === 'object' && 'length' in plugins ) {
230- length = plugins . length
231- index = - 1
232-
233- while ( ++ index < length ) {
220+ while ( ++ index < plugins . length ) {
234221 add ( plugins [ index ] )
235222 }
236223 } else {
@@ -254,15 +241,11 @@ function unified() {
254241 }
255242
256243 function find ( plugin ) {
257- var length = attachers . length
258244 var index = - 1
259- var entry
260245
261- while ( ++ index < length ) {
262- entry = attachers [ index ]
263-
264- if ( entry [ 0 ] === plugin ) {
265- return entry
246+ while ( ++ index < attachers . length ) {
247+ if ( attachers [ index ] [ 0 ] === plugin ) {
248+ return attachers [ index ]
266249 }
267250 }
268251 }
@@ -320,8 +303,8 @@ function unified() {
320303 // Run transforms on a unist node representation of a file (in string or
321304 // vfile representation), sync.
322305 function runSync ( node , file ) {
323- var complete = false
324306 var result
307+ var complete
325308
326309 run ( node , file , done )
327310
@@ -331,8 +314,8 @@ function unified() {
331314
332315 function done ( err , tree ) {
333316 complete = true
334- bail ( err )
335317 result = tree
318+ bail ( err )
336319 }
337320 }
338321
@@ -388,8 +371,8 @@ function unified() {
388371
389372 // Process the given document (in string or vfile representation), sync.
390373 function processSync ( doc ) {
391- var complete = false
392374 var file
375+ var complete
393376
394377 freeze ( )
395378 assertParser ( 'processSync' , processor . Parser )
0 commit comments