Snippets of the day – Monday, February 24, 2014

Posted on Posted in Snippets

snip2code-scissors-text

Here are some of the most recently published snippets!

Typescript: passing a class member function as parameter to another function

Typescript introduces the class construct and the concept of member functions. However if you try to pass a instance member function as parameter to another function the binding with the instance is lost.

To solve this problem you can use the capability of javascript (and Typescript) to support closures on anonymous function (or lambda expression) to preserve the instance for the function you want to pass as argument.

The example in this snippet runs on node.js

Open the snippet

Author:    micurs

Generate comma separated value string in Typescript using underscore _.reduce()

Underscore work well with Typescript lambda syntax.

Open the snippet

Author:    micurs

C#: retrieve the number of milliseconds from Epoch

Returns the number of milliseconds from Epoch

Open the snippet

Author:    cghersi

Leave a Reply

Your email address will not be published. Required fields are marked *