forked from github/copilot-cli-for-beginners
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelpers.js
More file actions
37 lines (31 loc) · 682 Bytes
/
Copy pathhelpers.js
File metadata and controls
37 lines (31 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Utility helper functions
* Used throughout the application for common operations
*/
function formatDate(date) {
return date.toISOString().split('T')[0];
}
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
function debounce(fn, delay) {
let timeoutId;
return function (...args) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => fn.apply(this, args), delay);
};
}
// TODO: Add input validation
function parseJSON(str) {
return JSON.parse(str);
}
function generateId() {
return Math.random().toString(36).substring(2, 9);
}
module.exports = {
formatDate,
capitalize,
debounce,
parseJSON,
generateId
};