Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
629 bytes
|
Line | |
---|
1 | var from = require('from')
|
---|
2 | var through = require('../')
|
---|
3 |
|
---|
4 | var tape = require('tape')
|
---|
5 |
|
---|
6 | tape('simple async example', function (t) {
|
---|
7 |
|
---|
8 | var n = 0, expected = [1,2,3,4,5], actual = []
|
---|
9 | from(expected)
|
---|
10 | .pipe(through(function(data) {
|
---|
11 | this.pause()
|
---|
12 | n ++
|
---|
13 | setTimeout(function(){
|
---|
14 | console.log('pushing data', data)
|
---|
15 | this.push(data)
|
---|
16 | this.resume()
|
---|
17 | }.bind(this), 300)
|
---|
18 | })).pipe(through(function(data) {
|
---|
19 | console.log('pushing data second time', data);
|
---|
20 | this.push(data)
|
---|
21 | })).on('data', function (d) {
|
---|
22 | actual.push(d)
|
---|
23 | }).on('end', function() {
|
---|
24 | t.deepEqual(actual, expected)
|
---|
25 | t.end()
|
---|
26 | })
|
---|
27 |
|
---|
28 | })
|
---|
Note:
See
TracBrowser
for help on using the repository browser.