Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/is-dir-like-path
Check if a given string looks like a directory path
https://github.com/shinnn/is-dir-like-path
Last synced: 26 days ago
JSON representation
Check if a given string looks like a directory path
- Host: GitHub
- URL: https://github.com/shinnn/is-dir-like-path
- Owner: shinnn
- License: isc
- Created: 2015-11-10T10:52:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-16T09:43:39.000Z (over 5 years ago)
- Last Synced: 2024-09-20T13:18:08.961Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 79.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-dir-like-path
[![npm version](https://img.shields.io/npm/v/is-dir-like-path.svg)](https://www.npmjs.com/package/is-dir-like-path)
[![Build Status](https://travis-ci.com/shinnn/is-dir-like-path.svg?branch=master)](https://travis-ci.com/shinnn/is-dir-like-path)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/is-dir-like-path.svg)](https://coveralls.io/github/shinnn/is-dir-like-path)Check if a given `string` looks like a directory path
```javascript
const isDirLikePath = require('is-dir-like-path');isDirLikePath('foo'); //=> false
isDirLikePath('foo/'); //=> true
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install is-dir-like-path
```## API
```javascript
const isDirLikePath = require('is-dir-like-path');
```### isDirLikePath(*str*)
*str*: `string` (path)
Return: `boolean`It returns `true` if the last character of a given string is equal to [`path.sep`](https://nodejs.org/api/path.html#path_path_sep).
```javascript
// On POSIX
isDirLikePath('dir\\'); //=> false// On Windows
isDirLikePath('dir\\'); //=> true
```### isDirLikePath.posix(*str*)
*str*: `string` (path)
Return: `boolean`Always interact in a [posix](https://www.opengroup.org/austin/papers/posix_faq.html) compatible way.
```javascript
isDirLikePath.posix('dir\\'); //=> false
```### isDirLikePath.win32(*str*)
*str*: `string` (path)
Return: `boolean````javascript
isDirLikePath.win32('dir\\'); //=> true
```Always interact in a [win32](https://msdn.microsoft.com/library/cc433218) compatible way.
## License
[ISC License](./LICENSE) © 2018 - 2019 Watanabe Shinnosuke