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
var people = (function() { | |
var people = []; | |
render(); | |
function render() { | |
var people = people; | |
console.log(people); | |
} | |
}()) |
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
console.log(1..toString()); |
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 eventEmiter, { EVENTS } from './core/bus'; | |
eventEmitter.on(EVENTS.AUTH.SUCCESS, () => {}); | |
eventEmitter.on(EVENTS.AUTH.FAILED, () => {}); | |
eventEmitter.trigger(EVENTS.AUTH.ATTEMPT, { user, pass }); |
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 EventEmitter2 from 'eventemitter2'; | |
const appBus = new eventEmitter(); | |
const EVENTS = { | |
AUTH: { | |
SUCCESS: 'AUTH.SUCCESS', | |
FAILED: 'AUTH.FAILED', | |
ATTEMPT: 'AUTH.ATTEMPT', | |
}; | |
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 eventEmiter, { EVENTS } from './core/bus'; | |
function authenticate(user, password) { | |
return new Promise((resolve, reject) => { | |
eventEmitter.on(EVENTS.AUTH.SUCCESS, resolve); | |
eventEmitter.on(EVENTS.AUTH.FAILED, reject); | |
eventEmitter.trigger(EVENTS.AUTH.ATTEMPT, { user, pass }); | |
}); | |
} |
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 eventEmiter, { EVENTS } from './core/bus'; | |
function authenticate(user, password) { | |
return new Promise((resolve, reject) => { | |
eventEmitter.once(EVENTS.AUTH.SUCCESS, resolve); | |
eventEmitter.once(EVENTS.AUTH.FAILED, reject); | |
eventEmitter.trigger(EVENTS.AUTH.ATTEMPT, { user, pass }); | |
}); | |
} |
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
async function distil(imgPath, nrOfPalettes = 2) { | |
const wasmModule = await compile('distil.wasm'); | |
const { imgBufferLocation, length } = await readImgIntoMemory(imgPath); | |
const paletteBuffer = wasmModule.exports.distil(imgBufferLocation, length); | |
console.log(bufferToHex(paletteBuffer, nrOfPalettes)); | |
} | |
// -> ['#ff1122', '#jjkkll'] |
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
rustup default nightly | |
rustup target add wasm32-unknown-unknown --toolchain nightly | |
cargo install wasm-gc |