Get started with q.js CDN
MIT licensed
Q.js: Library for writing async JS with deferred, promised objects.
Tags:- q
- promise
- promises
- promises-a
- promises-a-plus
- deferred
- future
- async
- flow control
- fluent
- browser
- node
Stable version
Copied!
How to start using q.js CDN
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.cdnhub.io/q.js/1.5.1/q.min.js"></script>
<title>Get started with q.js CDN - cdnhub.io</title>
</head>
<body>
<button id="promiseButton">Click me</button>
<script>
const promiseButton = document.getElementById('promiseButton');
promiseButton.addEventListener('click', () => {
const deferred = Q.defer();
// Simulate an asynchronous operation
setTimeout(() => {
const result = Math.random();
deferred.resolve(result);
}, 1000);
// Get the promise and handle its result
const promise = deferred.promise;
promise.then((value) => {
console.log(`Random number: ${value}`);
});
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
All versions
0.0.0
0.0.1
0.0.2
0.0.3
0.1.0
0.1.1
0.4.0
0.4.1
0.4.2
0.4.4
0.5.0
0.5.1
0.5.2
0.5.3
0.6.0
0.7.0
0.7.1
0.7.2
0.8.0
0.8.1
0.8.10
0.8.11
0.8.12
0.8.2
0.8.3
0.8.4
0.8.5
0.8.6
0.8.7
0.8.8
0.8.9
0.9.0
0.9.1
0.9.2
0.9.3
0.9.4
0.9.5
0.9.6
0.9.7
1.0.0
1.0.1
1.1.0
1.1.1
1.1.2
1.2.0
1.2.1
1.3.0
1.4.0
1.4.1
1.5.0
*** 1.5.1
2.0.0
2.0.1
2.0.2
2.0.3