New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

guess-mime

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

guess-mime - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

12

index.js
function isPNG(binStr) {
var PNG_MARKER = [137, 80, 78, 71, 13, 10, 26, 10]
.map(code => String.fromCharCode(code)).join('');
.map(function(code){
return String.fromCharCode(code);
}).join('');
return binStr.indexOf(PNG_MARKER) === 0;

@@ -9,6 +11,6 @@ }

var length = binStr.length;
var SOI = `${String.fromCharCode(0xff)}${String.fromCharCode(0xd8)}`;
var DQT = `${String.fromCharCode(0xff)}${String.fromCharCode(0xdb)}`;
var DHT = `${String.fromCharCode(0xff)}${String.fromCharCode(0xc4)}`;
var EOI = `${String.fromCharCode(0xff)}${String.fromCharCode(0xd9)}`;
var SOI = String.fromCharCode(0xff) + String.fromCharCode(0xd8);
var DQT = String.fromCharCode(0xff) + String.fromCharCode(0xdb);
var DHT = String.fromCharCode(0xff) + String.fromCharCode(0xc4);
var EOI = String.fromCharCode(0xff) + String.fromCharCode(0xd9);
var EOIIndex = binStr.indexOf(EOI);

@@ -15,0 +17,0 @@ return ((binStr.indexOf(SOI) !== -1)

{
"name": "guess-mime",
"version": "0.0.1",
"version": "0.0.2",
"description": "Guess image file mime form binary string",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,1 +5,9 @@ # Guess MIME from Binary String.

A Library to determine mime type from binary string.
```js
import guessMIME from 'guess-mime';
const base64 = '...'; // just base64 code of image, without mime segment
const binaryString = window.atob(base64);
const mime = guessMIME(binaryString); // return null if guess failed
```
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