UNPKG

@code-to-json/cli

Version:

53 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var fs = require("fs"); function get(obj, propname) { if (obj && typeof obj === 'object') return obj[propname]; else return undefined; } function isEmpty(obj) { var none = obj === null || obj === undefined; if (none) { return none; } if (typeof obj.size === 'number') { return !obj.size; } var objectType = typeof obj; if (objectType === 'object') { var size = get(obj, 'size'); if (typeof size === 'number') { return !size; } } if (typeof obj.length === 'number' && objectType !== 'function') { return !obj.length; } if (objectType === 'object') { var length = get(obj, 'length'); if (typeof length === 'number') { return !length; } } return false; } exports.isEmpty = isEmpty; function isBlank(obj) { return isEmpty(obj) || (typeof obj === 'string' && /\S/.test(obj) === false); } exports.isBlank = isBlank; function isPresent(obj) { return !isBlank(obj); } exports.isPresent = isPresent; function isFileThatExists(pathString) { return fs.existsSync(pathString) && fs.lstatSync(pathString).isFile(); } exports.isFileThatExists = isFileThatExists; function isDirectoryThatExists(pathString) { return fs.existsSync(pathString) && fs.lstatSync(pathString).isDirectory(); } exports.isDirectoryThatExists = isDirectoryThatExists; //# sourceMappingURL=validators.js.map