View test.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<title>Worker example</title> | |
</head> | |
<body> | |
<main id="mount"></main> | |
<script src="http://localhost:8080/packages/diffhtml/dist/diffhtml.min.js"></script> | |
<script src="./packages/diffhtml-middleware-worker/dist/worker.js"></script> |
View visible-proxy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeVisibleProxy() { | |
const obj = {}; | |
// Own keys must be known ahead of time for this to work | |
const keys = ['key1', 'key2']; | |
// Map each known key to the obj, but make the getter "lazy" | |
keys.forEach(keyName => { | |
const desc = { | |
configurable: true, |
View game-of-life.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const grid = buildGrid(20, 50, [ | |
(10 * 50) + 20, | |
(10 * 50) + 21, | |
(10 * 50) + 22, | |
(10 * 50) + 23, | |
(10 * 50) + 24, | |
(10 * 50) + 25, | |
(10 * 50) + 26, | |
(10 * 50) + 27, | |
(10 * 50) + 28, |
View diffhtml.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { innerHTML, html } from 'https://unpkg.com/diffhtml/dist/es'; | |
let a = 1; | |
let b = 2; | |
const updateA = ({ target }) => (a = Number(target.value), render()); | |
const updateB = ({ target }) => (b = Number(target.value), render()); | |
function render() { | |
innerHTML(document.body, html` |
View awhat.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makePromise() { | |
return new Promise(() => {}); | |
} | |
async function main() { | |
console.log('start'); | |
await makePromise(); | |
console.log('end'); | |
} |
View console-react.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Console = props => { | |
for (let method in console) { | |
if (method in props) { | |
console[method](props[method]); | |
} | |
} | |
return <></>; | |
}; |
View hook-class.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, Component } from 'react'; | |
class MyComponent extends Component { | |
render() { | |
const [ count, setCount ] = this.state; | |
return ( | |
<div>{count}</div> | |
); | |
} |
View webapp.config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"builds": [{ | |
"input": "lib/**/*.js", | |
"output": "dist/esm", | |
"outputType": "module", | |
"debug": true | |
}, { | |
"input": "lib/**/*.js", | |
"output": "dist/cjs", | |
"outputType": "commonjs", |
View events.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bus = {}; | |
const get = e => (bus[e] = bus[e] || new Set()); | |
export const listeners = new Proxy(bus, { get }); | |
export const emit = (e, ...args) => listeners[e].forEach(fn => fn(...args)); |
View cjs-treeshake.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('will treekshake a static named import', async () => { | |
const input = register('./a')` | |
const { a } = require('./b'); | |
console.log(a); | |
`; | |
register('./b')` | |
function b() {} | |
exports.a = 'hello world'; |
NewerOlder