mirror of
				https://scm.univ-tours.fr/22107988t/rappaurio-sae501_502.git
				synced 2025-11-04 11:15:22 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			580 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			580 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const { Transform } = require('stream')
 | 
						|
 | 
						|
const constructTree = require('./construct-tree')
 | 
						|
 | 
						|
class StreamTreeConstructor extends Transform {
 | 
						|
  constructor (options) {
 | 
						|
    super(Object.assign(
 | 
						|
      {},
 | 
						|
      options,
 | 
						|
      {
 | 
						|
        objectMode: true,
 | 
						|
        readableObjectMode: true
 | 
						|
      }
 | 
						|
    ))
 | 
						|
 | 
						|
    this.currentState = undefined
 | 
						|
  }
 | 
						|
 | 
						|
  _transform (tokensChunk, encoding, callback) {
 | 
						|
    const { state, ast } = constructTree(
 | 
						|
      tokensChunk,
 | 
						|
      this.currentState
 | 
						|
    )
 | 
						|
 | 
						|
    this.currentState = state
 | 
						|
 | 
						|
    callback(null, ast)
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
module.exports = StreamTreeConstructor
 |