Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | # path-type [![Build Status](https://travis-ci.org/sindresorhus/path-type.svg?branch=master)](https://travis-ci.org/sindresorhus/path-type)
|
---|
2 |
|
---|
3 | > Check if a path is a file, directory, or symlink
|
---|
4 |
|
---|
5 |
|
---|
6 | ## Install
|
---|
7 |
|
---|
8 | ```
|
---|
9 | $ npm install path-type
|
---|
10 | ```
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | const {isFile} = require('path-type');
|
---|
17 |
|
---|
18 | (async () => {
|
---|
19 | console.log(await isFile('package.json'));
|
---|
20 | //=> true
|
---|
21 | })();
|
---|
22 | ```
|
---|
23 |
|
---|
24 |
|
---|
25 | ## API
|
---|
26 |
|
---|
27 | ### isFile(path)
|
---|
28 |
|
---|
29 | Check whether the passed `path` is a file.
|
---|
30 |
|
---|
31 | Returns a `Promise<boolean>`.
|
---|
32 |
|
---|
33 | #### path
|
---|
34 |
|
---|
35 | Type: `string`
|
---|
36 |
|
---|
37 | The path to check.
|
---|
38 |
|
---|
39 | ### isDirectory(path)
|
---|
40 |
|
---|
41 | Check whether the passed `path` is a directory.
|
---|
42 |
|
---|
43 | Returns a `Promise<boolean>`.
|
---|
44 |
|
---|
45 | ### isSymlink(path)
|
---|
46 |
|
---|
47 | Check whether the passed `path` is a symlink.
|
---|
48 |
|
---|
49 | Returns a `Promise<boolean>`.
|
---|
50 |
|
---|
51 | ### isFileSync(path)
|
---|
52 |
|
---|
53 | Synchronously check whether the passed `path` is a file.
|
---|
54 |
|
---|
55 | Returns a `boolean`.
|
---|
56 |
|
---|
57 | ### isDirectorySync(path)
|
---|
58 |
|
---|
59 | Synchronously check whether the passed `path` is a directory.
|
---|
60 |
|
---|
61 | Returns a `boolean`.
|
---|
62 |
|
---|
63 | ### isSymlinkSync(path)
|
---|
64 |
|
---|
65 | Synchronously check whether the passed `path` is a symlink.
|
---|
66 |
|
---|
67 | Returns a `boolean`.
|
---|
68 |
|
---|
69 |
|
---|
70 | ## License
|
---|
71 |
|
---|
72 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.