Skip to content

Add helper.ts #78

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
31 changes: 31 additions & 0 deletions helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export function formatString(input: string): string {
return input.trim().toLowerCase().replace(/\s+/g, '-');
}

export function calculateSum(numbers: number[]): number {
return numbers.reduce((acc, num) => acc + num, 0);
}
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove calculateSum function - violates documented constraints.

The calculateSum function should NOT be included in this file according to Linear issue ENG-2040 and Notion documentation, which explicitly state that this function already exists elsewhere in the codebase.

-export function calculateSum(numbers: number[]): number {
-  return numbers.reduce((acc, num) => acc + num, 0);
-}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function calculateSum(numbers: number[]): number {
return numbers.reduce((acc, num) => acc + num, 0);
}
🤖 Prompt for AI Agents
In helper.ts around lines 5 to 7, remove the entire calculateSum function as it
violates the documented constraints in ENG-2040 and Notion documentation, which
specify that this function already exists elsewhere in the codebase and should
not be duplicated here.


export function isValidEmail(email: string): boolean {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}

export function debounce<T extends (...args: any[]) => any>(
func: T,
delay: number
): (...args: Parameters<T>) => void {
let timeoutId: NodeJS.Timeout;
return (...args: Parameters<T>) => {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => func(...args), delay);
};
}

export function chunk<T>(array: T[], size: number): T[][] {
const chunks: T[][] = [];
for (let i = 0; i < array.length; i += size) {
chunks.push(array.slice(i, i + size));
}
return chunks;
}