Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert Monfera monfera

View GitHub Profile
@edankwan
edankwan / toEs6
Created Feb 26, 2021
Convert old javascript into ES6 format
View toEs6
function toEs6(script) {
return script.replace(/var/g, 'let');
}
@addyosmani
addyosmani / bytecode.md
Last active May 10, 2021
Thoughts on precompiling JS bytecode for delivery through a server/CDN
View bytecode.md

Some quick thoughts on https://twitter.com/dan_abramov/status/884892244817346560. It's not ignorant at all to ask how browser vendors approach performance. On the V8 side we've discussed bytecode precompilation challenges a few times this year. Here's my recollection of where we stand on the idea:

JavaScript engines like V8 have to work on multiple architectures. Every version of V8 is different. The architectures we target are different. A precompiled bytecode solution would require a system (e.g the server or a CDN) to generate bytecode builds for every target architecture, every version of V8 supported and every version of the JavaScript libraries or bundles bytecode is being generated for. This is because we would need to make sure every user accessing a page using that bytecode can still get the final JS successfully executed.

Consider that if a cross-browser solution to this problem was desired, the above would need to be applied to JavaScriptCore, SpiderMonkey and Chakra as well. It would need to ca

@yelouafi
yelouafi / FP_Observables.js
Last active Mar 1, 2021
Observables with pure FP
View FP_Observables.js
// Observable is an Union Type, with the following variants
const Empty = () => ['EMPTY']
const Cons = (head, tail) => ['CONS', head, tail]
const Future = promise => ['FUTURE', promise]
// race between 2 promises; each promise will resolve to a lazy value
const lazyRace = (p1, p2) => Promise.race([p1,p2]).then(lazy => lazy())
// function composition
const compose = (...fns) => (arg) => fns.reduceRight((res, f) => f(res), arg)
@mbostock
mbostock / .block
Last active Aug 31, 2020
General Update Pattern, I
View .block
license: gpl-3.0
redirect: https://observablehq.com/@d3/selection-join
@igstan
igstan / state-monad.js
Created May 1, 2011
State Monad in JavaScript
View state-monad.js
var push = function (value) {
return function (stack) {
var newStack = [value].concat(stack);
return { value:undefined, stack:newStack };
};
};
var pop = function () {
return function (stack) {
var value = stack[0];