aboutsummaryrefslogtreecommitdiff
path: root/webAO/utils/getAnimLength.js
diff options
context:
space:
mode:
authorstonedDiscord <stonedDiscord@users.noreply.github.com>2024-11-20 13:04:14 +0000
committerGitHub Action <actions@github.com>2024-11-20 13:04:14 +0000
commitb8283b373caa2ac198497a8dd466bf494d81982a (patch)
tree23de734e7ab5c093ace1d1a8fec716bb7603bdbf /webAO/utils/getAnimLength.js
parent376fadcca3a1b5c32a3361b2843c6c576237a1a3 (diff)
Prettified Code!
Diffstat (limited to 'webAO/utils/getAnimLength.js')
-rw-r--r--webAO/utils/getAnimLength.js34
1 files changed, 17 insertions, 17 deletions
diff --git a/webAO/utils/getAnimLength.js b/webAO/utils/getAnimLength.js
index 2d83844..ac673c2 100644
--- a/webAO/utils/getAnimLength.js
+++ b/webAO/utils/getAnimLength.js
@@ -2,26 +2,26 @@
/* eslint no-restricted-syntax: "off" */
/* TODO: use promises for this */
-import calculatorHandler from './calculatorHandler';
-import fileExists from './fileExists';
-import { requestBuffer } from '../services/request';
+import calculatorHandler from "./calculatorHandler";
+import fileExists from "./fileExists";
+import { requestBuffer } from "../services/request";
/**
- * Gets animation length. If the animation cannot be found, it will
- * silently fail and return 0 instead.
- * @param {string} filename the animation file name
- */
+ * Gets animation length. If the animation cannot be found, it will
+ * silently fail and return 0 instead.
+ * @param {string} filename the animation file name
+ */
const getAnimLength = async (url) => {
- const extensions = ['.gif', '.webp', '.apng'];
- for (const extension of extensions) {
- const urlWithExtension = url + extension;
- const exists = await fileExists(urlWithExtension);
- if (exists) {
- const fileBuffer = await requestBuffer(urlWithExtension);
- const length = calculatorHandler[extension](fileBuffer);
- return length;
- }
+ const extensions = [".gif", ".webp", ".apng"];
+ for (const extension of extensions) {
+ const urlWithExtension = url + extension;
+ const exists = await fileExists(urlWithExtension);
+ if (exists) {
+ const fileBuffer = await requestBuffer(urlWithExtension);
+ const length = calculatorHandler[extension](fileBuffer);
+ return length;
}
- return 0;
+ }
+ return 0;
};
export default getAnimLength;