Skip to content

Interoperability Details

bjouhier edited this page Aug 21, 2011 · 17 revisions

As mentioned in the README, streamline interoperates seamlessly with standard node.js code: you can call node.js APIs from streamline code, and you can call functions written with streamline from normal node.js code.

Wrappers

Streamline lets you call directly external APIs that follow the node conventions (callback with err and result parameters). If you need to call non standard APIs that use a different callback signature, you can provide your own wrappers. There is one gotcha, though: you have to follow a special naming convention and call these wrappers __wrapXxx because streamline needs to transform these wrapper calls in a special way.

Compatibility with underscore.js

underscore.js is a popular library and you will have a problem if you use try to use it with streamline.js because streamline will interpret the _ identifier as its special callback.

One way to avoid the problem it to use a different identifier for underscore.js. For example:

var __ = require("underscore");

But you can solve the problem the other way around. You can keep _ for underscore.js and tell streamline.js to use a different identifier for callbacks. This is done by setting the callback option, as follows:

// streamline.options = { "callback" : "__" }

Clone this wiki locally