// This is the reference implementation for xml2js. It's 3-4x slower. function xml2js(node) { if (node instanceof Array) return node.map(xml2js); if (node.nodeType == 3) return node.nodeValue; if (node.nodeType != 1) return undefined; var childElements = node.childNodes.select( function(c){return c.nodeType==1}); if (childElements.length) { var obj = {}; childElements.forEach(function(child) { var o = xml2js(child); var v = obj[child.nodeName]; if (v) { if (v instanceof Array) v.push(o); else v = [v, o]; o = v; } obj[child.nodeName] = o; }); return obj; } else return node.childNodes.map( function(c) {return c.nodeType==3 ? c.nodeValue : ""}).join(''); } // function f1(a,b) {return [a,b]} // var f2 = f1.bind(null,1); // info(f2(2)); function f3(a) {return a+1} function f4(a) {return a*2}; info(f3.compose(f4)(1)); info(f4.compose(f3)(1));