Initial commit
[yaffs-website] / node_modules / parse-filepath / README.md
1 # parse-filepath [![NPM version](https://img.shields.io/npm/v/parse-filepath.svg?style=flat)](https://www.npmjs.com/package/parse-filepath) [![NPM downloads](https://img.shields.io/npm/dm/parse-filepath.svg?style=flat)](https://npmjs.org/package/parse-filepath) [![Build Status](https://img.shields.io/travis/jonschlinkert/parse-filepath.svg?style=flat)](https://travis-ci.org/jonschlinkert/parse-filepath)
2
3 > Pollyfill for node.js `path.parse`, parses a filepath into an object.
4
5 You might also be interested in [global-prefix](https://github.com/jonschlinkert/global-prefix).
6
7 ## Install
8
9 Install with [npm](https://www.npmjs.com/):
10
11 ```sh
12 $ npm install parse-filepath --save
13 ```
14
15 ## Usage
16
17 ```js
18 var parsePath = require('parse-filepath');
19 parsePath(filepath);
20 ```
21
22 This can be used as a polyfill for the native node.js `path.parse()` method, and it also adds a few properties:
23
24 * `path`: the original filepath
25 * `isAbsolute`: (getter) true if the given path is absolute
26 * `absolute`: (getter) fully resolved, absolute filepath
27 * `dirname`: alias for `dir`
28 * `basename`: alias for `base`
29 * `extname`: alias for `ext`
30 * `stem`: alias for `name`
31
32 **Example**
33
34 ```js
35 var parsePath = require('parse-filepath');
36 console.log(parsePath('foo/bar/baz/index.js'));
37 ```
38
39 Returns:
40
41 ```js
42 { root: '',
43   dir: 'foo/bar/baz',
44   base: 'index.js',
45   ext: '.js',
46   name: 'index',
47
48   // aliases
49   extname: '.js',
50   basename: 'index.js',
51   dirname: 'foo/bar/baz',
52   stem: 'index',
53
54   // original path
55   path: 'foo/bar/baz/index.js',
56
57   // getters
58   absolute: [Getter/Setter],
59   isAbsolute: [Getter/Setter] }
60 ```
61
62 ## Related projects
63
64 You might also be interested in these projects:
65
66 * [global-prefix](https://www.npmjs.com/package/global-prefix): Get the npm global path prefix. | [homepage](https://github.com/jonschlinkert/global-prefix)
67 * [is-absolute](https://www.npmjs.com/package/is-absolute): Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute)
68 * [is-relative](https://www.npmjs.com/package/is-relative): Returns `true` if the path appears to be relative. | [homepage](https://github.com/jonschlinkert/is-relative)
69 * [relative](https://www.npmjs.com/package/relative): Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file,… [more](https://www.npmjs.com/package/relative) | [homepage](https://github.com/jonschlinkert/relative)
70
71 ## Contributing
72
73 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/parse-filepath/issues/new).
74
75 ## Building docs
76
77 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
78
79 ```sh
80 $ npm install verb && npm run docs
81 ```
82
83 Or, if [verb](https://github.com/verbose/verb) is installed globally:
84
85 ```sh
86 $ verb
87 ```
88
89 ## Running tests
90
91 Install dev dependencies:
92
93 ```sh
94 $ npm install -d && npm test
95 ```
96
97 ## Author
98
99 **Jon Schlinkert**
100
101 * [github/jonschlinkert](https://github.com/jonschlinkert)
102 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
103
104 ## License
105
106 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
107 Released under the [MIT license](https://github.com/jonschlinkert/parse-filepath/blob/master/LICENSE).
108
109 ***
110
111 _This file was generated by [verb](https://github.com/verbose/verb), v, on March 29, 2016._