Originally from an email, gisted here for posterity:
I was able to remember the example where "naive" 1:1 module transpilation fails:
npm version patch && git push --follow-tags | |
npm publish |
function makeRequest(url) { | |
fetch(url) | |
.then(response => response.json()) | |
.then(json => it.next(json)) | |
.catch(error => console.error('Somthing shit the bed', error)); | |
} | |
function *syncRequests() { | |
const redditUrl = 'https://www.reddit.com/controversial.json?count=1&limit=2'; | |
const page1 = yield makeRequest(redditUrl); |
I wrote a bunch of utility helpers for graphing data with pie charts, bar charts, scatter plots and histograms.
It reutilices many examples from [d3.org][d3.org], so many that I lost track of them all. I have only tested on d3's v3.
module Auth0 | |
( AuthenticationState(..), AuthenticationError, AuthenticationResult | |
, Options, defaultOpts | |
, LoggedInUser, UserProfile, Token | |
, showLock, showLockSignal | |
, mapResult | |
) where |
function* zip(...iterables) { | |
let iterators = iterables.map(i => i[Symbol.iterator]()); | |
while (true) { | |
let entries = iterators.map(i => i.next()); | |
let done = entries.some(entry => entry.done); | |
if (done) break; | |
yield entries.map(e => e.value); | |
} | |
} |
{ | |
"ignore": [ | |
"**/deps/**", | |
"**/node_modules/**", | |
"**/thirdparty/**", | |
"**/third_party/**", | |
"**/vendor/**", | |
"**/**-min-**", | |
"**/**-min.**", | |
"**/**.min.**", |
Years ago, some smart folks that worked on JS engines realized that not all JS that's loaded into a page/app initially is needed right away. They implemented JIT to optimize this situation.
JIT means Just-In-Time, which means essentially that the engine can defer processing (parsing, compiling) certain parts of a JS program until a later time, for example when the function in question is actually needed. This deferral means the engine is freer to spend the important cycles right now on the code that's going to run right now. This is a really good thing for JS performance.
Some time later, some JS engine devs realized that they needed to get some hints from the code as to which functions would run right away, and which ones wouldn't. In technical speak, these hints are called heuristics.
So they realized that one very common pattern for knowing that a function was going to run right away is if the first character before the function
keyword was a (
, because that usually m
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share} |
/* So how does this work? | |
I'm using ANSI escape sequences to control the behavior of the terminal while | |
cat is outputting the text. I deliberately place these control sequences inside | |
comments so the C++ compiler doesn't try to treat them as code.*/ | |
//[2K[2D[A[2K[A[2K[A[2K[A[2K[A | |
/*The commands in the fake code comment move the cursor to the left edge and | |
clear out the line, allowing the fake code to take the place of the real code. | |
And this explanation uses similar commands to wipe itself out too. */ | |
//[2K[2D[A[2K[A[2K[A[2K[A | |
#include <cstdio> |