Socket
Socket
Sign inDemoInstall

is-jpg

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 3.0.0

11

index.js

@@ -1,3 +0,2 @@

'use strict';
module.exports = buffer => {
export default function isJpg(buffer) {
if (!buffer || buffer.length < 3) {

@@ -7,5 +6,5 @@ return false;

return buffer[0] === 255 &&
buffer[1] === 216 &&
buffer[2] === 255;
};
return buffer[0] === 255
&& buffer[1] === 216
&& buffer[2] === 255;
}
{
"name": "is-jpg",
"version": "2.0.0",
"description": "Check if a Buffer/Uint8Array is a JPEG image",
"license": "MIT",
"repository": "sindresorhus/is-jpg",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"jpg",
"jpeg",
"image",
"img",
"pic",
"picture",
"photo",
"type",
"detect",
"check",
"is",
"exif",
"binary",
"buffer",
"uint8array",
"cli",
"bin"
],
"devDependencies": {
"ava": "*",
"read-chunk": "^2.1.0",
"xo": "*"
}
"name": "is-jpg",
"version": "3.0.0",
"description": "Check if a Buffer/Uint8Array is a JPEG image",
"license": "MIT",
"repository": "sindresorhus/is-jpg",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"jpg",
"jpeg",
"image",
"picture",
"photo",
"type",
"detect",
"check",
"is",
"exif",
"binary",
"buffer",
"uint8array"
],
"devDependencies": {
"ava": "^3.15.0",
"read-chunk": "^4.0.2",
"xo": "^0.44.0"
}
}

@@ -1,13 +0,11 @@

# is-jpg [![Build Status](https://travis-ci.org/sindresorhus/is-jpg.svg?branch=master)](https://travis-ci.org/sindresorhus/is-jpg)
# is-jpg
> Check if a Buffer/Uint8Array is a [JPEG](https://en.wikipedia.org/wiki/JPEG) image
## Install
```sh
npm install is-jpg
```
$ npm install is-jpg
```
## Usage

@@ -18,6 +16,7 @@

```js
const readChunk = require('read-chunk');
const isJpg = require('is-jpg');
const buffer = readChunk.sync('unicorn.jpg', 0, 3);
import {readChunk} from 'read-chunk';
import isJpg from 'is-jpg';
const buffer = await readChunk('unicorn.jpg', {length: 3});
isJpg(buffer);

@@ -42,3 +41,2 @@ //=> true

## API

@@ -48,14 +46,8 @@

Accepts a Buffer (Node.js) or Uint8Array.
Accepts a `Buffer` (Node.js) or `Uint8Array`.
It only needs the first 3 bytes.
## Related
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc