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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rechunk/utils

v0.3.0

Published

Utility functions and helpers for ReChunk packages and implementations

Readme

@rechunk/utils

Utility functions and helpers for ReChunk packages and implementations.

Features

  • 🔍 File system utilities
  • 🔄 Process management
  • 🛠️ Path resolution
  • 🚀 Development server detection
  • 📦 Workspace utilities
  • ⚡️ Performance optimizations

Installation

npm install @rechunk/utils

# or with yarn
yarn add @rechunk/utils

# or with pnpm
pnpm add @rechunk/utils

API Reference

File System Utilities

getRealPath

Resolves the real native path for a given file path, handling case sensitivity issues.

import {getRealPath} from '@rechunk/utils';

const realPath = getRealPath('/path/to/file');

findClosestJSON

Recursively searches for the closest JSON file from a starting directory.

import {findClosestJSON} from '@rechunk/utils';

const config = findClosestJSON('.rechunkrc.json');
const pkg = findClosestJSON('package.json');

Workspace Utilities

findWorkspaceDir

Locates the workspace directory by finding package manager files.

import {findWorkspaceDir} from '@rechunk/utils';

const workspaceDir = findWorkspaceDir(process.cwd());

Process Management

ProcessInfo Interface

interface ProcessInfo {
  pid: number; // Process ID
  ppid: number; // Parent Process ID
  uid: number; // User ID
  cpu: number; // CPU usage percentage
  memory: number; // Memory usage percentage
  name: string; // Process name
  cmd: string; // Full command line
}

nonWindowsCall

Retrieves information about running processes on non-Windows systems.

import {nonWindowsCall} from '@rechunk/utils';

const processes = nonWindowsCall({all: true});

Development Server

isRechunkDevServerRunning

Checks if the ReChunk development server is currently running.

import {isRechunkDevServerRunning} from '@rechunk/utils';

if (isRechunkDevServerRunning()) {
  console.log('Dev server is running');
}

Use Cases

Configuration File Management

import {findClosestJSON, getRealPath} from '@rechunk/utils';

// Find and load configuration
const configPath = getRealPath('./config');
const config = findClosestJSON('.rechunkrc.json', configPath);

Workspace Detection

import {findWorkspaceDir} from '@rechunk/utils';

// Set up workspace environment
const workspaceDir = findWorkspaceDir(process.cwd());
process.env.WORKSPACE_DIR = workspaceDir;

Process Monitoring

import {nonWindowsCall, ProcessInfo} from '@rechunk/utils';

// Monitor specific processes
const processes: ProcessInfo[] = nonWindowsCall();
const nodeProcesses = processes.filter(p => p.name.includes('node'));

Development Environment

import {isRechunkDevServerRunning} from '@rechunk/utils';

// Configure based on dev server status
const isDev = isRechunkDevServerRunning();
const config = {
  mode: isDev ? 'development' : 'production',
  // ... other config
};

Best Practices

  1. Path Resolution

    // Recommended
    const path = getRealPath(filePath);
    
    // Avoid
    const path = filePath; // Might have case sensitivity issues
  2. Configuration Loading

    // Recommended
    const config = findClosestJSON('.rechunkrc.json');
    
    // Avoid
    const config = require('.rechunkrc.json'); // Might fail if not in exact location
  3. Process Management

    // Recommended
    const processes = nonWindowsCall({all: true});
    
    // Avoid
    const {execSync} = require('child_process');
    const output = execSync('ps aux'); // Less reliable and platform-dependent

Error Handling

The utilities include built-in error handling and fallbacks:

// File not found fallback
const config = findClosestJSON('missing.json'); // Returns {}

// Path resolution fallback
const path = getRealPath('invalid/path'); // Returns original path

// Process information error handling
try {
  const processes = nonWindowsCall();
} catch (error) {
  console.error('Failed to get process information:', error);
}

Contributing

Contributions are welcome! Please read our contributing guidelines first.

License

MIT