Skip to content

Instantly share code, notes, and snippets.

View isaacs's full-sized avatar
🔮
only way out is through

isaacs isaacs

🔮
only way out is through
View GitHub Profile
@isaacs
isaacs / foo.js
Created February 7, 2011 21:50 — forked from niklasfi/foo.js
module.exports = Foo;
//now i would like to have a constructor function for the foo "class" (i know in JS that does not exist)
//with normal js this would be
function Foo(arg1,arg2){
this.something = arg1;
this.somethingOther = arg2;
}
@isaacs
isaacs / gist:620979
Created October 11, 2010 18:24 — forked from mikeal/gist:620021
diff --git a/lib/stream.js b/lib/stream.js
index 189708a..37687b0 100644
--- a/lib/stream.js
+++ b/lib/stream.js
@@ -53,3 +53,22 @@ Stream.prototype.pipe = function (dest, options) {
if (source.readable) source.resume();
});
};
+
+exports.createFilter = function (listener) {
diff --git a/lib/module.js b/lib/module.js
index 72814a7..1db1cb4 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -83,17 +83,6 @@ var pathFn = process.compile("(function (exports) {" + natives.path + "\n})",
var pathModule = createInternalModule('path', pathFn);
var path = pathModule.exports;
-function existsSync (path) {
- try {
@isaacs
isaacs / module.patch
Created August 4, 2010 20:48 — forked from nickstenning/dirs.patch
module.patch
diff --git a/lib/module.js b/lib/module.js
index 72814a7..0827d13 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -83,17 +83,6 @@ var pathFn = process.compile("(function (exports) {" + natives.path + "\n})",
var pathModule = createInternalModule('path', pathFn);
var path = pathModule.exports;
-function existsSync (path) {
- try {
fromAll("foo","bar","baz","widget", function(foo, bar, baz, widget){
var myThing
// Actual library code
return myThing
})
@isaacs
isaacs / router.js
Created July 22, 2010 17:11 — forked from pgriess/router.js
var HTTPParser = process.binding('http_parser').HTTPParser;
var net = require('net');
var path = require('path');
var sys = require('sys');
var Worker = require('webworker').Worker;
var VHOSTS = ['foo.bar.com', 'baz.bizzle.com'];
var WORKERS = {};
VHOSTS.forEach(function(vh) {
var crypto = require('crypto');
["sha1", "md5", "sha256", "sha512", "ripemd160"].forEach(function(algo) {
exports[algo] = function(data, salt) {
return crypto["createH"+(typeof salt != 'undefined' ? "mac":"ash"](algo,salt)
.update(data).digest("hex");
};
});
var sys = require('sys'),
crypto = require('crypto'),
algos = ["sha1", "md5", "sha256", "sha512", "ripemd160"],
encoding = "hex";
algos.forEach( function( algo) {
exports[ algo ] = function(data, salt) {
return (typeof salt === 'undefined')
? crypto.createHash(algo).update(data).digest(encoding)
: crypto.createHmac(algo, salt).update(data).digest(encoding)
function readAllHelps (cb) {
var help_text = []
, didError = false
function error (er) {
if (didError) return undefined
didError = true
cb(er)
}
fs.readdir('help', function(er, files) {
if (err) return error(er)
var n = 45
, sys = require("sys")
sys.puts(typeof n); // number
sys.puts(n instanceof Number); // false
var m = Number(45);
sys.puts(typeof m); // number