Pathologic was missing because of a .git folder inside.
[yaffs-website] / node_modules / is-jpg / readme.md
1 # is-jpg [![Build Status](https://travis-ci.org/sindresorhus/is-jpg.svg?branch=master)](https://travis-ci.org/sindresorhus/is-jpg)
2
3 > Check if a Buffer/Uint8Array is a [JPEG](http://en.wikipedia.org/wiki/JPEG) image
4
5 Used by [image-type](https://github.com/sindresorhus/image-type).
6
7
8 ## Install
9
10 ```sh
11 $ npm install --save is-jpg
12 ```
13
14
15 ## Usage
16
17 ##### Node.js
18
19 ```js
20 var readChunk = require('read-chunk'); // npm install read-chunk
21 var isJpg = require('is-jpg');
22 var buffer = readChunk.sync('unicorn.jpg', 0, 3);
23
24 isJpg(buffer);
25 //=> true
26 ```
27
28 ##### Browser
29
30 ```js
31 var xhr = new XMLHttpRequest();
32 xhr.open('GET', 'unicorn.jpg');
33 xhr.responseType = 'arraybuffer';
34
35 xhr.onload = function () {
36         isJpg(new Uint8Array(this.response));
37         //=> true
38 };
39
40 xhr.send();
41 ```
42
43
44 ## API
45
46 ### isJpg(buffer)
47
48 Accepts a Buffer (Node.js) or Uint8Array.
49
50 It only needs the first 3 bytes.
51
52
53 ## License
54
55 MIT © [Sindre Sorhus](http://sindresorhus.com)