mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix(utils/index): little fix (lint)
This commit is contained in:
@ -86,12 +86,14 @@ export const startPlugin = <Config extends PluginConfig>(
|
|||||||
if (!lifecycle) return null;
|
if (!lifecycle) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// HACK: for bind 'this' to context
|
||||||
const defContext = def[options.ctx];
|
const defContext = def[options.ctx];
|
||||||
if (defContext && typeof defContext !== 'function') {
|
if (defContext && typeof defContext !== 'function') {
|
||||||
Object.entries(defContext).forEach(([key, value]) => {
|
Object.entries(defContext).forEach(([key, value]) => {
|
||||||
|
if (typeof value === 'function') {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
||||||
if (typeof value === 'function')
|
|
||||||
defContext[key as keyof typeof defContext] = value.bind(defContext);
|
defContext[key as keyof typeof defContext] = value.bind(defContext);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,14 +103,14 @@ export const startPlugin = <Config extends PluginConfig>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`[YTMusic] Executed ${id}::${options.ctx} in ${
|
'[YTMusic]', `Executed ${id}::${options.ctx} in ${
|
||||||
performance.now() - start
|
performance.now() - start
|
||||||
} ms`,
|
} ms`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`[YTMusic] Failed to start ${id}::${options.ctx}`);
|
console.error('[YTMusic]', `Failed to start ${id}::${options.ctx}`);
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -132,14 +134,14 @@ export const stopPlugin = <Config extends PluginConfig>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`[YTMusic] Executed ${id}::${options.ctx} in ${
|
'[YTMusic]', `Executed ${id}::${options.ctx} in ${
|
||||||
performance.now() - start
|
performance.now() - start
|
||||||
} ms`,
|
} ms`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`[YTMusic] Failed to execute ${id}::${options.ctx}`);
|
console.error('[YTMusic]', `Failed to execute ${id}::${options.ctx}`);
|
||||||
console.trace(err);
|
console.trace(err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user