Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change 'any' type to a safer type #17

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading