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

async-image-hash

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-image-hash - npm Package Compare versions

Comparing version 5.3.0 to 6.0.0-cjs

dist/index.d.ts

49

package.json
{
"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 @@

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