Vitepress

This commit is contained in:
Robert Jelic
2025-02-10 06:53:23 +01:00
parent 3818128521
commit b0a4a6da9c
2428 changed files with 1005324 additions and 0 deletions

29
node_modules/shiki/samples/javascript.sample generated vendored Normal file
View File

@@ -0,0 +1,29 @@
function resolveAfter2Seconds(x) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(x);
}, 2000);
});
}
// async function expression assigned to a variable
const add = async function (x) {
const a = await resolveAfter2Seconds(20);
const b = await resolveAfter2Seconds(30);
return x + a + b;
};
add(10).then((v) => {
console.log(v); // prints 60 after 4 seconds.
});
// async function expression used as an IIFE
(async function (x) {
const p1 = resolveAfter2Seconds(20);
const p2 = resolveAfter2Seconds(30);
return x + (await p1) + (await p2);
})(10).then((v) => {
console.log(v); // prints 60 after 2 seconds.
});
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function