You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # is-absolute [![NPM version](https://img.shields.io/npm/v/is-absolute.svg?style=flat)](https://www.npmjs.com/package/is-absolute) [![NPM monthly downloads](https://img.shields.io/npm/dm/is-absolute.svg?style=flat)](https://npmjs.org/package/is-absolute) [![NPM total downloads](https://img.shields.io/npm/dt/is-absolute.svg?style=flat)](https://npmjs.org/package/is-absolute) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/is-absolute.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/is-absolute)
  2. > Returns true if a file path is absolute. Does not rely on the path module and can be used as a polyfill for node.js native `path.isAbolute`.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install --save is-absolute
  7. ```
  8. Originally based on the `isAbsolute` utility method in [express](https://github.com/visionmedia/express).
  9. ## Usage
  10. ```js
  11. var isAbsolute = require('is-absolute');
  12. isAbsolute('a/b/c.js');
  13. //=> 'false'
  14. isAbsolute('/a/b/c.js');
  15. //=> 'true'
  16. ```
  17. **Explicitly test windows paths**
  18. ```js
  19. isAbsolute.posix('/foo/bar');
  20. isAbsolute.posix('/user/docs/Letter.txt');
  21. //=> true
  22. isAbsolute.posix('foo/bar');
  23. //=> false
  24. ```
  25. **Explicitly test windows paths**
  26. ```js
  27. var isAbsolute = require('is-absolute');
  28. isAbsolute.win32('c:\\');
  29. isAbsolute.win32('//C://user\\docs\\Letter.txt');
  30. isAbsolute.win32('\\\\unc\\share');
  31. isAbsolute.win32('\\\\unc\\share\\foo');
  32. isAbsolute.win32('\\\\unc\\share\\foo\\');
  33. isAbsolute.win32('\\\\unc\\share\\foo\\bar');
  34. isAbsolute.win32('\\\\unc\\share\\foo\\bar\\');
  35. isAbsolute.win32('\\\\unc\\share\\foo\\bar\\baz');
  36. //=> true
  37. isAbsolute.win32('a:foo/a/b/c/d');
  38. isAbsolute.win32(':\\');
  39. isAbsolute.win32('foo\\bar\\baz');
  40. isAbsolute.win32('foo\\bar\\baz\\');
  41. //=> false
  42. ```
  43. ## About
  44. ### Related projects
  45. * [is-dotfile](https://www.npmjs.com/package/is-dotfile): Return true if a file path is (or has) a dotfile. Returns false if the… [more](https://github.com/jonschlinkert/is-dotfile) | [homepage](https://github.com/jonschlinkert/is-dotfile "Return true if a file path is (or has) a dotfile. Returns false if the path is a dot directory.")
  46. * [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
  47. * [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 "Returns `true` if the path appears to be relative.")
  48. * [is-unc-path](https://www.npmjs.com/package/is-unc-path): Returns true if a filepath is a windows UNC file path. | [homepage](https://github.com/jonschlinkert/is-unc-path "Returns true if a filepath is a windows UNC file path.")
  49. * [is-valid-glob](https://www.npmjs.com/package/is-valid-glob): Return true if a value is a valid glob pattern or patterns. | [homepage](https://github.com/jonschlinkert/is-valid-glob "Return true if a value is a valid glob pattern or patterns.")
  50. ### Contributing
  51. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  52. ### Contributors
  53. | **Commits** | **Contributor** |
  54. | --- | --- |
  55. | 35 | [jonschlinkert](https://github.com/jonschlinkert) |
  56. | 1 | [es128](https://github.com/es128) |
  57. | 1 | [shinnn](https://github.com/shinnn) |
  58. | 1 | [Sobak](https://github.com/Sobak) |
  59. ### Building docs
  60. _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
  61. To generate the readme, run the following command:
  62. ```sh
  63. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  64. ```
  65. ### Running tests
  66. Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
  67. ```sh
  68. $ npm install && npm test
  69. ```
  70. ### Author
  71. **Jon Schlinkert**
  72. * [github/jonschlinkert](https://github.com/jonschlinkert)
  73. * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
  74. ### License
  75. Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
  76. Released under the [MIT License](LICENSE).
  77. ***
  78. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 13, 2017._