blog.gvm-it.eu
Introduction to the node.js EventEmitter

When you start learning node.js you soon stumble upon something called EventEmitter. The following post covers how the built-in EventEmitter works, how you can use and why it is so useful.

Read More

Extract newline seperated messages from a stream

In node.js, you are often confronted with streams that you may want to send and recieve data over. The following post provides and explains a small helper function that allows you to extract newline-separated messages from a node.js stream.

Read More

Callback conventions in node.js, how and why

When first confronted with node.js, you are not only presented with a completely new programming environment. You also encounter what is often referred to as callback hell accompanied by weird unfamiliar programming patterns. One of these is the way node treats callback functions.

The following post explains the conventions that node.js uses for its callback patterns (referred to as Continuation-passing style) and how you should implement them in order to comply.

Read More

Register all routes in a folder for your express server

Given the following problem: You have an express based webserver and you have stored all your routes in seperate files in one folder, perhaps even organized into several subfolders. You now want an easy way to apply all routes with as little effort as possible..

Meet node-walker: This little module let’s you crawl a subfolder and perform a callback on each filename that it encounters, including files in subdirectories.

Read More

How to: Heredocs in JavaScript

The following code allows you to define multi line strings in your JavaScript code. However, it is not cross-browser compatible - some implementations will return empty strings. So why bother? Because the V8 engine - thus node.js - does support this dirty hack!

Read More

Keyboard input module for node: node-prompt.js

I have been watching node.js very close over the past weeks and eventually got myself a working installation, so it was about time to code something. But what? Don’t ask why, but I ended up writing a simple module that allows you to prompt input in your node process window.

Read More