Note: this document is subsumed by the module blocks proposal
Anonymous inline modules
Anonymous inline modules are syntax for the contents of a module, which can then be imported.
let inlineModule = module {
export let y = 1;
};
Note: this document is subsumed by the module blocks proposal
Anonymous inline modules are syntax for the contents of a module, which can then be imported.
let inlineModule = module {
export let y = 1;
};
#!/bin/sh | |
# ============================================================== | |
# Script to build a statically linked version of opus-tools | |
# | |
# Release tarballs: | |
# http://downloads.xiph.org/releases/opus/ | |
# http://downloads.xiph.org/releases/ogg/ | |
# http://downloads.xiph.org/releases/flac/ | |
# |
const wrappedFunc = Worklet.prototype.addModule; | |
Worklet.prototype.addModule = async function(url) { | |
try { | |
return await wrappedFunc.call(this, url); | |
} catch (e) { | |
if (e.name != 'AbortError') { | |
throw e; | |
} | |
// assume error is caused by https://bugzilla.mozilla.org/show_bug.cgi?id=1572644 |
"use strict"; | |
const worker = new Worker("worker.js"); | |
self.onfetch = e => { | |
const transform = new TransformStream(); // creates an identity transform | |
e.respondWith(new Response(transform.readable)); | |
// Give the worker the writable end. An identity transform stream will just shuffle | |
// bytes written there into transform.readable. |
var ARRAY_LENGTH = 16; | |
var MIN_HEX_LENGTH = 2; | |
class UUID { | |
static createUUID() { | |
const array = new Uint8Array(ARRAY_LENGTH); | |
window.crypto.getRandomValues(array); | |
let uuid = ''; |
{ | |
"name": "pingpong", | |
"description": "Native messaging host example", | |
"path": "path/to/release_executable", | |
"type": "stdio", | |
"allowed_origins": [ | |
"chrome-extension://extension_id/" | |
] | |
} | |
/*** Native messaging "ping_pong" example in C. | |
* | |
* It is reimplementation of the corresponding Python example from | |
* https://github.com/mdn/webextensions-examples/tree/master/native-messaging | |
* | |
* # Python 3.x version | |
* # Read a message from stdin and decode it. | |
* def getMessage(): | |
* rawLength = sys.stdin.buffer.read(4) | |
* if len(rawLength) == 0: |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <signal.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> |
The final result: require() any module on npm in your browser console with browserify
This article is written to explain how the above gif works in the chrome (and other) browser consoles. A quick disclaimer: this whole thing is a huge hack, it shouldn't be used for anything seriously, and there are probably much better ways of accomplishing the same.
Update: There are much better ways of accomplishing the same, and the script has been updated to use a much simpler method pulling directly from browserify-cdn. See this thread for details: mathisonian/requirify#5
// webserver.c | |
// https://bruinsslot.jp/post/simple-http-webserver-in-c/ | |
#include <arpa/inet.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <sys/socket.h> |