Skip to content

Commit f2f7068

Browse files
committed
remove async await and reduce bundle size
1 parent 44aa4ac commit f2f7068

File tree

4 files changed

+17
-20
lines changed

4 files changed

+17
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1111
[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo)
1212

13-
Javascript SDK for [ImageKit](https://imagekit.io/) provides URL generation for image & video resizing and provides an interface for file upload. This SDK is lightweight and you can also use this as an ES module.
13+
Javascript SDK for [ImageKit](https://imagekit.io/) provides URL generation for image & video resizing and provides an interface for file upload. This SDK is lightweight and has no dependency. You can also use this as an ES module.
1414

1515
ImageKit is complete media storage, optimization, and transformation solution that comes with an [image and video CDN](https://imagekit.io/features/imagekit-infrastructure). It can be integrated with your existing infrastructure - storage like AWS S3, web servers, your CDN, and custom domain names, allowing you to deliver optimized images in minutes with minimal code changes.
1616

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,5 @@
6969
"url": "https://github.com/imagekit-developer/imagekit-javascript/issues"
7070
},
7171
"homepage": "https://github.com/imagekit-developer/imagekit-javascript#readme",
72-
"dependencies": {
73-
"regenerator-runtime": "^0.13.9"
74-
}
72+
"dependencies": {}
7573
}

src/utils/request.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,25 @@ const addResponseHeadersAndBody = (body: any, xhr: XMLHttpRequest): IKResponse<U
3939
return response as IKResponse<UploadResponse>;
4040
}
4141

42-
export const request = async (
42+
export const request = (
4343
uploadFileXHR: XMLHttpRequest,
4444
formData: FormData,
4545
options: ImageKitOptions & { authenticationEndpoint: string },
4646
callback?: (err: Error | null, response: UploadResponse | null) => void) => {
47-
try {
48-
var signaturObj = await generateSignatureToken(options.authenticationEndpoint);
49-
} catch (ex) {
50-
return respond(true, ex, callback);
51-
}
5247

53-
formData.append("signature", signaturObj.signature);
54-
formData.append("expire", String(signaturObj.expire));
55-
formData.append("token", signaturObj.token);
48+
generateSignatureToken(options.authenticationEndpoint).then((signaturObj) => {
49+
formData.append("signature", signaturObj.signature);
50+
formData.append("expire", String(signaturObj.expire));
51+
formData.append("token", signaturObj.token);
5652

57-
try {
58-
var result = await uploadFile(uploadFileXHR, formData);
59-
return respond(false, result, callback);
60-
} catch (ex) {
53+
uploadFile(uploadFileXHR, formData).then((result) => {
54+
return respond(false, result, callback);
55+
}, (ex) => {
56+
return respond(true, ex, callback);
57+
});
58+
}, (ex) => {
6159
return respond(true, ex, callback);
62-
}
60+
});
6361
}
6462

6563
export const generateSignatureToken = (

0 commit comments

Comments
 (0)