Skip to content

Commit

Permalink
fix: Change 'any' type to a safer type (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Jan 24, 2024
2 parents 9d26c02 + e5ff0f5 commit 46eed1f
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions packages/codeforces/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import { diffCodeforcesPlugin } from './diff';

export * from './constant';


async function delay(ms:number) {
return new Promise((resolve)=>{
setTimeout(resolve, ms);
});
}
const delay = async (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

export function codeforcesPlugin(option: ICPanyPluginConfig): CPanyPlugin[] {
const api = axios.create({
Expand All @@ -27,19 +22,19 @@ export function codeforcesPlugin(option: ICPanyPluginConfig): CPanyPlugin[] {
maxBodyLength: Infinity
});

let original_get = api.get;
let original_post = api.post;
(api as any).get = async function(...args: [any, any]) {
let result = await original_get(...args);
const originalGet = api.get.bind(api);
const originalPost = api.post.bind(api);
api.get = async function (...args: Parameters<typeof originalGet>) {
let result = await originalGet(...args);
await delay(800);
return result;
};
} as typeof api.get;

(api as any).post = async function(...args: [any, any, any]) {
let result = await original_post(...args);
api.post = async function (...args: Parameters<typeof originalPost>) {
let result = await originalPost(...args);
await delay(800);
return result;
};
} as typeof api.post;

const oldHandles: IHandleWithCodeforces[] = [];
const newHandles: IHandleWithCodeforces[] = [];
Expand Down

0 comments on commit 46eed1f

Please sign in to comment.