Code Monkey home page Code Monkey logo

pathe's Introduction

๐Ÿ›ฃ๏ธ pathe

Universal filesystem path utils

version downloads size

โ“ Why

For historical reasons, windows followed MS-DOS and using backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, Windows supports both Slash and Backslash for paths. Node.js's built in path module in the default operation of the 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 path module will assume that Windows-style paths are being used. This makes inconsistent code behavior between Windows and POSIX. Compared to popular upath, pathe is providing identical exports of Node.js with normalization on all operations and written in modern ESM/Typescript and has no dependency on Node.js!

This package is a drop-in replacement of the Node.js's path module module and ensures paths are normalized with slash / and work in environments including Node.js.

๐Ÿ’ฟ Usage

Install using npm or yarn:

# npm
npm i pathe

# yarn
yarn add pathe

# pnpm
pnpm i pathe

Import:

// ESM / Typescript
import { resolve } from 'pathe'

// CommonJS
const { resolve } = require('pathe')

Read more about path utils from Node.js documentation and rest assured behavior is ALWAYS like POSIX regardless of your input paths format and running platform!

Extra utilities

Pathe exports some extra utilities that do not exist in standard Node.js path module. In order to use them, you can import from pathe/utils subpath:

import { filename, normalizeAliases, resolveAlias } from 'pathe/utils'

License

MIT. Made with ๐Ÿ’–

Some code used from Node.js project. See LICENSE.

pathe's People

Contributors

renovate[bot] avatar pi0 avatar danielroe avatar antfu avatar eltociear avatar huang-julien avatar kraenhansen avatar andarist avatar missedwarrior avatar peterroe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.