Enums considered harmful

January 24, 2023typescriptenum

It seems that torwards the end of 2022 the collective hivemind of the TypeScript programming world decided that enums are terrible. While I mostly agree with the premise that TypeScript enums are not good the solutions that are presented often only deal with String enums. For my work on SDL_ts I really need a solution for Numeric enums as SDL is full of them.

Read More

Now powered by deno

December 23, 2022deno

I finally sat down and got my blog compiling with deno. Now that there is official npm support I didn't need to completely rewrite the compiler which was what was stopping me before.

Read More

deno: Get the path of the current script in

In deno obtaining the path of the current script is done via the import.meta.url api:

const scriptPath = new URL(import.meta.url).pathname;

On Windows though this will return a path with unix style path seperators and a leading /:

Read More

Iterating thru an Object in JavaScript

For the longest time if I wanted to iterate thru an object in JavaScript I would write code that looked something like this:

const obj = { a: "foo", b: "bar" };
for (const key of Object.keys(obj)) {
    console.info(key, obj[key]);

Since ES2017 there is a better way of doing this using Object.entries() and destructuring:

const obj = { a: "foo", b: "bar" };
for (const [ key, value ] of Object.entries(obj)) {
    console.info(key, value);
Read More

Powershell time command

March 10, 2022powershell

I commbined the best parts of this StackOverflow answer and this Super User answer to come up with this solution for a time function in Powershell:

function time {
    $Command = "$args";
    (Measure-Command { Invoke-Expression $Command 2>&1 | Out-Default }).ToString();

Example usage:

# time git pull