Get started with pleasejs CDN
MIT licensed
Lightweight library: Pleas.js handles async tasks in JS via callbacks, promises.
Tags:- color
- scheme
- random
Stable version
Copied!
How to start using pleasejs CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with pleasejs CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/pleasejs/0.4.2/Please.min.js"></script>
</head>
<body>
<button id="promiseButton">Click me</button>
<script>
const promiseButton = document.getElementById('promiseButton');
promiseButton.addEventListener('click', () => {
Please.promise((resolve, reject) => {
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
const randomNumber = Math.floor(Math.random() * 10) + 1;
if (randomNumber > 5) {
resolve(randomNumber);
} else {
reject(new Error('Random number is less than 5'));
}
}, 1000);
});
promise.then(value => {
console.log(`Random number: ${value}`);
}).catch(error => {
console.error(error.message);
});
});
});
</script>
</body>
</html>
Copied!
Copied!