Initial commit
[yaffs-website] / node_modules / path-type / index.js
1 'use strict';
2 var fs = require('graceful-fs');
3 var Promise = require('pinkie-promise');
4 var pify = require('pify');
5
6 function type(fn, fn2, fp) {
7         if (typeof fp !== 'string') {
8                 return Promise.reject(new TypeError('Expected a string'));
9         }
10
11         return pify(fs[fn], Promise)(fp).then(function (stats) {
12                 return stats[fn2]();
13         });
14 }
15
16 function typeSync(fn, fn2, fp) {
17         if (typeof fp !== 'string') {
18                 throw new TypeError('Expected a string');
19         }
20
21         return fs[fn](fp)[fn2]();
22 }
23
24 exports.file = type.bind(null, 'stat', 'isFile');
25 exports.dir = type.bind(null, 'stat', 'isDirectory');
26 exports.symlink = type.bind(null, 'lstat', 'isSymbolicLink');
27 exports.fileSync = typeSync.bind(null, 'statSync', 'isFile');
28 exports.dirSync = typeSync.bind(null, 'statSync', 'isDirectory');
29 exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink');