Sha256: 26106de437f8795522861fa6dbb836606d687ce46228f68a66954d8e85e73469

Contents?: true

Size: 841 Bytes

Versions: 35

Compression:

Stored size: 841 Bytes

Contents

'use strict';
var fs = require('graceful-fs');
var Promise = require('pinkie-promise');
var pify = require('pify');

function type(fn, fn2, fp) {
	if (typeof fp !== 'string') {
		return Promise.reject(new TypeError('Expected a string'));
	}

	return pify(fs[fn], Promise)(fp).then(function (stats) {
		return stats[fn2]();
	});
}

function typeSync(fn, fn2, fp) {
	if (typeof fp !== 'string') {
		throw new TypeError('Expected a string');
	}

	return fs[fn](fp)[fn2]();
}

exports.file = type.bind(null, 'stat', 'isFile');
exports.dir = type.bind(null, 'stat', 'isDirectory');
exports.symlink = type.bind(null, 'lstat', 'isSymbolicLink');
exports.fileSync = typeSync.bind(null, 'statSync', 'isFile');
exports.dirSync = typeSync.bind(null, 'statSync', 'isDirectory');
exports.symlinkSync = typeSync.bind(null, 'lstatSync', 'isSymbolicLink');

Version data entries

35 entries across 34 versions & 15 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/read-pkg/node_modules/path-type/index.js
disco_app-0.18.0 test/dummy/node_modules/path-type/index.js
disco_app-0.18.2 test/dummy/node_modules/path-type/index.js
tang-0.2.1 spec/tang_app/node_modules/read-pkg/node_modules/path-type/index.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/read-pkg/node_modules/path-type/index.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/read-pkg/node_modules/path-type/index.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/read-pkg/node_modules/path-type/index.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/read-pkg/node_modules/path-type/index.js
tang-0.2.0 spec/tang_app/node_modules/read-pkg/node_modules/path-type/index.js
tang-0.1.0 spec/tang_app/node_modules/read-pkg/node_modules/path-type/index.js
tang-0.0.9 spec/tang_app/node_modules/read-pkg/node_modules/path-type/index.js
enju_library-0.3.8 spec/dummy/node_modules/read-pkg/node_modules/path-type/index.js
ilog-0.4.1 node_modules/path-type/index.js
ilog-0.4.0 node_modules/path-type/index.js
ilog-0.3.3 node_modules/path-type/index.js
jester-data-8.0.0 node_modules/path-type/index.js
ezii-os-5.2.1 node_modules/path-type/index.js
ezii-os-2.0.1 node_modules/path-type/index.js
ezii-os-1.1.0 node_modules/path-type/index.js
ezii-os-1.0.0 node_modules/path-type/index.js