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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bemoje/node

v2.0.0

Published

Node.js utilities for process execution, logging, timing, streams, and system monitoring.

Readme

@bemoje/node

Node.js utilities for process execution, logging, timing, streams, and system monitoring.

TypeScript Module

Exports

  • StringStream: Extension of Node's native Readable class for converting a string into a Readable stream.
  • argvHasHelpFlag.
  • createLogger: Creates a logger instance with colored output and consistent formatting.
  • execOutput: Helper function to execute a shell command and return stdout and stderr without throwing on error. If there was an error and nothing was sent to stderr, the error.message takes its place.
  • execute: Execute one or multiple shell commands.
  • formatTableForTerminal: Formats a 2D array of strings as a terminal table with optional headers and styling.
  • getCurrentMemoryUsage: Get the current heap memory usage in megabytes.
  • isTerminalColorSupported supported.
  • memoryUsage: Returns the memory usage of the Node.js process with values converted from bytes to megabytes and rounded to the specified precision.
  • prompt: Prompt the user for input.
  • shellSpawnProgram: Spawns a program using child_process.spawn with promise-based interface and optional stdio inheritance control.
  • spawnChildProcess: Spawn a child process.
  • spawnNodeProcess: Spawn a child node process.
  • startPowerShellScript: Executes a PowerShell script with arguments and returns stdout/stderr.
  • streamToString: Drain a Readable into a string.
  • timer: Executes a task and logs the execution time.
  • toError: Converts the given value to an Error object. If the value is already an Error object, it is returned as is. If the value is not an Error object, it is converted to a string and used as the error message.

Installation

npm install @bemoje/node

Usage

Execute Shell Commands

import { execute } from '@bemoje/node'

// Execute a single command with colored echo
execute('git status')

// Execute silently and capture output
const output = execute('git branch', { silent: true })

// Execute multiple commands
execute(['npm run build', 'npm test'])

// Execute in a specific directory
execute('ls -la', { cwd: '/some/path' })

Create Logger

Colored, prefixed terminal logging:

import { createLogger } from '@bemoje/node'

const log = createLogger('MyApp')

log.start('Initializing...') // [MyApp] [START] Initializing...
log.info('Processing data') // [MyApp] [INFO]  Processing data
log.done('Complete!') // [MyApp] [DONE]  Complete!
log.warn('Disk space low') // [MyApp] [WARN]  Disk space low
log.error(new Error('fail')) // [MyApp] [ERROR] Error: fail
log.debug('Debug info') // [MyApp] [DEBUG] Debug info

Timer

Measure and log task execution time:

import { timer } from '@bemoje/node'

// Sync
timer('build', (log) => {
  // ... do work
  log.info('Step 1 done')
})
// [build] [START]
// [build] [INFO]  Step 1 done
// [build] [DONE]  1.23 seconds

// Async
await timer('deploy', async (log) => {
  await deployToServer()
})

Streams

import { streamToString, StringStream } from '@bemoje/node'

// Convert a Readable stream to string
const content = await streamToString(fs.createReadStream('file.txt'))

// Create a Readable from a string
const stream = new StringStream('hello world')

Prompt User Input

import { prompt } from '@bemoje/node'

const name = await prompt('What is your name? ')

// With validation callback
const age = await prompt('Age: ', (input) => {
  const n = parseInt(input)
  return isNaN(n) ? '' : input // return empty to re-prompt
})

Memory Usage

import { memoryUsage, getCurrentMemoryUsage } from '@bemoje/node'

const mem = memoryUsage(2) // rounded to 2 decimals
console.log(mem.heapUsed) // e.g. 45.23 (MB)

const heapMB = getCurrentMemoryUsage() // current heap in MB

Spawn Processes

import { spawnChildProcess, spawnNodeProcess } from '@bemoje/node'

await spawnChildProcess('/usr/bin/python3', ['script.py'])
await spawnNodeProcess(['--version'])