npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@winches/dynamic-log

v0.0.1

Published

dynamic log for your nodejs project enhance your log with color and emoji/ascii art

Downloads

2

Readme

🚀 Getting Started

npm i -g @winches/dynamic-log

📖 Usage

Say

say(['wo zhe shi ce shi ni kan kan', 'test da jia hao'], { title: chalk.magentaBright('𝓝𝒆𝔁𝓽𝓤𝓘:') })

SayBox

sayBox(['wo zhe shi ce shi ni kan kan', 'test da jia hao'], { boxOptions: { center: true, color: 'yellow', titleColor: 'cyan' } })

FunnySay

This could use many funny option to show a funny output in the terminal

funnySay(['wo zhe shi ce shi ni kan kan ', 'test da jia hao'], { character: 'cow', bodyFunny: true })

With custom emoji

const defaultSayingEyes = chalk.white('ಠ')
const defaultStartEyes = chalk.white('◕')
const defaultEndEyes = chalk.white('◕')

say(['wo zhe shi ce shi ni kan kan', 'test da jia hao'], {
  title: chalk.magentaBright('𝓝𝒆𝔁𝓽𝓤𝓘:'),
  // Fully custom emoji
  emoji: [
    // Start emoji
    { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('◡'), eyes: [defaultStartEyes, defaultStartEyes] },
    // Saying emoji
    [
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('•'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('○'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('■'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('▪'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('▫'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('▬'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('▭'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('-'), eyes: [defaultSayingEyes, defaultSayingEyes] },
      { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('○'), eyes: [defaultSayingEyes, defaultSayingEyes] },
    ],
    // End emoji
    { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: chalk.cyan('◡'), eyes: [defaultEndEyes, defaultEndEyes] },
  ]
  // Simple emoji
  // emoji: ['٩(◕‿◕。)۶', '٩(ಠ_ಠ)۶', '٩(◉‿◉。)۶']
})

With custom render content

say(['wo zhe shi ce shi ni kan kan', 'test da jia hao'], {
  title: chalk.magentaBright('𝓝𝒆𝔁𝓽𝓤𝓘:'),
  renderContent: (msg, emoji) => {
    // You can get the current saying emoji and the message, and you can return what you want render
    return `${emoji} ${msg}` // output like: ٩(◕‿◕。)۶ wo zhe shi ce shi ni kan kan
  }
})

📚 Api

type OmitTips<T, K extends keyof T> = {
  [P in Exclude<keyof T, K>]: T[P];
}
type ChalkColor = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | 'grey' | 'blackBright' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright' | 'bgBlack' | 'bgRed' | 'bgGreen' | 'bgYellow' | 'bgBlue' | 'bgMagenta' | 'bgCyan' | 'bgWhite' | 'bgGray' | 'bgGrey' | 'bgBlackBright' | 'bgRedBright' | 'bgGreenBright' | 'bgYellowBright' | 'bgBlueBright' | 'bgMagentaBright' | 'bgCyanBright' | 'bgWhiteBright'

declare const colorMatchRegex: RegExp
declare function strip(str: string): string

declare const boxRound: {
  bold: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
  classic: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
  double: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
  doubleSingle: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
  round: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
  single: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
  singleDouble: {
    bottomLeft: string
    bottomRight: string
    horizontal: string
    topLeft: string
    topRight: string
    vertical: string
  }
}

interface BoxOptions {
  text: string
  center?: boolean
  log?: boolean
  color?: ChalkColor
  title?: string
  borderStyle?: keyof typeof boxRound
  padding?: number
  width?: number
  align?: 'left' | 'center' | 'right'
  titleColor?: ChalkColor
}
/**
 * Output a box with the content
 */
declare function outputBox({ borderStyle, center, color, log, padding, text, title, width, align, titleColor, }: BoxOptions): string

type Character = 'cat' | 'cow' | 'cheese'
declare function generateCharacter({ mouth, eyes, character, content, color: _color, funny, bodyFunny, }: {
  mouth?: string
  eyes?: [string, string]
  character: Character
  content: string
  color?: ChalkColor
  funny?: boolean
  bodyFunny?: boolean
}): string
declare function generateBox(content: string, color?: ChalkColor): string

type Message = string | Promise<string>
type Msg = Message[] | Message | Message[][]
type EmojiItem = string | {
  content: string
  mouth: string
  eyes: [string, string]
}
interface SayOptions {
  clear?: boolean
  stdout?: NodeJS.WriteStream
  /**
   * Ascii text to use for the face
   * @example ['٩(◕‿◕。)۶', '٩($eyes1_$mouth。$eyes2۶', '٩(◉‿◉。)۶']
   * @example Custom face
   * ['٩(◕‿◕。)۶', { content: '٩($eyes1 $mouth $eyes2。)۶', mouth: 'ಠ', eyes: ['ಠ', 'ಠ'] }, '٩(◉‿◉。)۶']
   */
  emoji?: [EmojiItem, EmojiItem | EmojiItem[], EmojiItem]
  title?: string
  renderContent?: (msg: string, emoji: EmojiItem) => string
}
/**
 * Say something with a face
 */
declare function say(msg?: Msg, { clear, stdout, title, emoji, renderContent: _renderContent, }?: SayOptions): Promise<void>
interface SayBoxOptions extends SayOptions {
  boxOptions: Omit<BoxOptions, 'text'>
}
declare function sayBox(msg: Msg, options?: SayBoxOptions): Promise<void>
interface FunnySayOptions extends Partial<OmitTips<SayOptions, 'title'>> {
  character?: Character
  color?: ChalkColor
  funny?: boolean
  bodyFunny?: boolean
}
declare function funnySay(msg: Msg, options?: FunnySayOptions): Promise<void>

declare function transformEmoji(emoji: EmojiItem): string
declare const sleep: (ms: number) => Promise<unknown>
declare const randomBetween: (min: number, max: number) => number
declare function getText(text: Message[] | Message[][]): Promise<(string | string[])[]>
declare function getTextMaxLength(text: string[] | string[][]): number

declare const chalkColorList: ChalkColor[]

export { type BoxOptions, type ChalkColor, type Character, type EmojiItem, type FunnySayOptions, type Message, type Msg, type OmitTips, type SayBoxOptions, type SayOptions, boxRound, chalkColorList, colorMatchRegex, funnySay, generateBox, generateCharacter, getText, getTextMaxLength, outputBox, randomBetween, say, sayBox, sleep, strip, transformEmoji }