PHP 8.2.30
Preview: numbers.js Size: 896 B
/opt/alt/alt-nodejs9/root/lib/node_modules/npm/node_modules/tar/node_modules/minipass/bench/lib/numbers.js

'use strict'
const stream = require('stream')

const numbers = new Array(1000).join(',').split(',').map((v, k) => k)
let acc = ''
const strings = numbers.map(n => acc += n)
const bufs = strings.map(s => new Buffer(s))
const objs = strings.map(s => ({ str: s }))

module.exports = class Numbers {
  constructor (opt) {
    this.objectMode = opt.objectMode
    this.encoding = opt.encoding
    this.ii = 0
    this.done = false
  }
  pipe (dest) {
    this.dest = dest
    this.go()
    return dest
  }

  go () {
    let flowing = true
    while (flowing) {
      if (this.ii >= 1000) {
        this.dest.end()
        this.done = true
        flowing = false
      } else {
        flowing = this.dest.write(
          (this.objectMode ? objs
          : this.encoding ? strings
          : bufs)[this.ii++])
      }
    }

    if (!this.done)
      this.dest.once('drain', _ => this.go())
  }
}

Directory Contents

Dirs: 0 × Files: 6

Name Size Perms Modified Actions
220 B lrw-r--r-- 2021-09-28 11:28:37
Edit Download
233 B lrw-r--r-- 2021-09-28 11:28:37
Edit Download
230 B lrw-r--r-- 2021-09-28 11:28:37
Edit Download
216 B lrw-r--r-- 2021-09-28 11:28:37
Edit Download
896 B lrw-r--r-- 2021-09-28 11:28:37
Edit Download
387 B lrw-r--r-- 2021-09-28 11:28:37
Edit Download

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