Skip to content

Instantly share code, notes, and snippets.

Avatar

Caridy Patiño caridy

View GitHub Profile
@caridy
caridy / evaluator.ts
Last active Feb 12, 2020
evaluator api proposal
View evaluator.ts
interface EvaluatorInit {
importHook(name, referrer): Promise<ParsedModule>;
isDirectEvalHook(evalFunctionRef: any): boolean;
randomHook(): number; // Use for Math.random()
nowHook(): number; // Use for both Date.now() and new Date(),
localeHook(): string; // e.g.: 'fr-FR' - Affects appropriate ECMA-402 APIs within Realm
LocalTZAHook(): string; // This is important to be able to override for deterministic testing and such
canCompileStringsHook(source: String): boolean; // mimic CSP including nounces
thisValue?: object;
}
@caridy
caridy / a.js
Last active Feb 3, 2017 — forked from dherman/a.js
a tiny userland registry, using a "parse" and "link" primitive
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:

@caridy
caridy / export-syntax.js
Last active Oct 10, 2020
ES6 Module Syntax Table
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

@caridy
caridy / README.md
Last active Dec 20, 2015
requiring optional client side dependencies on common dependencies
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
@caridy
caridy / README.md
Last active Dec 20, 2015
how to deal with vendor scripts when using `express-yui`
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
@caridy
caridy / README.md
Last active Dec 20, 2015
Patching YUI Core Modules with `express-yui`
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
@caridy
caridy / README.md
Last active Dec 20, 2015
express-routes-notes
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
You can’t perform that action at this time.