Comparing version 1.0.3 to 1.0.4
24
main.js
'use strict'; | ||
var fs = require('fs'); | ||
var normalize = require('path').normalize; | ||
var fileType = require('file-type'); | ||
@@ -17,3 +18,3 @@ var mime = require('mime-types'); | ||
try { | ||
fs.accessSync(require('path').normalize(path)); | ||
fs.accessSync(normalize(path)); | ||
return true; | ||
@@ -29,3 +30,3 @@ } catch (e) { | ||
if (!data.fd) { | ||
data.path = require('path').normalize(data.path); | ||
data.path = normalize(data.path); | ||
if (isExists(data.path)) { | ||
@@ -45,3 +46,2 @@ data.fd = fs.openSync(data.path, data.flags, data.mode); | ||
function streamSync(stream, length) { | ||
var buf; | ||
if (!stream.closed && !stream.destroyed && length > 0) { | ||
@@ -56,5 +56,3 @@ try { | ||
buf = chunkSync(data, length); | ||
return buf; | ||
return chunkSync(data, length); | ||
} catch (e) { | ||
@@ -68,3 +66,3 @@ throw new Error('The file must be local and exists.'); | ||
module.exports = function(data, defaultValue) { | ||
module.exports = function (data, defaultValue) { | ||
var type; | ||
@@ -76,3 +74,3 @@ var ext; | ||
if (!type && isExists(data)) { | ||
type = fileType(chunkSync({path: data, flags: 'r'}, 262)); | ||
type = fileType(chunkSync({ path: data, flags: 'r' }, 262)); | ||
} | ||
@@ -86,5 +84,7 @@ } else if (Buffer.isBuffer(data)) { | ||
if (type) { | ||
!type.mime || (type = type.mime); | ||
ext = mime.extension(type); | ||
return {ext: ext, mime: type}; | ||
if (type.mime) { | ||
return { ext: type.ext, mime: type.mime }; | ||
} | ||
return { ext: mime.extension(type), mime: type }; | ||
} | ||
@@ -117,3 +117,3 @@ | ||
if (type && ext) { | ||
return {ext: ext, mime: type}; | ||
return { ext: ext, mime: type }; | ||
} | ||
@@ -120,0 +120,0 @@ } |
{ | ||
"name": "mime-kind", | ||
"author": "Alexey Bystrov <strikeentco@gmail.com>", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Detect the mime type of a Buffer, ReadStream, file path and file name.", | ||
@@ -17,2 +17,5 @@ "keywords": [ | ||
"main": "./main.js", | ||
"files": [ | ||
"main.js" | ||
], | ||
"scripts": { | ||
@@ -30,10 +33,10 @@ "test": "mocha test", | ||
"dependencies": { | ||
"file-type": "^3.7.0", | ||
"mime-types": "^2.1.7" | ||
"file-type": "^3.8.0", | ||
"mime-types": "^2.1.10" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.3.3", | ||
"should": "^7.1.0" | ||
"mocha": "^2.4.5", | ||
"should": "^8.2.2" | ||
}, | ||
"license": "MIT" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
4608
3
95
1
0
Updatedfile-type@^3.8.0
Updatedmime-types@^2.1.10