PHP 8.2.30
Preview: test.js Size: 1.40 KB
//opt/alt/alt-nodejs9/root/lib/node_modules/npm/node_modules/mississippi/node_modules/stream-each/test.js

var tape = require('tape')
var through = require('through2')
var each = require('./')

tape('each', function (t) {
  var s = through.obj()
  s.write('a')
  s.write('b')
  s.write('c')
  s.end()

  s.on('end', function () {
    t.end()
  })

  var expected = ['a', 'b', 'c']
  each(s, function (data, next) {
    t.same(data, expected.shift())
    next()
  })
})

tape('each and callback', function (t) {
  var s = through.obj()
  s.write('a')
  s.write('b')
  s.write('c')
  s.end()

  var expected = ['a', 'b', 'c']
  each(s, function (data, next) {
    t.same(data, expected.shift())
    next()
  }, function () {
    t.end()
  })
})

tape('each (write after)', function (t) {
  var s = through.obj()
  s.on('end', function () {
    t.end()
  })

  var expected = ['a', 'b', 'c']
  each(s, function (data, next) {
    t.same(data, expected.shift())
    next()
  })

  setTimeout(function () {
    s.write('a')
    s.write('b')
    s.write('c')
    s.end()
  }, 100)
})

tape('each error', function (t) {
  var s = through.obj()
  s.write('hello')
  s.on('error', function (err) {
    t.same(err.message, 'stop')
    t.end()
  })

  each(s, function (data, next) {
    next(new Error('stop'))
  })
})

tape('each error and callback', function (t) {
  var s = through.obj()
  s.write('hello')

  each(s, function (data, next) {
    next(new Error('stop'))
  }, function (err) {
    t.same(err.message, 'stop')
    t.end()
  })
})

Directory Contents

Dirs: 1 × Files: 8

Name Size Perms Modified Actions
- drwxr-xr-x 2024-03-03 22:42:02
Edit Download
13 B lrw-r--r-- 2021-09-28 11:28:42
Edit Download
62 B lrw-r--r-- 2021-09-28 11:28:42
Edit Download
352 B lrw-r--r-- 2021-09-28 11:28:42
Edit Download
910 B lrw-r--r-- 2021-09-28 11:28:42
Edit Download
1.05 KB lrw-r--r-- 2021-09-28 11:28:42
Edit Download
1.52 KB lrw-r--r-- 2021-09-28 11:28:42
Edit Download
1012 B lrw-r--r-- 2021-09-28 11:28:42
Edit Download
1.40 KB lrw-r--r-- 2021-09-28 11:28:42
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).