Comparing version 3.0.0 to 3.0.1
@@ -10,13 +10,16 @@ /** | ||
// Node.js: | ||
import readChunk from 'read-chunk'; | ||
import {readChunk} from 'read-chunk'; | ||
import isPng from 'is-png'; | ||
const buffer = readChunk.sync('unicorn.png', 0, 8); | ||
const buffer = await readChunk('unicorn.png', {length: 8}); | ||
isPng(buffer); | ||
//=> true | ||
``` | ||
@example | ||
``` | ||
import isPng from 'is-png'; | ||
// Browser: | ||
import readChunk from 'read-chunk'; | ||
const response = await fetch('unicorn.png'); | ||
@@ -29,2 +32,2 @@ const buffer = await response.arrayBuffer(); | ||
*/ | ||
export default function isPng(buffer: Uint8Array | Buffer): boolean; | ||
export default function isPng(buffer: Uint8Array): boolean; |
18
index.js
@@ -6,12 +6,10 @@ export default function isPng(buffer) { | ||
return ( | ||
buffer[0] === 0x89 && | ||
buffer[1] === 0x50 && | ||
buffer[2] === 0x4E && | ||
buffer[3] === 0x47 && | ||
buffer[4] === 0x0D && | ||
buffer[5] === 0x0A && | ||
buffer[6] === 0x1A && | ||
buffer[7] === 0x0A | ||
); | ||
return buffer[0] === 0x89 | ||
&& buffer[1] === 0x50 | ||
&& buffer[2] === 0x4E | ||
&& buffer[3] === 0x47 | ||
&& buffer[4] === 0x0D | ||
&& buffer[5] === 0x0A | ||
&& buffer[6] === 0x1A | ||
&& buffer[7] === 0x0A; | ||
} |
{ | ||
"name": "is-png", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Check if a Buffer/Uint8Array is a PNG image", | ||
@@ -43,8 +43,8 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/node": "^14.14.41", | ||
"@types/node": "^16.7.10", | ||
"ava": "^3.15.0", | ||
"read-chunk": "^3.2.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.38.2" | ||
"read-chunk": "^4.0.1", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
@@ -16,6 +16,6 @@ # is-png | ||
```js | ||
import readChunk from 'read-chunk'; // npm install read-chunk | ||
import {readChunk} from 'read-chunk'; | ||
import isPng from 'is-png'; | ||
const buffer = readChunk.sync('unicorn.png', 0, 8); | ||
const buffer = await readChunk('unicorn.png', {length: 8}); | ||
@@ -22,0 +22,0 @@ isPng(buffer); |
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
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
37
3772