You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					34 lines
				
				423 B
			
		
		
			
		
	
	
					34 lines
				
				423 B
			| 
											3 years ago
										 | 
 | ||
|  | var pause = require('..') | ||
|  | var assert = require('assert') | ||
|  | 
 | ||
|  | var ps = pause() | ||
|  | var read = [], ended = false | ||
|  | 
 | ||
|  | ps.on('data', function (i) { | ||
|  |   read.push(i) | ||
|  | }) | ||
|  | 
 | ||
|  | ps.on('end', function () { | ||
|  |   ended = true | ||
|  | }) | ||
|  | 
 | ||
|  | assert.deepEqual(read, []) | ||
|  | 
 | ||
|  | ps.write(0) | ||
|  | ps.write(1) | ||
|  | ps.write(2) | ||
|  | 
 | ||
|  | assert.deepEqual(read, [0, 1, 2]) | ||
|  | 
 | ||
|  | ps.pause() | ||
|  | 
 | ||
|  | assert.deepEqual(read, [0, 1, 2]) | ||
|  | 
 | ||
|  | ps.end() | ||
|  | assert.equal(ended, false) | ||
|  | ps.resume() | ||
|  | assert.equal(ended, true) | ||
|  | 
 | ||
|  | 
 |