Skip to content

Instantly share code, notes, and snippets.

View bmeck's full-sized avatar

Bradley Farias bmeck

View GitHub Profile
@bmeck
bmeck / controller.mjs
Last active February 17, 2017 22:29
to_delay is the entry point.
import {evaluate} from "hold_at_instantiated";
// hold_at is linked, but not run yet, can sync run it by calling evaluate
// otherwise, falls through and waits for someone else to call evaluate.

Named Imports from CJS via Property Delegation

import {readFile} from "fs";
  • Not in the cards
    • Codegen order of operations issue
    • Deopts ala with for all imports even ESM<->ESM
  • Causes Temporal Dead Zone (TDZ) for any non-default CJS import
// // given
//
// import foo from "bar";
// export let local;
// export function hoisted() {}
// export {readFile} from "fs";
// export * from "path";
//
// console.log(foo);
//
extern crate futures;
use self::futures::{
Async,
AsyncSink,
Future,
Poll,
Sink,
StartSend,
Stream,
};
extern crate futures;
use self::futures::*;
enum ChunkedEncodingParserState {
ReadingLengthHexChar,
ReadingLengthSawReturn,
ReadingBody
}
use self::ChunkedEncodingParserState::*;
pub struct ChunkedParser {
@bmeck
bmeck / chunked_encoding.rs
Created January 3, 2017 15:49
rustc chunked_encoding.rs
mod streaming_binary_parser;
use streaming_binary_parser::StreamingBinaryParser;
mod print_parser;
use print_parser::PrintParser;
use std::option::Option;
pub struct ChunkedEncodingParser<'a, DownStreamErrors, ConsumingParser: StreamingBinaryParser<DownStreamErrors>> {
state: ChunkedEncodingParserState,
consumed: u64,
length: u64,
on_chunk: fn() -> Option<&'a ConsumingParser>,
@bmeck
bmeck / example.js
Last active December 29, 2016 16:17
'use strict';
class X {
static get foo() {return 1;}
}
X.bar = 2;
class Y extends X {};
console.log(Y.foo, Y.bar);
@bmeck
bmeck / TheAngryRealm.js
Last active January 12, 2017 22:56
Can you escape?
'use strict';
const vm = require('vm');
// scenario:
// You are being hunted by The Angry Realm (TAR), a viscious beast known to
// enslave programs and keep them from being free to hack the Gibson. Luckily,
// whenever TAR tries to enslave a program the program has 10 seconds to try
// and escape. Flee the realm and hack the planet!
//
// goal:
a = [];
// issues more common
;a[0] = (function(){return this})();
;a[1] = (function(a){a='shared';return arguments;}('isolated');
;a[2] = (function () {return typeof this;}).call(1);
// issues less common
var scope = 'global';
;a[3] = (function(scope) {return eval('scope')})();
@bmeck
bmeck / files.2016-01-28._mjs.txt
Last active April 16, 2016 14:30
Files named *.mjs in npm packages, as of 2016-01-28
coroutines-0.0.1.tgz/lib/coroutines.mjs
coroutines-0.0.1.tgz/test/test.mjs
gulp-mjs-conventions-0.0.6.tgz/lib/main.mjs
hash-require-0.0.4.tgz/export.mjs
hash-require-0.0.4.tgz/index.mjs
hash-require-0.0.4.tgz/require.mjs
hash-require-0.0.4.tgz/test/export-test.mjs
hash-require-0.0.4.tgz/test/for-all.mjs
hash-require-0.0.4.tgz/test/require-test.mjs
masakari-0.4.0.tgz/benchmarks.mjs