Socket
Socket
Sign inDemoInstall

mime-kind

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mime-kind - npm Package Compare versions

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc