JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6943722
  • Score
    100M100P100Q217901F

Thin wrapper around the node.js path module to simplify working with multiple file extensions and yield predictable results for basename. Just pass a filepath and get an object of path segments. This is a tiny lib with no dependencies.

Package Exports

  • parse-filepath

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-filepath) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

parse-filepath NPM version

Thin wrapper around the node.js path module to simplify working with multiple file extensions and yield predictable results for basename. Just pass a filepath and get an object of path segments. This is a tiny lib with no dependencies.

Install

Install with npm:

npm i parse-filepath --save-dev

Usage

var parsePath = require('parse-filepath');
parsePath('foo/bar/baz/index.md.html');

// returns
{
  basename: 'index',
  dirname: 'foo/bar/baz',
  extname: '.md.html',
  filename: 'index.md.html',
  extSegments: ['.md', '.html']
}

Differences

Given the following string:

var str = 'foo/bar/baz/quux.min.js';

.basename

Node.js:

  • path.basename(str) => quux.min.js
  • path.basename(str, path.extname(str)) => quux.min whaaaaa!?

parse-filepath:

  • parsePath(str).basename => quux.min.js
  • parsePath(str).name => quux

.extname

Node.js:

  • path.extname(str) => .js

parse-filepath

  • parsePath(str).extname => .min.js

.dotfiles

Given the following string:

var str = 'foo/bar/.dotfile';

Node.js

  • path.basename(str) => .dotfile
  • path.extname(str) => .dotfile

parse-filepath

  • parsePath(str).basename => dotfile
  • parsePath(str).name => dotfile
  • parsePath(str).extname => ''

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on May 09, 2014.