-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 785 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 785 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
import { ExternalApiClient } from './src/externalApiClient.js';
import { MyClass } from './src/myClass.js';
const externalAPIClient = new ExternalApiClient();
const myClassObj = new MyClass(externalAPIClient);
console.time('First call')
await myClassObj.myMethod();
console.timeEnd('First call')
console.time('Second call')
await myClassObj.myMethod();
console.timeEnd('Second call')
console.time('Third call')
await myClassObj.myMethod();
console.timeEnd('Third call')
console.time('Forth call')
await myClassObj.myMethod();
console.timeEnd('Forth call')
//Only one request is executed in this promise list thanks to the batching strategy used by the lib
await Promise.all([
myClassObj.myMethod(),
myClassObj.myMethod(),
myClassObj.myMethod(),
myClassObj.myMethod(),
])