Initial commit
[yaffs-website] / node_modules / path-root / README.md
1 # path-root [![NPM version](https://img.shields.io/npm/v/path-root.svg?style=flat)](https://www.npmjs.com/package/path-root) [![NPM downloads](https://img.shields.io/npm/dm/path-root.svg?style=flat)](https://npmjs.org/package/path-root) [![Build Status](https://img.shields.io/travis/jonschlinkert/path-root.svg?style=flat)](https://travis-ci.org/jonschlinkert/path-root)
2
3 > Get the root of a posix or windows filepath.
4
5 You might also be interested in [parse-filepath](https://github.com/jonschlinkert/parse-filepath).
6
7 ## Install
8
9 Install with [npm](https://www.npmjs.com/):
10
11 ```sh
12 $ npm install path-root --save
13 ```
14
15 ## Usage
16
17 ```js
18 var pathRoot = require('path-root');
19 ```
20
21 **Examples**
22
23 ```js
24 pathRoot('\\\\server\\share\\abc');
25 //=> '\\\\server\\share\\'
26
27 pathRoot('\\\\server foo\\some folder\\base-file.js');
28 //=> '\\\\server foo\\some folder\\'
29
30 pathRoot('\\\\?\\UNC\\server\\share');
31 //=> '\\\\?\\UNC\\'
32
33 pathRoot('foo/bar/baz.js');
34 //=> ''
35
36 pathRoot('c:\\foo\\bar\\baz.js');
37 //=> 'c:\\'
38
39 pathRoot('\\\\slslslsl\\admin$\\system32');
40 //=> '\\\\slslslsl\\admin$\\'
41
42 pathRoot('/foo/bar/baz.js');
43 //=> '/'
44 ```
45
46 ## Related projects
47
48 You might also be interested in these projects:
49
50 * [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)
51 * [parse-filepath](https://www.npmjs.com/package/parse-filepath): Parse a filepath into an object. Falls back on the native node.js `path.parse` method if… [more](https://www.npmjs.com/package/parse-filepath) | [homepage](https://github.com/jonschlinkert/parse-filepath)
52 * [path-root-regex](https://www.npmjs.com/package/path-root-regex): Regular expression for getting the root of a posix or windows filepath. | [homepage](https://github.com/regexhq/path-root-regex)
53
54 ## Contributing
55
56 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/path-root/issues/new).
57
58 ## Building docs
59
60 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
61
62 ```sh
63 $ npm install verb && npm run docs
64 ```
65
66 Or, if [verb](https://github.com/verbose/verb) is installed globally:
67
68 ```sh
69 $ verb
70 ```
71
72 ## Running tests
73
74 Install dev dependencies:
75
76 ```sh
77 $ npm install -d && npm test
78 ```
79
80 ## Author
81
82 **Jon Schlinkert**
83
84 * [github/jonschlinkert](https://github.com/jonschlinkert)
85 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
86
87 ## License
88
89 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
90 Released under the [MIT license](https://github.com/jonschlinkert/path-root/blob/master/LICENSE).
91
92 ***
93
94 _This file was generated by [verb](https://github.com/verbose/verb), v, on March 29, 2016._