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

@leelaing/file-library

v0.2.0

Published

Reusable Node.js file scanning, filtering, metadata, duplicate detection, sorting, and scan-cache utilities.

Readme

@leelaing/file-library

Reusable Node.js file scanning, filtering, metadata, duplicate detection, deterministic sorting, content hashing, and versioned scan-cache utilities.

Install

npm install @leelaing/file-library

Node.js 20 or newer is required. The package has no runtime dependencies and exposes identical ESM and CommonJS APIs.

Scan files

import { scanFiles } from '@leelaing/file-library';

const library = await scanFiles('/home/lee/Music', {
  extensions: ['mp3', 'wav', 'flac'],
  excludedDirectoryNames: ['node_modules', '.git'],
  onProgress(progress) {
    console.log(progress.filesMatched);
  },
});

console.log(library.files, library.errors);

Scans are recursive by default, do not follow directory symlinks by default, and continue past unreadable entries while returning structured errors. Pass recursive: false, an AbortSignal, include/exclude globs, or an excludePath predicate when needed. Metadata scans do not read file contents.

Filter and sort metadata

import { filterFiles, sortFiles } from '@leelaing/file-library';

const recentLargeFiles = filterFiles(library.files, {
  extensions: ['mp3'],
  minSize: 1_000_000,
  modifiedAfter: new Date('2026-01-01'),
});

const newestFirst = sortFiles(recentLargeFiles, {
  by: 'modified',
  direction: 'desc',
});

Every sort uses stable path tie breakers so results are deterministic.

Find numbered duplicates

import { findDuplicateGroups } from '@leelaing/file-library';

const groups = findDuplicateGroups(library.files);
for (const group of groups) {
  console.log(group.kept, group.duplicates, group.reason);
}

The default strategy treats Song_1.mp3 and Song_2.mp3 as duplicates only when Song.mp3 exists in the same parent directory. Identical names in different directories are never combined. Use mode: 'exact-name' or provide key(file) for a custom strategy.

Optional content hashing

import { hashFileContent } from '@leelaing/file-library';

const digest = await hashFileContent('/path/to/file.flac');

Hashing is explicit and streaming. Normal scans never hash or read file contents.

Versioned scan cache

import { scanFilesCached } from '@leelaing/file-library';

const library = await scanFilesCached('/home/lee/Music', {
  cacheFile: '/home/lee/.local/share/my-app/library-cache.json',
  extensions: ['mp3'],
  maxAgeMs: 60 * 60 * 1000,
});

The caller owns the cache location. Cache identity includes the normalized root and scan options. Saves use a temporary sibling plus atomic rename; missing, corrupt, incompatible, or mismatched caches are clean cache misses.

Development

npm install
npm start
npm run check

License

MIT