View polymorphism-access.js
const N = 10000;
const FOO = 'foo';
function test(fn) {
var result;
for (var i = 0; i < N; ++i) result = fn();
return result;
}
test(x => x);
View worker.html
<script id="worker" type="worker">
importScripts('https://unpkg.com/dio.js')
const shared = {memory: {}, address: 0}
const allocateMemory = (object) => {
shared.memory[shared.address] = object
return shared.address++
}
View ast.js
function Stack () {
this.next = this
this.prev = this
this.length = 0
}
Stack.prototype = {
/**
* @param {Object} node
* @param {Object} before
View interface.ts
interface Virtual {
merge(Virtual)
}
interface VirtualStyle extends Virtual {
merge(VirtualStyle)
}
interface VirtualProperties extends Virtual {
style: VirtualStyle
View talk.md

A Journey Into Building a Fast Text Editor With JS & Canvas!

Text editors have a way of looking simple but managing and painting text is no small task, this talk will give us a look into what bits(literaly) and pieces go into making a fast text editor with Javascript & Canvas. We'll look into what format the text you type is stored in, how it's mutated and highlighted, and how all of this is translated onto a canvas in less than the time it takes you to blink. As a by product we'll get to see how a regular expression engine is implementated and why games use draw distance to save precious hardware resources.

View VDOM-impl.js
var length = 1024*100; // enough to store 100kb of instrutions at any time
var action = new Uint8Array(length);
var memory = new Array(length);
// action carry instructions with pointers to memory for where to find the nodes to act on
// memory carries nodes that exist in memory
// for example
View frameScheduler.js
function frameScheduler (fps) {
var highPriWork = [];
var lowPriWork = [];
var highPriWorkLen = 0;
var lowPriWorkLen = 0;
var frameBudget = 1000 / fps;
var lastTime = 0;
var asyncCallback;
var Promise = window.Promise;
View frameLoop.js
/**
* @param fn {Function} Callback function to trigger on frame
* @param fps {int} Target FPS
* @returns {{pause: pause, start: start, destroy: destroy}}
*/
function frameLoop(fn, fps=60) {
let then = 0;
let interval = 1000 / fps;
let isRunning = true;
let currentFrameId = null;
View urlstore.js
param: function (obj, prefix) {
var arr = [];
for (var key in obj) {
var __prefix = prefix ? prefix + '[' + key + ']' : key,
value = obj[key];
arr.push(typeof value == 'object' ?
param(value, __prefix) :
encodeURIComponent(__prefix) + '=' + encodeURIComponent(value));
}
View camelCase.js
function camelCase (string, separator) {
return string.split(separator).map((word, index) => word.substr(0,1)[index ? 'toUpperCase' : 'toLowerCase']() + word.substr(1) ).join('');
}
console.log(camelCase('metal gear solid', ' '));
// metalGearSolid
function undoCamelCase (string, separator) {
return string.split('').map((letter) => letter.toLowerCase() !== letter ? separator + letter.toLowerCase() : letter).join('');
}