Skip to content

Omnibus modernization, particularly ESM#70

Merged
kriskowal merged 17 commits intomainfrom
esm
Nov 29, 2025
Merged

Omnibus modernization, particularly ESM#70
kriskowal merged 17 commits intomainfrom
esm

Conversation

@kriskowal
Copy link
Member

No description provided.

@kriskowal kriskowal force-pushed the esm branch 2 times, most recently from 4eca1de to 9bc9a04 Compare November 28, 2025 07:37
Copy link
Collaborator

@jcorbin jcorbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's Happening!

I stopped reading somwhere around html.js in alphabetic files-changed order... green ci -> merge and continue...

tho why no more tsc in CI? what even is the current meta on prettier-vs-eslint-vs-justusestricttypescriptrules ?

describe.js Outdated
Comment on lines +39 to +44
if (node.variable) {
desc += '(' + node.variable + '+' + node.value + ') ' + S(node.expression);
} else {
desc += S(node.expression);
}
desc += ' (' + node.branches.join(' ') + ') W(' + node.weights.map(S).join(' ') + ')';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uplift to backtick wen? destructure node wen? how far does that train go to expression crunching down this nascent desc string builder pattern?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously this apples throughout below, not echoing it after this site

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a commit to adopt the prefer-template and apply the autofix.

describe.js Outdated
types.set = function set(node) {
return node.variable + ' ' + S(node.expression);
types.set = node => {
return node.variable + ' ' + S(node.expression);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these one-line return bracket-bodies could be erased fwiw

import fs from 'fs';
import verify from './verify.js';

function main() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what even is the test framework again here? global test from whence? reporting via console.error below? thoughts? plans? dreams?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test framework is that the tests exit non-zero. Obvious room to improve once past the decision paralysis.

Comment on lines +14 to +22
const offset = Math.floor(randomer.random() * weight);
let passed = 0;
for (let i = 0; i < weights.length; i++) {
passed += weights[i];
if (offset < passed) {
return i;
}
}
return null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this pr, but this 2-pass sampling algo could be 1-pass; there is no need for the pre-summed weight term; just use pow(random(), 1/weights[i]; I guess the "cost" is you go from 1 random call to N, but now you've got a 1-pass online algo fwiw

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great point and I love the math of it, but also want to avoid floating point because the browsers are constantly whacking behavior divergence moles.

Comment on lines +294 to +297
this.randomer._state0U = random[0];
this.randomer._state0L = random[1];
this.randomer._state1U = random[2];
this.randomer._state1L = random[3];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something something TODO pluggable / modern/ bigint-based prng wen ; and how ; does it need to support restoring legacy state snapshots? whew...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d love to attack this some time!

engine.js Outdated
}

$echo() {
return this.write('' + evaluate(this.top, this.randomer, this.instruction.expression));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the '' + coercion still necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not at runtime, but when deepening the relationship with TypeScript, this will probably continue to at least be a quasi/template literal just to appease the write string param.

@kriskowal kriskowal merged commit 844aeb5 into main Nov 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants