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 /:

/D:/Code/deno-path-of-script/main.ts
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

Practical WebAssembly

December 17, 2021javascriptwasmconciso

I wrote an article for my company conciso that attempts to show a practical usage of WebAssembly: https://conciso.de/practical-webassembly/.

Node script for syntax highlighting

I decided to switch my blog to use highlightjs instead of the mixture of my own library and ColorCode. I still wanted everything to rendered statically though so I decided to use highlight.js as it already offered instructions on how to use the library from node.

Read More