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.

59 lines
1.1 KiB

4 years ago
  1. # path-is-absolute [![Build Status](https://travis-ci.org/sindresorhus/path-is-absolute.svg?branch=master)](https://travis-ci.org/sindresorhus/path-is-absolute)
  2. > Node.js 0.12 [`path.isAbsolute()`](http://nodejs.org/api/path.html#path_path_isabsolute_path) [ponyfill](https://ponyfill.com)
  3. ## Install
  4. ```
  5. $ npm install --save path-is-absolute
  6. ```
  7. ## Usage
  8. ```js
  9. const pathIsAbsolute = require('path-is-absolute');
  10. // Running on Linux
  11. pathIsAbsolute('/home/foo');
  12. //=> true
  13. pathIsAbsolute('C:/Users/foo');
  14. //=> false
  15. // Running on Windows
  16. pathIsAbsolute('C:/Users/foo');
  17. //=> true
  18. pathIsAbsolute('/home/foo');
  19. //=> false
  20. // Running on any OS
  21. pathIsAbsolute.posix('/home/foo');
  22. //=> true
  23. pathIsAbsolute.posix('C:/Users/foo');
  24. //=> false
  25. pathIsAbsolute.win32('C:/Users/foo');
  26. //=> true
  27. pathIsAbsolute.win32('/home/foo');
  28. //=> false
  29. ```
  30. ## API
  31. See the [`path.isAbsolute()` docs](http://nodejs.org/api/path.html#path_path_isabsolute_path).
  32. ### pathIsAbsolute(path)
  33. ### pathIsAbsolute.posix(path)
  34. POSIX specific version.
  35. ### pathIsAbsolute.win32(path)
  36. Windows specific version.
  37. ## License
  38. MIT © [Sindre Sorhus](https://sindresorhus.com)