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/fs

v2.0.0

Published

File system utilities for reading, updating, and managing files and directories.

Readme

@bemoje/fs

File system utilities for reading, updating, and managing files and directories.

TypeScript Module

Exports

  • deleteOlderThan: Delete files older than a given timestamp
  • getFileAge: Retrieves the age of a file in milliseconds.
  • getFirstFileInDir found in a directory.
  • readFileFirstLine: Reads the first line of a file asynchronously.
  • removeDataUrlSchemePrefix: Removes the data URL scheme prefix from a given string.
  • updateFile: Updates a file by reading its content, applying a transformation function, and writing back the result. Creates the file and directories if they don't exist.
  • updateFileLines or an array of lines. Creates the file and directories if they don't exist.
  • updateFileLinesSync: Synchronous version of updateFileLines.
  • updateFileSync: Synchronous version of updateFile.
  • updateJsonFile: Updates a JSON file by applying a transformation function to the parsed content. If the file doesn't exist or can't be parsed, uses the default value. Creates the file and directories if they don't exist.
  • updateJsonFileSync: Synchronous version of updateJsonFile.
  • walkDirectory: Walk a directory recursively and return an array of paths.

Installation

npm install @bemoje/fs

Usage

Walk a Directory

Recursively traverse a directory tree:

import { walkDirectory } from '@bemoje/fs'

// Get all file paths
const files = walkDirectory('./src', { only: 'files' })

// Get paths with stats
const entries = walkDirectory('./src', { stats: true })
entries.forEach(([path, stats]) => {
  console.log(path, stats.size)
})

// Filter directories and limit depth
const shallow = walkDirectory('./src', { maxDepth: 2, filter: (dirpath, basename) => basename !== 'node_modules' })

Update Files

Read, transform, and write files in one operation:

import { updateFile, updateFileSync } from '@bemoje/fs'

// Async
await updateFile('config.json', (content) => {
  return content.replace(/localhost/g, 'production.host')
})

// Sync
updateFileSync('config.json', (content) => {
  return content.replace(/localhost/g, 'production.host')
})

Update File Lines

Transform files line-by-line:

import { updateFileLines, updateFileLinesSync } from '@bemoje/fs'

await updateFileLines('data.csv', (lines) => {
  return lines.filter((line) => line.trim() !== '')
})

updateFileLinesSync('data.csv', (lines) => {
  return lines.map((line) => line.toUpperCase())
})

Update JSON Files

Read, transform, and write JSON files:

import { updateJsonFile, updateJsonFileSync } from '@bemoje/fs'

await updateJsonFile('package.json', (pkg) => {
  pkg.version = '2.0.0'
  return pkg
})

updateJsonFileSync('tsconfig.json', (config) => {
  config.compilerOptions.strict = true
  return config
})

File Utilities

import { getFileAge, deleteOlderThan, readFileFirstLine, getFirstFileInDir } from '@bemoje/fs'

// Get file age in milliseconds
const age = await getFileAge('./data.json')

// Delete files older than 24 hours
await deleteOlderThan('./cache', 24 * 60 * 60 * 1000)

// Read only the first line of a file
const header = await readFileFirstLine('./data.csv')

// Get the first file in a directory
const firstFile = await getFirstFileInDir('./uploads')

Data URL

import { removeDataUrlSchemePrefix } from '@bemoje/fs'

removeDataUrlSchemePrefix('data:image/png;base64,iVBOR...')
// 'iVBOR...'