Skip to content

Instantly share code, notes, and snippets.

View nicolo-ribaudo's full-sized avatar

Nicolò Ribaudo nicolo-ribaudo

View GitHub Profile

Productions with optional elements whose SDOs omit the optional

These are cases where a grammar production has an optional (?) element on the right-hand side, and a syntax-directed operation defines a rule for that production without the optional part.

For example, the production Foo : Bar Baz? has two alternatives: Foo : Bar Baz and Foo : Bar. When an SDO is defined on Foo : Bar, it handles the "optional element absent" case.

{
"did": "did:plc:diblntoainoud2g6qk5bawks"
}
From bc1e34f1a3be4cd8ab92f35c67c9ac7306da934d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= <nribaudo@igalia.com>
Date: Sun, 16 Feb 2025 01:17:14 +0100
Subject: [PATCH 1/2] Define `importMap` option in webidl
---
.../renderer/bindings/generated_in_core.gni | 4 +++
.../blink/renderer/core/workers/worker.idl | 2 +-
.../renderer/core/workers/worker_options.idl | 5 ++++
.../constructors/Worker/importMap-option.html | 29 +++++++++++++++++++

"numeric value with precision" V3

NOTE: The other file in the gist shows the same but using "significant digits" rather than "fractional digits". After trying to use it, I noticed that almost always we want to start counting fro mthe units and not from the most significant digit.

A "numeric with precision" is a pair consisting of a numeric value and an indication of how many of its digits are significant. The number of digits is counted starting from the units: 1 means the first digit after the dot, 0 means that we have an integer, -1 means that we have a multiple of 10.

It can be obtained from a numeric value (wether it's decimal, float, or bigint) by "decorating it":

new Decimal("123.45").withFractionalDigits(1);
123.45.withFractionalDigits(1);

MessageFormat 2 modules integration

This is a proposal for better integration of MessageFormat 2 (Unicode proposal, TC39 proposal) with the rest of the web platform.

TLDR

import message from "./message.mf2" with { type: "messageformat" };

export function Notifications({ count }) {
  return html`<p>${message.format({ count })}</p>`;

Optional chaining assignment proposal

Basically, allow this:

foo?.bar = value;

which is equivalent to

foo == null ? undefined : (foo.bar = value);
const CH_BRACE_L = 0x7b as const;
const CH_BRACE_R = 0x7d as const;
const CH_SQUARE_L = 0x5b as const;
const CH_SQUARE_R = 0x5d as const;
const CH_QUOTE_D = 0x22 as const;
const CH_ESCAPE = 0x5c as const;
const CH_COMMA = 0x2c as const;
const CH_COLON = 0x3a as const;
const CH_DOT = 0x2e as const;
const CH_MINUS = 0x2d as const;

Meta

Key ID: C6CB6CC54E363735

Subkeys: AAFDA9101C58F338, A96EDD9C10BC77A5, 5BB1D2E5A4C8404B

Setup GPG

git config --global user.signingkey AAFDA9101C58F338

This for loop:

for (let i = 0, getI = () => i; i < 3; i++)
  console.log(getI());

unrolls to:

@nicolo-ribaudo
nicolo-ribaudo / function.cjs
Created October 6, 2020 20:20
Synchronize async functions
"use strict";
const synchronize = require("./synchronize.cjs");
synchronize.export({
async getMyObj(value) {
await new Promise((resolve) => setTimeout(resolve, 2000));
return { foo: value * 3 };
}
});