Skip to content

Instantly share code, notes, and snippets.

@z-------------
Last active September 4, 2015 11:38
Show Gist options
  • Save z-------------/4c63f4dae36721bb33c1 to your computer and use it in GitHub Desktop.
Save z-------------/4c63f4dae36721bb33c1 to your computer and use it in GitHub Desktop.
Little function that makes it easy to connect a simple linear chain of things.
var chain = function(nodes, func) {
for (var i = 0; i < nodes.length - 1; i++) {
func(nodes[i], nodes[i + 1]);
}
};
/**
* example:
* chain([source, filter, gain, output], function(a, b) {
* a.connect(b);
* });
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment