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

@zokugun/fs-path

v0.2.0

Published

Path utilities complementing the builtin path module

Readme

@zokugun/fs-path

MIT licensed NPM Version Donation Donation Donation

Compact set of path utilities that complement Node's builtin path module.

Features

  • Tilde expansion: expand ~ to the current user's home directory with untildify.
  • Safe joining and resolving: helpers that avoid common pitfalls when composing paths.
  • Useful utilities: retrieve parent paths, absolute normalization, and platform-aware helpers.
  • Small package with ESM and CJS builds

Installation

npm add @zokugun/fs-path

Quick Start

import { isInDir, join, resolve } from '@zokugun/fs-path'

const configDir = resolve('~/.config/myapp')
const dataFile = join(configDir, 'data.json')

console.log('Config dir:', configDir)
console.log('Data file:', dataFile)

console.log('Is data file inside config dir?', isInDir(dataFile, configDir))

This example expands the current user's home directory, joins paths safely, and prints the resolved absolute path for configDir.

API reference

  • absolute(...paths: string[]): string: Returns a normalized absolute path.
  • isAbsolute(path: string): boolean: Return true when path is absolute for the current platform.
  • isInDir(path: string, parent: string): boolean: Return true when path is equal to or contained within parent.
  • isInDirs(path: string, parents: string[]): boolean: Return true when path is equal to or contained within in one of the parents.
  • isSafePath(path: string, options?): boolean: Return true when path is considered safe for use (guards against suspicious segments such as .. when appropriate for the platform).
  • isSafeSegment(segment: string, target?: Target | 'auto'): boolean: Return true when a single path segment is safe (doesn't contain path separators or traversal sequences).
  • join(...paths: string[]): string: Join path segments.
  • leafExt(path: string, length?: number): string: Return the extensions.
  • leafName(path: string, extension?: number | string): string: Return the basename of path with/without the extensions.
  • matchesGlob?(path: string, pattern: string): boolean: Optional platform-provided glob matcher when available.
  • normalize(path: string): string: Normalize the path (same as path.normalize).
  • parentName(path: string): string: Return the parent name of path.
  • parentPath(path: string): string: Return the parent directory of path.
  • relative(from: string, to: string): string: Compute the relative path from from to to.
  • resolve(...paths: string[]): string: Resolve path segments to an absolute path. Supports tilde expansion:
    • ~ expands to the current user's home directory.
    • ~username/... attempts to expand to that user's home directory when available.
  • sanitize(path: string, options?): Result<string>: Return a sanitized form of path with unsafe segments normalized.
  • untildify(path: string): string: Expand a leading ~ or ~username to the home directory, or return path unchanged.
  • delimiter: Platform-specific character (;/:).
  • separator: Platform-specific character (\//).
export type PlatformPath = {
    readonly delimiter: ';' | ':';
    readonly separator: '\\' | '/';
    readonly posix: PlatformPath;
    readonly win32: PlatformPath;
    absolute: (...paths: string[]) => string;
    isAbsolute: (path: string) => boolean;
    isInDir(path: string, parent: string): boolean;
    isInDirs(path: string, parents: string[]): boolean;
    isSafePath: (path: string, options?: {
		parent?: string | null;
		parents?: string | string[] | null;
		target?: Target | 'auto';
	}) => boolean;
    isSafeSegment: (segment: string, target?: Target | 'auto') => boolean;
    join: (...paths: string[]) => string;
	leafExt: (path: string, length?: number) => string;
    leafName: (path: string, extension?: number | string) => string;
    matchesGlob?: (path: string, pattern: string) => boolean;
    normalize: (path: string) => string;
    parentName: (path: string) => string;
	parentPath: (path: string) => string;
    relative: (from: string, to: string) => string;
    resolve: (...paths: string[]) => string;
    sanitize(path: string, options?: {
        parent?: string | null;
        parents?: string | string[] | null;
        replacement?: string | null;
        target?: Target | 'auto'
    }) => Result<string>
    untildify: (path: string) => string;
};

Comparison with Node's path

This library intentionally mirrors many of Node's path APIs but provides small ergonomic differences and extra features where useful:

  • join(...paths): wraps path.join. Returns '' instead of . when the joined result is the current directory.
  • isAbsolute(path), normalize(path), relative(from, to): direct mappings to path.isAbsolute, path.normalize, and path.relative respectively.
  • parentPath(file): wraps path.dirname. Returns '' instead of . for consistency with join.
  • resolve(...paths): wraps path.resolve but adds tilde expansion (~ and ~username) before resolving.
  • delimiter: same value as path.delimiter on the current platform.
  • separator: same value as path.sep on the current platform.

Contributions

Contributions are most welcome. Please:

  • Open issues and feature requests under the repository discussions.
  • Follow the CONTRIBUTING.md.

Donations

Support this project by becoming a financial contributor.

License

Copyright © 2026-present Baptiste Augrain

Licensed under the MIT license.