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

packaged-path-parse

v8.11.1

Published

path.parse() from Node.js as a standalone package

Downloads

5

Readme

path.parse() from Node.js as a standalone package

npm Build Status

path.parse() from a current Node.js version (matching this package version), packaged into a stand-alone module, without deps (including Node.js core).

Consider using this package through compatible-path-parse wrapper to avoid unnecessary version updates and to ensure proper deduplication, see semver section for explanation.

usage

// Note: use compatible-path-parse wrapper instead in require
const pathParse = require('packaged-path-parse')
pathParse(path) // platform-dependant, default — posix
pathParse.posix(path) // posix
pathParse.win32(path) // win32

path.parse() from Node.js

Documented in Node.js Documentation.

Clean

No deps on any modules, including Node.js core modules.

ES3-compatible. Single file.

Can be run in browser environment natively.

Ponyfill

This module fits all definitions of being a ponyfill.

Fast

Uses the new code from Node.js that avoids using regexes — there is not a single regex present here.

That was done mainly for performance reasons in Node.js, and path parsing became faster.

Tested

Tested to have the exact same behavior as the corresponding Node.js version path.parse(). Tests are generated from Node.js code automatically, based on strings present in Node.js path tests, and validated on any version.

The test matrix on Travis starts with Node.js 0.8.6 — the lowest one that has pre-built Linux binaries that nvm can install.

Also tested for identical behavior on brute-forced strings on the exact same version that the code was taken from.

Up-to-date

Based on a recent Node.js verson.

How recent? That's easy to tell — it matches with this package version!

That also makes testing easier.

Also, the Node.js (and this package) version is mentioned on the very first line of the library js file (index.js).

Semver?

Up-to-date section outlined why it was chosen to keep the Node.js package version numbering for this package — to provide clear understanding of the Node.js version used as the source, and to give predictable behavior.

Because of that while packaged-path-parse conforms to semver requirements, it bumps versions more often than it should be done. But there is a fix for that!

The version of packaged-path-parse is mirrored from Node.js version, and not all semver-major changes in Node.js must be semver-major changes in path.parse, as well as not all semver-minor changes in Node.js are semver-minor changes in path.parse.

All semver-major changes in path.parse are semver-major in Node.js, and all semver-minor changes in path.parse are semver-minor in Node.js, so you will never miss those.

It is recommended to use compatible-path-parse instead, which is a wrapper around this module that takes care of not bumping major/minor versions when path.parse was not affected by those — that way you and your users will get important updates faster, and that will better de-duplicate the code in case of several packages using this one.

Is this compatible to path-parse npm package?

path-parse package looks unmaintained and uses the old Node.js code that did the parsing using regexes.

The tests from path-parse module pass on packaged-path-parse with the exception of the exact TypeError error message texts — those were changed in Node.js over time.

License

MIT. See LICENSE file.