Instantly share code, notes, and snippets.

View a.js
import {b} from "./b.js";
import $ from "jquery";
export function a() {
// ...
}
View reflect-global.md

Updated (Aug 2nd, 2016)

API Refinements:

  • The default global scope when creating a new realm has no extra capabilities, it is confusing, we can remove it.
  • The realm object is the real power object, and users can decide to share it or not via endowments.
  • In a realm, you can create as many global scopes as you want via realmObj.createNewGlobalScope().
  • No more proxy-like API at the realm level, if you want to proxy a global, that should be used when creating a new global scope.

The API proposal:

View export-syntax.js
// default exports
export default 42;
export default {};
export default [];
export default foo;
export default function () {}
export default class {}
export default function foo () {}
export default class foo {}
View resolve-caller-script.js
/* global HackToInferCallerFilename */
'use strict';
var REGEX_CALLER_FILENAME = /\(([^:]+)\:\d+\:\d+\)/g;
module.exports = function () {
var filename;
try {
HackToInferCallerFilename;
View gist:10500131

Proposal for Extending Express Apps

Creating npm packages which extend the functionality of Express apps has become a major thing we've been doing. There are several approaches we can take, from messing with the Express object prototypes, to creating a function in which an express app is passed in. After trying the former, I'm now a fan of the latter.

The Issues with Extending Express

Extending the Express object prototypes has issues. The running Node.js process may have multiple versions of express, and in order to extend the prototypes you need to require('express'). This means that you might get a different express module instance than the one the main app is created from.

Both approaches suffer from extending something more than once. Similar to how there may be multiple version of express in the running Node.js process, there can also be multiple copies of the extension modules. If the app developer needs to rely on a different version of an Express ext

View README.md

What is this?

This is a gist to showcase how to have client affinity modules that are required by common affinity modules without breaking the app when trying to use the common affinity modules on the server side.

Instalation

npm install
node app.js
View README.md

What is this?

This is a gist to showcase how to deal with vendor scripts when using express-yui, in this particular case, loading jquery as a yui module.

Instalation

npm install
node app.js
View README.md

What is this?

This is a gist to showcase how to patch a yui core module when using express-yui, in this particular case, patching the router module by defining a new module router-patched as a replacement for the original module core module router.

Instalation

npm install
node app.js
View README.md

What is this?

This is a prototype for the low-level api to serialize express routes into the client side.

Installation

npm install
node simple.js
node complex.js
View README.md

What is this?

This is a script that you can add to your application to generating yui meta data and compiling yui modules using express-yui and locator. As a result, a build folder will be generated with everything that was compiled.

How does this work?

Locator walks the folder structure for your app, and finds any yui module, including build.json or just traditional *.js files with the corresponding YUI.add() statement. Generating the result of the operation as well as the metadata associated to each module.

Under the hood, it uses shifter to generate almost everything that is needed.