Category: node.js

C# style object initialisation in TypeScript

@RoutingKey(‘abc’) class Foo { public name: string | undefined; public age: number | undefined; public gender: string | undefined; constructor(init?: Partial<Foo>) { if (init) { Object.assign(this, init); } } } const foo = new Foo({ name: ‘something’ }); https://stackoverflow.com/a/72028371/1515209 Read more →

Microsoft’s Task Parallel Library and the principle behind node.js

I wanted to see how Microsoft’s Task Parallel Library compared with node.js in so far as passing the next method in to the current to chain the calls indefinitely. So I created a method that iteratively adds itself to the current executing Task. The initial test was to see if the code would fail with a StackOverflowException but what I… Read more →

node.js calling multiple web services in parallel

http://askhds.blogspot.co.uk/2012/02/nodejs-rest-call-using-http-library.html var http = require(‘http’); // Add helloworld module var helloworld = require(‘helloworld_mod’); http.createServer(function(req, res) { res.writeHead(200, { ‘Content-Type’ : ‘text/xml’ }); try { // Bypass function call to “Google Maps API” getFromGoogle(req, res); } catch (e) { res.end(“Try again later”); } }).listen(1337, ‘127.0.0.1’); console.log(‘Server running at http://127.0.0.1:1337/’); console.log(‘Type the URL in address bar’); console.log(‘http://127.0.0.1:1337/maps/api/geocode/xml?’ + ‘address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false’); function getFromGoogle(mainreq, mainres)… Read more →