$27 GRAYBYTE WORDPRESS FILE MANAGER $95

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.15.130 | ADMIN IP 216.73.216.51
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/alt-nodejs24/root/usr/lib/node_modules/npm/lib/utils/

HOME
Current File : /opt/alt/alt-nodejs24/root/usr/lib/node_modules/npm/lib/utils//format-search-stream.js
const { stripVTControlCharacters: strip } = require('node:util')
const { Minipass } = require('minipass')

// This module consumes package data in the following format:
//
// {
//   name: String,
//   description: String,
//   maintainers: [{ username: String, email: String }],
//   keywords: String | [String],
//   version: String,
//   date: Date // can be null,
// }
//
// The returned stream will format this package data into a byte stream of formatted, displayable output.

function filter (data, exclude) {
  const words = [data.name]
    .concat(data.maintainers.map(m => m.username))
    .concat(data.keywords || [])
    .map(f => f?.trim?.())
    .filter(Boolean)
    .join(' ')
    .toLowerCase()

  if (exclude.find(pattern => {
    // Treats both /foo and /foo/ as regex searches
    if (pattern.startsWith('/')) {
      if (pattern.endsWith('/')) {
        pattern = pattern.slice(0, -1)
      }
      return words.match(new RegExp(pattern.slice(1)))
    }
    return words.includes(pattern)
  })) {
    return false
  }

  return true
}

module.exports = (opts) => {
  return opts.json ? new JSONOutputStream(opts) : new TextOutputStream(opts)
}

class JSONOutputStream extends Minipass {
  #didFirst = false
  #exclude

  constructor (opts) {
    super()
    this.#exclude = opts.exclude
  }

