<reponame>CMENDOZA1036/NewProjects<filename>.vscode-server/extensions/ritwickdey.liveserver-5.7.9/node_modules/event-stream/test/replace.asynct.js<gh_stars>0var es = require('../')
  , it = require('it-is').style('colour')
  , d = require('ubelt')
  , spec = require('stream-spec')

var next = process.nextTick

var fizzbuzz = 'kgfhvu9qnh3mr6eel97y6fq2hezzol8z'
  , fizz7buzz = '12F4BFseven8FB11F1314FB161sevenF19BF2223FB26F2829FB3132F34BF3seven38FB41F4344FB464sevenF49BF5253FB56F5859FB6162F64BF6seven68FBseven1Fseven3seven4FBseven6sevensevenFseven9BF8283FB86F8889FB9192F94BF9seven98FB'
  , fizzbuzzwhitespce = '  kgfhvu9qnh3mr6eel97y6fq2hezzol8z  '

exports ['fizz buzz'] = function (test) {

  var readThis = d.map(1, 100, function (i) {
    return (
     ! (i % 3 || i % 5) ? "FB" :
      !(i % 3) ? "F" :
      !(i % 5) ? "B" :
      ''+i
    )
  }) //array of multiples of 3 < 100

  var reader = es.readArray(readThis)
  var join = es.wait(function (err, string){
    it(string).equal(fizzbuzz)
    test.done()
  })
  reader.pipe(join)

}


exports ['fizz buzz replace'] = function (test) {
  var split = es.split(/(1)/)
  var replace = es.replace('7', 'seven')
//  var x = spec(replace).through()
  split
    .pipe(replace)
    .pipe(es.join(function (err, string) {
      it(string).equal(fizz7buzz)
    }))

    replace.on('close', function () {
//      x.validate()
      test.done()
    })

  split.write(fizzbuzz)
  split.end()

}


exports ['fizz buzz replace whitespace using regexp'] = function (test) {
  var split = es.split(/(1)/)
  var replaceLeading = es.replace(/^[\s]*/, '')
  var replaceTrailing = es.replace(/[\s]*$/, '')
//  var x = spec(replace).through()
  split
    .pipe(replaceLeading)
    .pipe(replaceTrailing)
    .pipe(es.join(function (err, string) {
      it(string).equal(fizzbuzz)
    }))

    replaceTrailing.on('close', function () {
//      x.validate()
      test.done()
    })

  split.write(fizzbuzz)
  split.end()

}

require('./helper')(module)
