Code Buckets

Buckets of code

TypeScript

Is there any reason not to use TypeScript?

I’ve written a lot of code for side projects and for this blog, and a lot of it has been JavaScript. I’m really wondering now why I didn’t write it all in TypeScript instead. It’s easy to learn, improves your…

Getting Random Letters with the Correct Frequency Using TypeScript

The Task It’s pretty easy to get a random letter using TypeScript. Using lodash and returning upper case letters, it would be You don’t even need to use lodash – it’s a convenience. The problem with this code is that…

Infinite Buddha Quotes

Just moving on from the Pali Canon API that I published recently – I’ve published a web app which consumes the API. It randomly displays a quote from the Buddha, fades it out and displays the next with a suitably…

Extending TypeScript to serialise Map objects to JSON

The collection objects offered by ES6 such as Map and Set are indeed a marvel. One notable downside to them though is that they don’t serialise to JSON. For example JSON.stringify(MyMapObject); Results in {} Always – irrespective of what is…

LINQ FirstOrDefault implementation in TypeScript

Confession: when working in JavaScript languages I kind of miss some C# things such as LINQ. A substantial part of my C# coding seemed to be chaining LINQ operators together. So rather than staring wistfully out of the window  in…