diff options
Diffstat (limited to 'deps/node/deps/npm/node_modules/fstream/lib/get-type.js')
-rw-r--r-- | deps/node/deps/npm/node_modules/fstream/lib/get-type.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/deps/node/deps/npm/node_modules/fstream/lib/get-type.js b/deps/node/deps/npm/node_modules/fstream/lib/get-type.js new file mode 100644 index 00000000..19f6a657 --- /dev/null +++ b/deps/node/deps/npm/node_modules/fstream/lib/get-type.js @@ -0,0 +1,33 @@ +module.exports = getType + +function getType (st) { + var types = [ + 'Directory', + 'File', + 'SymbolicLink', + 'Link', // special for hardlinks from tarballs + 'BlockDevice', + 'CharacterDevice', + 'FIFO', + 'Socket' + ] + var type + + if (st.type && types.indexOf(st.type) !== -1) { + st[st.type] = true + return st.type + } + + for (var i = 0, l = types.length; i < l; i++) { + type = types[i] + var is = st[type] || st['is' + type] + if (typeof is === 'function') is = is.call(st) + if (is) { + st[type] = true + st.type = type + return type + } + } + + return null +} |