Skip to content

Instantly share code, notes, and snippets.

View tim-smart's full-sized avatar

Tim tim-smart

View GitHub Profile
[06:03] Tim_Smart: isaacs: You think I should have registerExtension enabled to return not just javascript strings?
[06:03] isaacs: Tim_Smart: i think i suggested that registerExtension should return a javascript function representing the module
[06:04] Tim_Smart: isaacs: Meaning, you can return a function or something?
[06:04] Tim_Smart: isaacs: Well, I don't want to re-implement the module system
[06:04] isaacs: Tim_Smart: i see, so you don't want to return a javascript function, and instead want the existing module system to wrap the js string in the process.compile cruft?
[06:05] isaacs: i guess that makes sense.
[06:05] Tim_Smart: atm, it only accepts a string as a return, and puts it through the same paces as the other JS modules
[06:05] isaacs: right
[06:05] Tim_Smart: But, it would be awesome if you didn't return a string, it directly attaches it to the exports
[06:05] isaacs: i guess i'm just thinking of a case where maybe you want to actually compile the thing to a function, because it's not using p
for (name in test) {
(function(name) {
// name is contained
})(name);
}
Haml: require './lib/haml'
require.registerExtension '.haml', (content) ->
content: Haml.compile content
(options) ->
compiled: if true is options.optimize then Haml.optimize content else content
Haml.execute compiled, options.context, options.locals
# Sexy templating begins
html: require('mytemplate') {
var result = document.evaluate('.//text()',
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null),
textNode,
i = 0;
while (textNode = result.snapshotItem(i++)) {
textNode.textContent = textNode.
var CoffeeScript = require('/usr/local/lib/coffee-script/lib/coffee-script');
require.registerExtension('.coffee', function(source) {
return CoffeeScript.compile(source);
});
require('zmodule');
var Parallel = exports.Parallel = function Parallel(actions) {
if ('object' === typeof actions) {
var keys = Object.keys(actions);
for (var i = 0, key; key = keys[i++]; ) {
this.add(key, actions[key]);
}
}
return this;
};
var Parallel = exports.Parallel = function Parallel(actions) {
this.actions = {};
this._emitter = new process.EventEmitter();
if ('object' === typeof actions) {
var keys = Object.keys(actions);
for (var i = 0, key; key = keys[i++]; ) {
this.add(key, actions[key]);
}
}
var Parallel = require('./parallel'),
Step = require('./step'),
fs = require('fs');
var task = new Parallel({
one: [fs.stat, '/etc/passwd'],
two: [fs.stat, '/hello/world']
});
var otherTask = new Parallel({
var namespace = (function() {
// Code that defines 'test' and 'foo'
return {
test: test,
foo: foo
};
})();
// Get the image
var image = document.getElementById('douglas'),
// Make a canvas
canvas = document.createElement('canvas'),
data;
canvas.height = image.height;
canvas.width = image.width;
// Put image on canvas
canvas.getContext('2d').drawImage(image, 0, 0);