2 var fs = require('graceful-fs');
3 var Promise = require('pinkie-promise');
4 var pify = require('pify');
6 function type(fn, fn2, fp) {
7 if (typeof fp !== 'string') {
8 return Promise.reject(new TypeError('Expected a string'));
11 return pify(fs[fn], Promise)(fp).then(function (stats) {
16 function typeSync(fn, fn2, fp) {
17 if (typeof fp !== 'string') {
18 throw new TypeError('Expected a string');
21 return fs[fn](fp)[fn2]();
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');