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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@flex-development/pathe

v4.0.1

Published

Universal drop-in replacement for node:path

Downloads

622

Readme

pathe

github release npm codecov license conventional commits typescript vitest yarn

Universal drop-in replacement for node:path

Contents

What is this?

This package is a universal drop-in replacement for Node.js' path module.

It enforces consistency between POSIX and Windows operating systems and also provides additional utilities for working with file URLs, paths, and extensions.

When should I use this?

For historical reasons, Windows followed MS-DOS and used backslashes (\) to separate path components, as opposed to the forwardslashes (/) used by POSIX operating systems. Even though Windows operating systems now support both separators, there are still discrepancies between operating systems when using Node.js' path module:

The default operation of the node:path module varies based on the operating system on which a Node.js application is running. Specifically, when running on a Windows operating system, the node:path module will assume that Windows-style paths are being used. – Windows vs. POSIX

This package enforces consistency between operating systems by ensuring paths are POSIX-compliant. With support for both drive and UNC paths as well, platform-specific modules like node:path/posix and node:path/win32 are no longer needed.

~~To achieve consistent results when working with Windows file paths on any operating system, use path.win32.~~ ~~To achieve consistent results when working with POSIX file paths on any operating system, use path.posix.~~

To achieve consistent results when working with Windows file paths on any operating system, use pathe. To achieve consistent results when working with POSIX file paths on any operating system, use pathe. :blush:

Install

This package is ESM only.

In Node.js (version 18+) with yarn:

yarn add @flex-development/pathe

In Deno with esm.sh:

import { parse } from 'https://esm.sh/@flex-development/pathe'

In browsers with esm.sh:

<script type="module">
  import { parse } from 'https://esm.sh/@flex-development/pathe'
</script>

Use

import {
  addExt,
  basename,
  changeExt,
  cwd,
  delimiter,
  dirname,
  dot,
  extToValue,
  extname,
  fileURLToPath,
  format,
  formatExt,
  isAbsolute,
  isDeviceRoot,
  isSep,
  isURL,
  join,
  matchesGlob,
  normalize,
  parse,
  pathToFileURL,
  relative,
  removeExt,
  resolve,
  resolveWith,
  root,
  sep,
  toNamespacedPath,
  toPath,
  toPosix
} from '@flex-development/pathe'

API

This package exports the following identifiers:

The default export is pathe.

Documentation website coming soon.

Types

This package is fully typed with TypeScript.

Contribute

See CONTRIBUTING.md.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.