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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@arcmantle/posix-path-browser

v1.0.3

Published

Browser friendly version of nodejs path posix implementation.

Downloads

15

Readme

@arcmantle/posix-path-browser

npm version

A browser-friendly implementation of Node.js's POSIX path utilities. This package provides the same API and methods as the standard Node.js path.posix module, but optimized for browser environments without any Node.js dependencies.

Features

  • 🌐 Browser Compatible: No Node.js dependencies, works in all modern browsers
  • 📦 Zero Dependencies: Lightweight implementation with no external dependencies
  • 🔄 Drop-in Replacement: Same API as Node.js path.posix module
  • 🎯 TypeScript Support: Full TypeScript definitions included
  • Lightweight: Minimal bundle size impact
  • 🧪 Well Tested: Based on Node.js's battle-tested path implementation

Installation

deno

deno add @arcmantle/posix-path-browser

pnpm 10.9+

pnpm add @arcmantle/posix-path-browser

yarn 4.9+

yarn add @arcmantle/posix-path-browser

Usage

import {
  join,
  resolve,
  normalize,
  dirname,
  basename,
  extname,
  relative,
  isAbsolute,
  parse,
  format,
  sep,
  delimiter
} from '@arcmantle/posix-path-browser';

// Join paths
const fullPath = join('home', 'user', 'documents', 'file.txt');
// → 'home/user/documents/file.txt'

// Resolve to absolute path
const absolutePath = resolve('/home/user', '../admin', 'config.json');
// → '/home/admin/config.json'

// Normalize path
const normalized = normalize('/home/user/../user/./documents//file.txt');
// → '/home/user/documents/file.txt'

// Get directory name
const dir = dirname('/home/user/documents/file.txt');
// → '/home/user/documents'

// Get file name
const filename = basename('/home/user/documents/file.txt');
// → 'file.txt'

// Get file extension
const ext = extname('/home/user/documents/file.txt');
// → '.txt'

// Get relative path
const rel = relative('/home/user', '/home/user/documents/file.txt');
// → 'documents/file.txt'

// Check if path is absolute
const isAbs = isAbsolute('/home/user');
// → true

// Parse path into components
const parsed = parse('/home/user/documents/file.txt');
// → {
//     root: '/',
//     dir: '/home/user/documents',
//     base: 'file.txt',
//     ext: '.txt',
//     name: 'file'
//   }

// Format path from components
const formatted = format({
  dir: '/home/user/documents',
  name: 'file',
  ext: '.txt'
});
// → '/home/user/documents/file.txt'

API Reference

Methods

resolve(...paths: string[]): string

Resolves a sequence of paths or path segments into an absolute path.

normalize(path: string): string

Normalizes a path, resolving '..' and '.' segments.

isAbsolute(path: string): boolean

Determines whether the path is an absolute path.

join(...paths: string[]): string

Joins all given path segments together using the platform separator as a delimiter, then normalizes the resulting path.

relative(from: string, to: string): string

Returns the relative path from from to to.

dirname(path: string): string

Returns the directory name of a path.

basename(path: string, suffix?: string): string

Returns the last portion of a path, optionally removing a given suffix.

extname(path: string): string

Returns the extension of the path, from the last '.' to end of string.

parse(path: string): ParsedPath

Returns an object with properties representing significant elements of the path.

format(pathObject: FormatInputPathObject): string

Returns a path string from an object - the opposite of parse().

Constants

sep: string

The platform-specific file separator: '/'

delimiter: string

The platform-specific path delimiter: ':'

Types

interface ParsedPath {
  root: string;
  dir: string;
  base: string;
  ext: string;
  name: string;
}

interface FormatInputPathObject {
  dir?: string;
  root?: string;
  base?: string;
  name?: string;
  ext?: string;
}

Why Use This Package?

Browser Compatibility

The standard Node.js path module is not available in browsers. This package provides the same functionality without requiring Node.js polyfills or bundler configuration.

Consistent POSIX Behavior

Always uses POSIX path conventions (forward slashes) regardless of the platform, making it perfect for web applications that work with URLs or need consistent path handling.

Lightweight Alternative

Unlike full Node.js polyfills, this package only includes the path utilities you need, keeping your bundle size minimal.

Browser Support

This package works in all modern browsers that support ES2015+ features:

  • Chrome 51+
  • Firefox 54+
  • Safari 10+
  • Edge 15+

License

Apache-2.0

Original Node.js implementation: Copyright Joyent, Inc. and other Node contributors.

Contributing

Issues and pull requests are welcome! Please ensure any contributions maintain compatibility with the Node.js path.posix API.