This blog post contains:
The focus of this post is on shell scripting, which is why we only work with textual data.
On 22 June 2022, the 123nd Ecma General Assembly approved the ECMAScript 2022 language specification, which means that it’s officially a standard now.
This blog post explains what’s new.
There are two ways in which npm packages can be installed:
Locally, into a node_modules
directory that npm searches for (or creates) in the current directory and its ancestors:
npm install some-package
Globally, into a global node_modules
directory:
npm install --global some-package
(Instead of the long version --global
of this flag, we can also use the shorter -g
.)
The latter requires root access on macOS and some other Unix platforms – which is a considerable downside. That’s why this blog post explores alternatives to global installs.
Web streams are a standard for streams that is now supported on all major web platforms: web browsers, Node.js, and Deno. (Streams are an abstraction for reading and writing data sequentially in small pieces from all kinds of sources – files, data hosted on servers, etc.)
For example, the global function fetch()
(which downloads online resources) asynchronously returns a Response which has a property .body
with a web stream.
This blog post covers web streams on Node.js, but most of what we learn applies to all web platforms that support them.
UTM is a free virtualization software that runs Windows/ARM on Apple Silicon Macs. This blog post explains how to use it.
for-of
vs. .reduce()
vs. .flatMap()
In this blog post, we look at three ways of processing Arrays:
for-of
loop.reduce()
.flatMap()
The goal is to help you choose between these features whenever you need to process Arrays. In case you don’t know .reduce()
and .flatMap()
yet, they will both be explained to you.
In order to get a better feeling for how these three features work, we use each of them to implement the following functionality:
Everything we do is non-destructive: The input Array is never changed. If the output is an Array, it is always freshly created.
(This blog post is based on a tweet thread and additional input by Mathias Bynens.)
After work started on it in August 2017, May 2022 finally saw the publication of RFC 9239 “Updates to ECMAScript media types” by Matthew A. Miller, Myles Borins, Mathias Bynens, and Bradley Farias. It updates JavaScript MIME type registrations to align with reality:
text/javascript
..mjs
is now a registered filename extension, specifically for JavaScript modules.This unblocks tooling and server software like Apache to support JavaScript modules out of the box in a unified manner, like e.g. Node.js already does. Better industry alignment on MIME type and file extensions increases interoperability across tooling and other software.
...
) in JavaScript: rest vs. spreadIn JavaScript, the same syntax – triple dots (...
) – is used for two different mechanisms:
This blog post examines how these mechanisms work and why they are not operators.
This blog post describes the ECMAScript proposal “Change Array by copy” by Robin Ricard and Ashley Claymore. It proposes four new methods for Arrays and Typed Arrays:
.toReversed()
.toSorted()
.toSpliced()
.with()
eval()
This blog post describes the ECMAScript proposal “ShadowRealm API” by Dave Herman, Caridy Patiño, Mark S. Miller, Leo Balter, and Rick Waldron.
Class ShadowRealm
provides a new way of evaluating code at runtime – think eval()
but better: