Skip to content

Instantly share code, notes, and snippets.

View bmeck's full-sized avatar

Bradley Farias bmeck

View GitHub Profile
Let us see the response to: "Street Fighter the movie has a better plot than Street Fighter the game."
@bmeck
bmeck / example.md
Last active June 27, 2018 21:57 — forked from jamiebuilds/example.md
`/my-website/` - `package.json`
`/src/`
`/pages/` - `index.html` - `about.html`
`/assets/` - `site.css` - `site.js`
@bmeck
bmeck / bus.js
Created June 23, 2018 13:51
it is a better API at least
// Example way to construct a Bus
//
// const ctrl = new SharedArrayBuffer(12);
// const size = new SharedArrayBuffer(4);
// let busSize = 4096;
// const data = new SharedArrayBuffer(busSize);
// const bufs = {ctrl,size,data,};
// const bus = new Bus(bufs);
'use strict';
@bmeck
bmeck / commands.js
Last active June 29, 2018 15:44
Show fs.readFile callback acting as if it was sync in another thread (naive impl)
module.exports = {
__proto__: null,
START: 0,
WORKER_READY: 2,
BUS_READY: 3,
BUS_DRAINED: 4,
BUS_END: 5,
WORKER_ERROR: 6,
};
console.log('hi');
module.exports = 123;
{
async resolve() {
const dep = vm.Module('export let a = 0; ({set a(v) {a = v;} get a() {return a;}})');
dep.onEvaluated((ns, reflect) => {
setInterval(() => reflect.a++, 1000);
});
return dep;
}
}
<!doctype html>
<html>
<style>
.screenreader-only {
position: absolute;
display: block;
left: -1px;
top: -1px;
width: 1px;
height: 1px;
@bmeck
bmeck / construction-private.md
Last active March 29, 2018 13:32
some simple examples of out of class private. It can be used only lexically and cannot be stored into a variable. EVERYTHING HERE IS BIKESHED
// allocate a private field key
private #constructedHere;

export let create = () => {
  return {
    // cannot be used in computed properties
    // #constructedHere is not a variable with a reified value
    #constructedHere: true
 };

ESM do not have a way to setup modules that are aliases of other modules

ESM in in browsers cannot reliably use export * from to act as an alias since it may alter the shape of the namespace they are importing, nor can they use HTTP redirects which are treated as new module records.

Adding default to the list of exports from export * from has been revisted and rejected. I have to take extra effort to use export * reliably as a means to create pass through modules. Typically involving resolving, fetching, and parsing the source text of a dependency outside of VM control. This can be seen in projects where I am invoking http/file access and parsing to AST to figure out if the module being delegated to has a default.

In addition using export * is also not suitable to be used

File API

** bikeshed **

fs.getFile(url) - https://developer.mozilla.org/en-US/docs/Web/API/File

Can be used by loaders/servers if they wish to request information about the file's MIME as file.type.

It will get the .type by checking the context for the current MIME DB, falling back to the globally MIME DB.