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

dzen2

v3.0.0

Published

Use dzen2 from Node.js.

Downloads

12

Readme

dzen2

Use dzen2 as a Node.js stream.

Install

npm install --save dzen2

Usage

const dzen2 = require('dzen2')

const dz = dzen2({
  foreground: 'red',
  background: 'white'
})

dz.write('Hello world!')
setTimeout(() => {
  dz.write('Yes this is dog')
}, 3000)

API

stream = require('dzen2')(options)

Spawn a dzen process. stream is a stream, write strings to it to display them.

Options:

  • spawn: (Bool=true) Whether to spawn a dzen process. Set to false if you want to pipe the dzen formatted stream to a separate dzen instance. If true, all options are also passed through to spawn.
  • events: (String) List of events and actions. See Events and actions.
  • eventServer: (Bool=false) Enable events server. Note: this options has been renamed from events.

If spawn is true, the stream has a process property with the spawned process.

pr = require('dzen2/spawn')(options)

Spawn a dzen process. Returns a plain ChildProcess. You can pipe a stream to its stdin.

Options:

  • path - Path to the dzen2 binary to use. Defaults to dzen2-bin.
  • foreground - Foreground and text color. Use a symbolic name or a six-character #rrggbb hex code.
  • background - Background color.
  • font - Font.
  • align - Content alignment in the title window. left, center or right.
  • titleWidth - Width of the title window.
  • secondaryAlign - Content alignment in the secondary window. left, center or right.
  • secondaryLines - Amount of lines to show in the secondary window.
  • menu - Menu mode.
  • persist - Keep running for this amount of seconds after the input stream closes.
  • x - X position.
  • y - Y position.
  • lineHeight - Height in pixels of each line. Defaults to the font height + 2px.
  • width - Width.
  • screen - Xinerama screen number.
  • dock - Set to true to dock the window, eg for use as a taskbar or statusbar. Otherwise it'll show on top of other windows.

Stream methods

stream.setTitle(str)

Set the contents of the title window. Equivalent to stream.write('^tw()' + str).

stream.toggleCollapse()

Toggle collapsed state of the secondary window.

stream.collapse()

Collapse the secondary window.

stream.uncollapse()

"Uncollapse" (expand) the secondary window.

stream.toggleHide()

Hide or show the title window.

stream.hide()

Hide the title window. If the secondary window is uncollapsed, the secondary window will still be shown.

stream.unhide()

"Unhide" (show) the title window.

stream.raise()

Raise the window in front of all other windows.

stream.lower()

Lower the window behind all other windows.

stream.scrollHome()

Scroll the secondary window to the top.

stream.scrollEnd()

Scroll the secondary window to the bottom.

stream.exit()

Tell dzen to quit.

Events and actions

This allows you to associate actions to events. Events and actions are separated by = and each pair is separaded by a ;. If an event triggers more than one action, the actions are separated by ,.

For example: entertitle=uncollapse,unhide;button1=exec:xterm:firefox; will uncollapse and unhide the window when the mouse enters the title and will execute xterm and firefox when the mouse button 1 is clicked.

For more information, see the "(2) Option '-e': Events and actions" section of the dzen2 README.

Clickable areas

The ^ca() modifier allows for running commands when the enclosed text is clicked. ^ca(BTN, CMD) marks the beggining of a clickable area which will call CMD when BTN is clicked in it. ^ca() marks the end of the clickable area.

var dzen2 = require('dzen2')
var stream = dzen2()
stream.write('^ca(1, firefox --new-tab npmjs.com/package/dzen2)click me^ca()')

For more information about clickable areas, see the "Interaction" section of the dzen2 README.

Event-server

When eventServer is set to true, the emit() function will be available inside ^ca().

var dzen2 = require('dzen2')
var stream = dzen2({
  eventServer: true
})

stream.write('^ca(1, emit(hello))click me^ca()')
stream.on('hello', function () {
  console.log('hello from dzen!')
})

This internally this starts a tiny TCP server. The emit(event) parts are rewritten to execute a node script that sends the event to the server.

"^ca(1, emit(test-event))Test event^ca()"
// is equivelent to
"^ca(1, /usr/bin/node '/home/username/Projects/dzen2/send-command.js' 41481 'test-event')Test event^ca()"

License

MIT