async-image-hash
Advanced tools
Comparing version 5.3.0 to 6.0.0-cjs
{ | ||
"name": "async-image-hash", | ||
"version": "5.3.0", | ||
"version": "6.0.0-cjs", | ||
"description": "Create a hash from an image", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"test": "npx mocha -r ts-node/register __tests__/*.test.ts ", | ||
"build": "tsc", | ||
"prepare": "npm run build -s", | ||
"test": "vitest run __tests__/*.test.ts", | ||
"coverage": "npm run test -- --coverage && typescript-coverage-report", | ||
"build": "tsup --config ./tsup.config.ts", | ||
"lint": "eslint src/*.ts", | ||
@@ -14,3 +16,3 @@ "lint:fix": "eslint src/*.ts --fix" | ||
"files": [ | ||
"lib" | ||
"dist" | ||
], | ||
@@ -35,28 +37,19 @@ "repository": { | ||
"@cwasm/webp": "^0.1.5", | ||
"file-type": "^16.5.3", | ||
"jpeg-js": "^0.4.0", | ||
"pngjs": "^6.0.0", | ||
"request": "^2.81.0" | ||
"file-type": "^18.5.0", | ||
"jpeg-js": "^0.4.4", | ||
"pngjs": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-transform-modules-commonjs": "^7.4.4", | ||
"@babel/preset-env": "^7.3.1", | ||
"@babel/preset-typescript": "^7.1.0", | ||
"@babel/runtime": "^7.3.1", | ||
"@types/chai": "^4.2.12", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^11.13.8", | ||
"chai": "^4.2.0", | ||
"eslint": "^8.8.0", | ||
"@types/eslint": "^8.44.2", | ||
"@types/pngjs": "^6.0.1", | ||
"@vitest/coverage-v8": "^0.34.4", | ||
"eslint": "^8.49.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^16.1.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"mocha": "^9.0.0", | ||
"ts-node": "^8.10.2", | ||
"typescript": "^3.3.1", | ||
"@types/pngjs": "^6.0.1" | ||
"eslint-config-airbnb-typescript": "^17.1.0", | ||
"eslint-plugin-import": "^2.28.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2", | ||
"typescript-coverage-report": "^0.8.0", | ||
"vitest": "^0.34.4" | ||
} | ||
} |
@@ -10,3 +10,3 @@ # async-image-hash | ||
```bash | ||
npm i -S image-hash | ||
npm i image-hash | ||
``` | ||
@@ -20,4 +20,3 @@ | ||
// remote file simple | ||
imageHash('https://ichef-1.bbci.co.uk/news/660/cpsprodpb/7F76/production/_95703623_mediaitem95703620.jpg', 16, true, (error, data) => { | ||
if (error) throw error; | ||
imageHash('https://ichef-1.bbci.co.uk/news/660/cpsprodpb/7F76/production/_95703623_mediaitem95703620.jpg', 16, true).then(data => { | ||
console.log(data); | ||
@@ -27,16 +26,4 @@ // 0773063f063f36070e070a070f378e7f1f000fff0fff020103f00ffb0f810ff0 | ||
// remote file with requestjs config object | ||
const config = { | ||
uri: 'https://ichef-1.bbci.co.uk/news/660/cpsprodpb/7F76/production/_95703623_mediaitem95703620.jpg' | ||
}; | ||
imageHash(config, 16, true, (error, data) => { | ||
if (error) throw error; | ||
console.log(data); | ||
// 0773063f063f36070e070a070f378e7f1f000fff0fff020103f00ffb0f810ff0 | ||
}); | ||
//local file | ||
imageHash('./_95695590_tv039055678.jpg', 16, true, (error, data) => { | ||
if (error) throw error; | ||
imageHash('./_95695590_tv039055678.jpg', 16, true).then(data => { | ||
console.log(data); | ||
@@ -51,4 +38,3 @@ // 0773063f063f36070e070a070f378e7f1f000fff0fff020103f00ffb0f810ff0 | ||
data: fBuffer | ||
}, 16, true, (error, data) => { | ||
if(error) throw error; | ||
}, 16, true).then(data => { | ||
console.log(data); | ||
@@ -62,4 +48,3 @@ // 0773063f063f36070e070a070f378e7f1f000fff0fff020103f00ffb0f810ff0 | ||
data: fBuffer | ||
}, 16, true, (error, data) => { | ||
if(error) throw error; | ||
}, 16, true).then(data => { | ||
console.log(data); | ||
@@ -74,6 +59,6 @@ // 0773063f063f36070e070a070f378e7f1f000fff0fff020103f00ffb0f810ff0 | ||
// name | ||
imageHash(location, bits, precise, callback); | ||
imageHash(location, bits, precise); | ||
// types | ||
imageHash(string|object, int, bool, function); | ||
imageHash(string|object, int, bool): Promise<string>; | ||
``` | ||
@@ -89,6 +74,5 @@ | ||
| -------- | ---- | ----------- | --------- | ------- | | ||
| location | `object` or `string` | A [RequestJS Object](https://github.com/request/request#requestoptions-callback), `Buffer` object (See input types below for more details), or `String` with a valid url or file location | Yes | see above | | ||
| location | `object` or `string` | `Buffer` object (See input types below for more details), or `String` with a valid url or file location | Yes | see above | | ||
| bits | `int` | The number of bits in a row. The more bits, the more unique the hash. | Yes | 8 | | ||
| precise | `bool` | Whether a precision algorithm is used. `true` Precise but slower, non-overlapping blocks. `false` Quick and crude, non-overlapping blocks. Method 2 is recommended as a good tradeoff between speed and good matches on any image size. The quick ones are only advisable when the image width and height are an even multiple of the number of blocks used. | Yes | `true` | | ||
| callback | `function` | A function with `error` and `data` arguments - see below | | ||
@@ -98,8 +82,2 @@ #### Location Object Types | ||
```typescript | ||
// Url Request Object | ||
interface UrlRequestObject { | ||
encoding?: string | null, | ||
url: string | null, | ||
}; | ||
// Buffer Object | ||
@@ -113,17 +91,2 @@ interface BufferObject { | ||
### Callback Arguments | ||
| Argument | Type | Description | | ||
| -------- | ------------------------ | ----------------------------------------------------------------------------------- | | ||
| error | `Error Object` or `null` | If a run time error is detected this will be an `Error Object`, otherwise `null` | | ||
| data | `string` or `null` | If there is no run time error, this be will be your hashed result, otherwise `null` | | ||
## Development | ||
I have made this with Typescript, ESLint, Jest, Babel and VSCode. All config files and global binaries are included. For developers using VS Code, make sure you have ESLint extension installed. | ||
## Testing | ||
`npm test` | ||
## Credit | ||
@@ -130,0 +93,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
27437
4
11
6
46
2
90
2
+ Addedabort-controller@3.0.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfile-type@18.7.0(transitive)
+ Addedpeek-readable@5.4.2(transitive)
+ Addedpngjs@7.0.0(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedreadable-stream@4.7.0(transitive)
+ Addedreadable-web-to-node-stream@3.0.3(transitive)
+ Addedstrtok3@7.1.1(transitive)
+ Addedtoken-types@5.0.1(transitive)
- Removedrequest@^2.81.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfile-type@16.5.4(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedpeek-readable@4.1.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpngjs@6.0.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedreadable-web-to-node-stream@3.0.2(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstrtok3@6.3.0(transitive)
- Removedtoken-types@4.2.1(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
Updatedfile-type@^18.5.0
Updatedjpeg-js@^0.4.4
Updatedpngjs@^7.0.0