Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
path-parse
Advanced tools
Node.js path.parse() ponyfill
Weekly downloads
Package description
The path-parse npm package is a utility for parsing a file path into its segments, offering a consistent and reliable way to dissect a path's components such as the root, directory, base, extension, and name. It is particularly useful in environments where path manipulation is necessary but challenging due to varying file system conventions.
Parsing file paths
This feature allows you to parse a full file path into an object containing properties such as root, dir, base, ext, and name. The code sample demonstrates parsing a Unix file path, which results in an object detailing each component of the path.
const pathParse = require('path-parse');
const parsedPath = pathParse('/home/user/dir/file.txt');
console.log(parsedPath);
The 'path' module is a core Node.js module that provides utilities for working with file and directory paths. It offers a wider range of functionalities compared to path-parse, including not only parsing but also joining, normalizing, and resolving paths. However, for projects that only require path parsing functionality, path-parse is a lightweight alternative.
node-path-extra extends the core 'path' module with additional functionalities, such as copying and removing directories, which go beyond what path-parse offers. While it includes path parsing capabilities, its focus is on providing a broader suite of path manipulation tools.
Readme
Node.js
path.parse(pathString)
ponyfill.
$ npm install --save path-parse
var pathParse = require('path-parse');
pathParse('/home/user/dir/file.txt');
//=> {
// root : "/",
// dir : "/home/user/dir",
// base : "file.txt",
// ext : ".txt",
// name : "file"
// }
See path.parse(pathString)
docs.
The Posix specific version.
The Windows specific version.
MIT © Javier Blanco
FAQs
Node.js path.parse() ponyfill
The npm package path-parse receives a total of 31,292,517 weekly downloads. As such, path-parse popularity was classified as popular.
We found that path-parse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.