  write (obj) {
    if (!filter(obj, this.#exclude)) {
      return
    }
    if (!this.#didFirst) {
      super.write('[\n')
      this.#didFirst = true
    } else {
      super.write('\n,\n')
    }

    return super.write(JSON.stringify(obj))
  }

  end () {
    super.write(this.#didFirst ? ']\n' : '\n[]\n')
    super.end()
  }
}

class TextOutputStream extends Minipass {
  #args
  #chalk
  #exclude
  #parseable

  constructor (opts) {
    super()
    // Consider a search for "cowboys" and "boy".
    // If we highlight "boys" first the "cowboys" string will no longer string match because of the ansi highlighting added to "boys".
    // If we highlight "boy" second then the ansi reset at the end will make the highlighting only on "cowboy" with a normal "s".
    // Neither is perfect but at least the first option doesn't do partial highlighting. So, we sort strings smaller to larger
    this.#args = opts.args
      .map(s => s.toLowerCase())
      .filter(Boolean)
      .sort((a, b) => a.length - b.length)
    this.#chalk = opts.npm.chalk
    this.#exclude = opts.exclude
    this.#parseable = opts.parseable
  }

  write (data) {
    if (!filter(data, this.#exclude)) {
      return
    }
    // Normalize
    const pkg = {
      authors: data.maintainers.map((m) => `${strip(m.username)}`).join(' '),
      publisher: strip(data.publisher?.username || ''),
      date: data.date ? data.date.toISOString().slice(0, 10) : 'prehistoric',
      description: strip(data.description ?? ''),
      keywords: [],
      name: strip(data.name),
      version: data.version,
    }
    if (Array.isArray(data.keywords)) {
      pkg.keywords = data.keywords.map(strip)
    } else if (typeof data.keywords === 'string') {
      pkg.keywords = strip(data.keywords.replace(/[,\s]+/, ' ')).split(' ')
    }

    let output
    if (this.#parseable) {
      output = [pkg.name, pkg.description, pkg.author, pkg.date, pkg.version, pkg.keywords]
        .filter(Boolean)
        .map(col => ('' + col).replace(/\t/g, ' ')).join('\t')
      return super.write(output)
    }

    const keywords = pkg.keywords.map(k => {
      if (this.#args.includes(k)) {
        return this.#chalk.cyan(k)
      } else {
        return k
      }
    }).join(' ')

    const description = this.#highlight(pkg.description)
    let name
    if (this.#args.includes(pkg.name)) {
      name = this.#chalk.cyan(pkg.name)
    } else {
      name = this.#highlight(pkg.name)
      name = this.#chalk.blue(name)
    }

    if (description.length) {
      output = `${name}\n${description}\n`
    } else {
      output = `${name}\n`
    }
    if (pkg.publisher) {
      output += `Version ${this.#chalk.blue(pkg.version)} published ${this.#chalk.blue(pkg.date)} by ${this.#chalk.blue(pkg.publisher)}\n`
    } else {
      output += `Version ${this.#chalk.blue(pkg.version)} published ${this.#chalk.blue(pkg.date)} by ${this.#chalk.yellow('???')}\n`
    }
    output += `Maintainers: ${pkg.authors}\n`
    if (keywords) {
      output += `Keywords: ${keywords}\n`
    }
    output += `${this.#chalk.blue(`https://npm.im/${pkg.name}`)}\n`
    return super.write(output)
  }

  #highlight (input) {
    let output = input
    for (const arg of this.#args) {
      let i = output.toLowerCase().indexOf(arg)
      while (i > -1) {
        const highlit = this.#chalk.cyan(output.slice(i, i + arg.length))
        output = [
          output.slice(0, i),
          highlit,
          output.slice(i + arg.length),
        ].join('')
        i = output.toLowerCase().indexOf(arg, i + highlit.length)
      }
    }
    return output
  }
}

Current_dir [ NOT WRITEABLE ] Document_root [ NOT WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
14 May 2026 8.36 AM
root / root
0755
audit-error.js
1.053 KB
24 Apr 2026 3.56 PM
root / root
0644
auth.js
3.211 KB
24 Apr 2026 3.56 PM
root / root
0644
cmd-list.js
2.884 KB
24 Apr 2026 3.56 PM
root / root
0644
completion.fish
1.559 KB
24 Apr 2026 3.56 PM
root / root
0644
completion.sh
1.854 KB
24 Apr 2026 3.56 PM
root / root
0755
did-you-mean.js
1.116 KB
24 Apr 2026 3.56 PM
root / root
0644
display.js
16.367 KB
24 Apr 2026 3.56 PM
root / root
0644
error-message.js
15.405 KB
24 Apr 2026 3.56 PM
root / root
0644
explain-dep.js
3.563 KB
24 Apr 2026 3.56 PM
root / root
0644
explain-eresolve.js
2.521 KB
24 Apr 2026 3.56 PM
root / root
0644
format-bytes.js
0.609 KB
24 Apr 2026 3.56 PM
root / root
0644
format-search-stream.js
4.798 KB
24 Apr 2026 3.56 PM
root / root
0644
format.js
2.09 KB
24 Apr 2026 3.56 PM
root / root
0644
get-identity.js
0.778 KB
24 Apr 2026 3.56 PM
root / root
0644
get-workspaces.js
1.707 KB
24 Apr 2026 3.56 PM
root / root
0644
installed-deep.js
1.103 KB
24 Apr 2026 3.56 PM
root / root
0644
installed-shallow.js
0.569 KB
24 Apr 2026 3.56 PM
root / root
0644
is-windows.js
0.173 KB
24 Apr 2026 3.56 PM
root / root
0644
log-file.js
7.676 KB
24 Apr 2026 3.56 PM
root / root
0644
npm-usage.js
2.023 KB
24 Apr 2026 3.56 PM
root / root
0644
oidc.js
7.195 KB
24 Apr 2026 3.56 PM
root / root
0644
open-url.js
2.493 KB
24 Apr 2026 3.56 PM
root / root
0644
output-error.js
0.77 KB
24 Apr 2026 3.56 PM
root / root
0644
ping.js
0.259 KB
24 Apr 2026 3.56 PM
root / root
0644
queryable.js
9.386 KB
24 Apr 2026 3.56 PM
root / root
0644
read-user-info.js
2.046 KB
24 Apr 2026 3.56 PM
root / root
0644
reify-finish.js
0.735 KB
24 Apr 2026 3.56 PM
root / root
0644
reify-output.js
6.323 KB
24 Apr 2026 3.56 PM
root / root
0644
sbom-cyclonedx.js
5.523 KB
24 Apr 2026 3.56 PM
root / root
0644
sbom-spdx.js
5.164 KB
24 Apr 2026 3.56 PM
root / root
0644
tar.js
3.429 KB
24 Apr 2026 3.56 PM
root / root
0644
timers.js
2.07 KB
24 Apr 2026 3.56 PM
root / root
0644
update-workspaces.js
0.974 KB
24 Apr 2026 3.56 PM
root / root
0644
validate-lockfile.js
0.999 KB
24 Apr 2026 3.56 PM
root / root
0644
verify-signatures.js
12.206 KB
24 Apr 2026 3.56 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF