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

@impactor/nodejs

v5.0.0

Published

nodejs utils

Readme

Nodejs utils

FS operations

Working with files, directories, and paths. all functions are available as promise or sync, for example:

  • read() -> the promise version
  • readSync() -> the sync version

The following are just a choosen examples, to see the full API check our docs.

Reading a JSON file

import { read } from "@impactor/nodejs-utils";

let file = await read("./package.json");

The content automatically pared as JSON.

Reading a cache file if only it is not expired

import { read } from "@impactor/nodejs-utils";

let cache = await read("./cache.json", { maxAge: 10000 });

Writing a JSON data

import { write } from "@impactor/nodejs-utils";

write("./data/reports/report.json", { status: "ok" });

The data will be stringified automatically. also, you don't need to manually create the directory, because it is created recursively. for instance if ./data or ./data/reports doesn't exist, it'll be created.

copy or move a file or folder, you can filter the files to be copied.

// copy static non-typescript files
copy("src", "dist/assets", (file) => !file.endsWith(".ts"));

// move flat-structure project to use "src"
move(".", "./src", (file) => file.endsWith(".ts"));

// remove log files
remove("./data", (file) => file.endsWith(".log"));

Parsing a path

let info = parsePath("./data/report.txt");

console.log(`type: ${info.type}`); // file or dir
console.log(`file extension: ${info.extension}`); // txt
console.log(`the containing dir: ${info.dir}`); // data
console.log(`file name: ${info.name}`); // report

Get the total size of a file or directory

getSize("./data");

Create the full path directory recursively

mkdir("./data/reports/summaries");

if one portion of the specified path doesn't exist, the full path will be created. for example, if ./data doesn't exist, it'll be created first, then reports then summaries. It also accepts files, the containing directory will be created.

get all or some files or directory.

// list first-level directories under "apps"
getEntries("apps", "dirs", 1);

// list all files under "reports" and its children
getEntries("reports", "files");

// list all JSON files under reports
getEntries("reports", "files", (entry) => entry.endsWith(".json"));

// list all summary log files under "reports"
// i.e. files that follow this pattern "summary-{number}.log"
getEntries("reports", "files", /summary-\d\.log/);

Apply an arbitrary action recursively

// remove all "*.log" files under "reports" and its subdirectories, recursively.
recursive(
  "reports", // the starting point
  (entry) => unlinkSync(entry), // the action to be applied
  (entry) => entry.endsWith(".log"), // the filter
);

Cache

Manage caches. built on top of @impactor/cache, using file-system caching.

let cache = await cacheFS(
  // cache entries
  ["./report-today.json", "./report-yesterday.json"],
  // data source
  () => fetch("https://my-server.com/getReport"),
  // cache options
  {
    maxAge: 1000,
    maxStale: 2000,
    // you don't need to define `read()` and `write()` here.
  },
);