Skip to content

Instantly share code, notes, and snippets.

@guybedford
guybedford / mock-loader.mjs
Last active October 23, 2021 23:22
Node.js mocking example
const mocks = Object.create(null);
global.mock = function (_mocks) {
Object.assign(mocks, _mocks);
};
export async function resolve (specifier, context, parentResolve) {
if (mocks[specifier]) {
return { url: 'mock:' + specifier };
}
return parentResolve(specifier, context);
JSPM Project Contribution License Agreement
This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”), and conveys certain license rights to Guy Bedford, 309-3277 Quadra Street, Victoria BC, V8X 4W9 (“Assignee”) for Your contributions to JSPM open source projects. This Agreement is effective as of the latest signature date below.
1. Definitions.
“Code” means the computer software code, whether in human-readable or machine-executable form, that is delivered by You to Assignee under this Agreement.
“Project” means any of the projects owned by Assignee including both commercial and open source works and including all projects distributed under the JSPM project organization account on GitHub.
“Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any Project, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the

Keybase proof

I hereby claim:

  • I am guybedford on github.
  • I am guybedford (https://keybase.io/guybedford) on keybase.
  • I have a public key ASC0rq68wlYMNf-xXCQat7dKCBoSIMpQtcOBYpEfwBI7Zwo

To claim this, I am signing this object:

@guybedford
guybedford / exports-packages.json
Last active April 21, 2020 01:14
List of all packages in the npm registry that use the "exports" field. *Last Updated 20 April 2020 (588 packages)*
[
"@-ui/react",
"@-ui/styles",
"@acies/core",
"@adobe/leonardo-contrast-colors",
"@aduh95/viz.js",
"@advertising-all/advertising-homepage",
"@agoric/harden",
"@agoric/make-hardener",
"@ajmey/toaster",
@guybedford
guybedford / jquery.ajaxqueue.js
Created April 23, 2012 12:12
jQuery AJAX queues
/*
Allows for ajax requests to be run synchronously in a queue
Usage::
var queue = new $.AjaxQueue();
queue.add({
url: 'url',
@guybedford
guybedford / esm-wasi-integration.md
Last active June 18, 2019 12:28
ES Module WASI Integration Concerns
@guybedford
guybedford / dirserver.js
Last active September 26, 2018 12:30
Directory serving
/*
* Adapted from node-ecstatic by Joshua Holbrook:
* https://github.com/jfhbrook/node-ecstatic/tree/master/lib/ecstatic/show-dir
*/
const fs = require('graceful-fs');
const path = require('path');
const he = require('he');
const perms = ['---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx'];
@guybedford
guybedford / proposal.md
Last active November 21, 2017 06:41
ES6 Module Spec Proposal - Deferred Execution and Instantiate Normalization

Key Issues

1. No Deferred Execution for Dynamic Modules

It can be quite confusing to new users that:

<module name="test">
  define(function() {
 console.log('running');
@guybedford
guybedford / trace.js
Last active August 30, 2017 11:49
RequireJS tracer
/*
* requireJS trace
*
* Given a configuration object, as would be passed to the optimizer,
* runs a raw build trace on the configuration, returning the traced
* dependency trees.
*
* Loaded as a requirejs module on the server.
*
* eg:
@guybedford
guybedford / system-steal-plugin.js
Last active January 1, 2016 22:39
Steal Modularity Example for SystemJS
// add the steal format as the first priority check
System.formats.unshift('steal');
// create the steal format detection
var stealRegEx = /(?:^\s*|[}{\(\);,\n\?\&]\s*)steal\s*\(\s*((?:"[^"]+"\s*,|'[^']+'\s*,\s*)*)/;
System.format.steal = {
detect: function(source, load) {
var match = source.match(stealRegEx);
if (match)
return match[1] ? eval(match[1].substr(0, match[1].lastIndexOf(','))) : [];