empathic
A set of small and fast Node.js utilities to understand your pathing needs.
Last updated 2 months ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install empathic 
SYNC missed versions from official npm registry.

empathic CI licenses

A set of small and fast Node.js utilities to understand your pathing needs.

Multiple submodules (eg, empathic/find) are offered, each of which are:

  • fast — 8x to 40x faster than popular alternatives
  • modern — based on newer node:* native APIs
  • small — ranging from 200b to 500b in size
  • safe — zero-dependency & easy to read

Install

$ npm install empathic

Usage

import { resolve } from 'node:path';
import * as find from 'empathic/find';
import * as pkg from 'empathic/package';

// Assumed example structure:
let cwd = resolve('path/to/acme/websites/dashboard');

// Find closest "foobar.config.js" file
let file = find.up('foobar.config.js', { cwd });
//=> "/.../path/to/acme/foobar.config.js"

// Find closest "package.json" file
let pkgfile = pkg.up({ cwd });
//=> "/.../path/to/acme/package.json"

// Construct (optionally create) "foobar" cache dir
let cache = pkg.cache('foobar', { cwd, create: true });
//=> "/.../path/to/acme/node_modules/.cache/foobar"

API

empathic/access

Source · Size: 259b

Check for file access/permissions. Named fs.accessSync shortcuts.

empathic/find

Source · Benchmark · Size: 569b

Find files and/or directories by walking up parent directories.

empathic/package

Source · Benchmark · Size: 505b

Convenience helpers for dealing with package.json files and/or node_modules packages.

empathic/resolve

Source · Benchmark · Size: 419b

Resolve absolute paths to package identifiers, relative paths, file URL, and/or from other root directories.

empathic/walk

Source · Benchmark · Size: 208b

Collect all the parent directories of a target. Controlled via cwd and last options.

License

MIT © Luke Edwards

Current Tags

  • 2.1.0                                ...           latest (2 months ago)
  • 2.0.0-next.0                                ...           next (a year ago)

10 Versions

  • 2.1.0                                ...           2 months ago
  • 2.0.1                                ...           7 months ago
  • 2.0.0                                ...           a year ago
  • 2.0.0-next.0                                ...           a year ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
  • 0.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Total 25
Today 0
This Week 0
This Month 14
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
None
Dev Dependencies (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE