diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-02 23:03:02 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-02 23:03:02 +0200 |
commit | 02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b (patch) | |
tree | 6d1dec61008998aadc6b69f7e750712794d99324 /includes/external/chvfs/node_modules/node-watch/lib/is.js | |
parent | f559308a1b42a9036135d764374a8c007b7d70a9 (diff) | |
download | pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.gz pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.bz2 pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.zip |
Updated 35 files, added 11 files and deleted includes/components/search.inc (automated)
Diffstat (limited to 'includes/external/chvfs/node_modules/node-watch/lib/is.js')
-rw-r--r-- | includes/external/chvfs/node_modules/node-watch/lib/is.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/includes/external/chvfs/node_modules/node-watch/lib/is.js b/includes/external/chvfs/node_modules/node-watch/lib/is.js new file mode 100644 index 0000000..ebe0600 --- /dev/null +++ b/includes/external/chvfs/node_modules/node-watch/lib/is.js @@ -0,0 +1,78 @@ +var fs = require('fs'); +var path = require('path'); +var os = require('os'); + +function matchObject(item, str) { + return Object.prototype.toString.call(item) + === '[object ' + str + ']'; +} + +function checkStat(name, fn) { + try { + return fn(name); + } catch (err) { + if (/^(ENOENT|EPERM|EACCES)$/.test(err.code)) { + if (err.code !== 'ENOENT') { + console.warn('Warning: Cannot access %s', name); + } + return false; + } + throw err; + } +} + +var is = { + nil: function(item) { + return item == null; + }, + array: function(item) { + return Array.isArray(item); + }, + emptyObject: function(item) { + for (var key in item) { + return false; + } + return true; + }, + buffer: function(item) { + return Buffer.isBuffer(item); + }, + regExp: function(item) { + return matchObject(item, 'RegExp'); + }, + string: function(item) { + return matchObject(item, 'String'); + }, + func: function(item) { + return typeof item === 'function'; + }, + number: function(item) { + return matchObject(item, 'Number'); + }, + exists: function(name) { + return fs.existsSync(name); + }, + file: function(name) { + return checkStat(name, function(n) { + return fs.statSync(n).isFile() + }); + }, + samePath: function(a, b) { + return path.resolve(a) === path.resolve(b); + }, + directory: function(name) { + return checkStat(name, function(n) { + return fs.statSync(n).isDirectory() + }); + }, + symbolicLink: function(name) { + return checkStat(name, function(n) { + return fs.lstatSync(n).isSymbolicLink(); + }); + }, + windows: function() { + return os.platform() === 'win32'; + } +}; + +module.exports = is; |