Skip to content

Commit 72460be

Browse files
committed
fix: refactor icon package loading to use isFulfilled helper function
1 parent 0c3c713 commit 72460be

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

adminforth/modules/codeInjector.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ function hashify(obj) {
6464
return md5hash(JSON.stringify(obj));
6565
}
6666

67+
function isFulfilled<T>(result: PromiseSettledResult<T>): result is PromiseFulfilledResult<T> {
68+
return result.status === 'fulfilled';
69+
}
70+
6771
function notifyWatcherIssue(limit) {
6872
afLogger.info('Ran out of file handles after watching %s files.', limit);
6973
afLogger.info('Falling back to polling which uses more CPU.');
@@ -95,7 +99,7 @@ class CodeInjector implements ICodeInjector {
9599
await Promise.allSettled(iconPackageNames.map(async (pkg) => ({ pkg: await import(this.spaTmpPath() +'/node_modules/' + pkg), name: pkg})))
96100
);
97101

98-
const loadedIconPackages = iconPackages.filter((res) => res.status === 'fulfilled').map((res) => res.value).reduce((acc, { pkg, name }) => {
102+
const loadedIconPackages = iconPackages.filter(isFulfilled).map((res) => res.value).reduce((acc, { pkg, name }) => {
99103
acc[name.slice(`@iconify-prerendered/vue-`.length)] = pkg;
100104
return acc;
101105
}, {});

0 commit comments

Comments
 (0)