MCPcopy Create free account
hub / github.com/azat-co/practicalnode / myAsyncTimeoutFn

Function myAsyncTimeoutFn

code/ch14/promise/basic-promise-2.js:1–16  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

1function myAsyncTimeoutFn(data) {
2
3 let _callback = null
4
5 setTimeout( () => {
6
7 if ( _callback ) _callback()
8 }, 1000)
9
10 return {
11 then(cb){
12 _callback = cb
13 }
14 }
15
16}
17
18myAsyncTimeoutFn('just a silly string argument').then(() => {
19 console.log('Final callback is here')

Callers 1

basic-promise-2.jsFile · 0.70

Calls 1

_callbackFunction · 0.85

Tested by

no test coverage detected