-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdebouncing.js
More file actions
55 lines (25 loc) · 910 Bytes
/
Copy pathdebouncing.js
File metadata and controls
55 lines (25 loc) · 910 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function throttle(func,delay){
let lastCall = 0;
return function(...args){
const now = new Date().getTime();
}
}
function generateUniqueFileName(originalName){
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 9e1);
return `${uniqueSuffix}-${originalName}`;
}
console.log(new Date().getTime())
console.log(generateUniqueFileName('dennis.png'))
function getOriginalFile(x){
const nameSplittedToArray = x.split('-')
return nameSplittedToArray[nameSplittedToArray.length - 1]
}
console.log(getOriginalFile(generateUniqueFileName('dennis.png')));
fetch('https://jsonplaceholder.typicode.com/users').then(response=>{
if(!response.ok){
throw new Error('Network response was not okay')
}
return response.json();
}).then(data => console.log(data) ).catch(error=>{
console.error('Error fetching data: ',error)
})