Skip to content

Instantly share code, notes, and snippets.

View nafeu's full-sized avatar
🕶️
In Virtual Reality

Nafeu Nasir nafeu

🕶️
In Virtual Reality
View GitHub Profile
let result;
result = await delay(() => '[RETURN VALUE 1]', 1000);
console.log(result); // [RETURN VALUE 1] in result
result = await delay(() => '[RETURN VALUE 2]', 1000);
console.log(result); // [RETURN VALUE 2] in result
async function main() {
const delaysInMs = [3000, 2000, 1000];
for (const time of delaysInMs) {
const result = await delay(() => `print after ${time / 1000} second(s)`, time);
console.log(result);
}
}
main();
async function main() {
let count = 0;
const max = 5;
while (count < max) {
const result = await delay(() => `${++count} of ${max} lines...`, 1000);
console.log(result);
}
}
<!DOCTYPE html>
<html>
<head>
<title>Snowpack Skypack React</title>
</head>
<body>
Hello World.
</body>
</html>
import React from 'https://cdn.skypack.dev/react';
import ReactDOM from 'https://cdn.skypack.dev/react-dom';
const App = () => {
return (
<h1>Hello World x2</h1>
);
}
ReactDOM.render(<App />, document.getElementById("root"));
<!DOCTYPE html>
<html>
<head>
<title>Snowpack Skypack React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="main.js"></script>
</body>
</html>
/* Section: Dependencies */
/* Section: Constants */
/* Section: Interfaces and Globals */
/* Step 0: Grab CLI arguments */
/* Step 1: Parse metadata and components from markdown file */
/* Step 0: Grab CLI arguments */
const filename = Deno.args[FIRST_ITEM_INDEX];
const buildPath = Deno.args[SECOND_ITEM_INDEX] || './build';
if (!filename) {
console.log('Please specify .md file');
Deno.exit(1);
} else {
console.log(`Building site with '${filename}' into '${buildPath}'`);
}
/* Section: Interfaces and Globals */
interface Page {
path: string,
name: string,
html: string
}
interface Layout {
[key: string]: any
}
/* Section: Dependencies */
import { Marked } from 'https://deno.land/x/markdown@v2.0.0/mod.ts';
import { ensureFileSync } from 'https://deno.land/std@0.84.0/fs/mod.ts';