Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@Raynos
Raynos / Readme.md
Created April 4, 2013 21:09 — forked from Gozala/Readme.md

Signal

Signal represents collection of values (over time) associated with a single identity. It can be expressed as follows:

function signal(next) {
  next(1)
  next(2)
 next(3)
// A pull stream is a function readable(closing, cb<err, chunk>)
// To extract a chunk out of the stream simply call (null, cb)
// to get another value call it again.
// The stream will tell you if it's ended by invoking cb(true)
// The stream will tell you if it errored by invoking cb(Error)
// You can tell the stream to close / destroy by calling stream(true, cb)
var stream = (function () {
var list = [1, 2, 3, 4]
return function stream(closing, callback) {
@Raynos
Raynos / callbacks.js
Last active August 18, 2022 22:25 — forked from wycats/promises.js
// The well-known callback pattern
fs.mkdir("some-path", function(err) {
fs.open("some-path/file", "w", function(err, fd) {
var buffer = new Buffer("hello world")
fs.write(fd, buffer, 0, buffer.length, null, function(err, bytes) {
console.log("Wrote " + bytes + " bytes")
})
})
})
var lines = require('line-stream')
, through = require('through')
, emit = require('emit-function')
, duplex = require('duplex')
module.exports = json
function json(transport) {
var input = through(write)
, output = through(recv)
@Raynos
Raynos / index.js
Last active December 14, 2015 04:29
var parseScope = require('lexical-scope');
var browserResolve = require('browser-resolve');
var commondir = require('commondir');
var through = require('through');
var mdeps = require('module-deps');
var path = require('path');
var processModulePath = require.resolve('process/browser.js');
module.exports = function (files, opts) {
@Raynos
Raynos / cursorapi.js
Last active December 11, 2015 09:48 — forked from sergioramos/cursorapi.js
var WriteStream = require("write-stream")
var toArray = require("write-stream/array")
/************************************** A *************************************/
db.readStream().pipe(WriteStream(function write(data) {
assert.equal(data, {
value: 'value',
key: 'key'
})
@Raynos
Raynos / nonuby.jade
Created January 13, 2013 07:14 — forked from tony-o/nonuby.jade
-var pad = function(decimal){ return decimal.toFixed(2); };
h2 Hi NoNuby
div!= pad(locals.val1);
div!= pad(locals.val2);
@Raynos
Raynos / assert.js
Last active December 10, 2015 13:19
var assert = require("TAP-winning/assert")()
assert.equal() ...
setTimeout(function () {
assert.end()
}, 1000)
pipe(stream('water'), [
stream('bathroom'), [
stream('sink'),
stream('toilet')
],
stream('kitchen'), [
stream('sink'),
stream('dishwasher')
],
])