Skip to content

Commit 1e0647a

Browse files
committed
refactor(index): ✨ added interface to output
1 parent f2e268b commit 1e0647a

File tree

3 files changed

+1029
-12
lines changed

3 files changed

+1029
-12
lines changed

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
"description": "Simple utility to generate blurhash from Image URL",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.esm.js",
7+
"umd": "dist/umd/index.js",
78
"files": [
89
"dist"
910
],
1011
"types": "dist/index.d.ts",
1112
"scripts": {
1213
"build": "rollup -c",
1314
"test": "yarn build && node ./test/index.js",
14-
"watch": "rollup -cw"
15+
"watch": "rollup -cw",
16+
"commit": "gacp",
17+
"clean:dist": "npm exec -- rimraf ./dist"
1518
},
1619
"license": "MIT",
1720
"dependencies": {
@@ -21,6 +24,8 @@
2124
},
2225
"devDependencies": {
2326
"@types/sharp": "^0.30.5",
27+
"gacp": "^3.0.3",
28+
"rimraf": "^3.0.2",
2429
"rollup": "^2.78.1",
2530
"rollup-plugin-typescript2": "^0.33.0",
2631
"typescript": "^4.8.2"
@@ -44,5 +49,11 @@
4449
"sharp",
4550
"plaiceholder",
4651
"blurhash-from-url"
47-
]
52+
],
53+
"gacp": {
54+
"add": false,
55+
"push": false,
56+
"emoji": "emoji",
57+
"editor": false
58+
}
4859
}

src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import get from "axios";
22
import { encode, decode } from "blurhash";
33
import sharp from 'sharp';
44

5+
export interface IOutput {
6+
encoded: string;
7+
decoded: Uint8ClampedArray;
8+
width: number;
9+
height: number;
10+
}
11+
512
export const blurhashFromURL = async (url: string) => {
613
const image = await get(url, {
714
responseType: "arraybuffer",
@@ -23,7 +30,7 @@ export const blurhashFromURL = async (url: string) => {
2330
);
2431
const decoded = decode(encoded, info.width, info.height);
2532

26-
const output = {
33+
const output: IOutput = {
2734
encoded: encoded,
2835
decoded: decoded,
2936
width: info.width,

0 commit comments

Comments
 (0)