GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(micro-utilities): add compute-gcd to replacements by lyn1dev · Pull Request #1288 · e18e/module-replacements

Conversation

@lyn1dev

@lyn1dev lyn1dev commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

resolves #1207

📚 Description

Adds the compute-gcd module to the micro-utilities manifest, mapped to a new snippet::gcd replacement. The replacement follows the shape of the recent compute-lcm entry: a small recursive helper that returns the greatest common divisor of two integers, with Math.abs on the base case so that negative inputs behave like the package (for example gcd(-12, 8) is 4).

The mapping and the snippet are inserted in the existing sort order of the manifest.

Testing

  • node scripts/sort-manifests.js leaves the manifest unchanged, so the new keys are in sorted position.
  • pnpm lint:manifests (node --experimental-vm-modules scripts/validate-modules.js) reports OK for the JSON-schema validation and the manifest problem checks.
  • Prettier reports no formatting issues for the changed manifest (tr -d '\r' < manifests/micro-utilities.json > .tmp-mu.json && npx prettier --check .tmp-mu.json; the checkout uses CRLF locally, which is why the repository-wide pnpm lint:format reports the same 188 pre-existing files on an unmodified checkout).
  • A small script that imports the built package (dist/main.js) asserts that all.mappings['compute-gcd'] is {type: 'module', moduleName: 'compute-gcd', replacements: ['snippet::gcd']}, that all.replacements['snippet::gcd'] exists, and evaluates the snippet example: gcd(48, 18) === 6, gcd(17, 5) === 1, gcd(0, 5) === 5, gcd(-12, 8) === 4, gcd(9, 0) === 9. The same script fails before the change because the mapping is undefined.

AI was used to write this code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lyn1dev
feat(micro-utilities): add compute-gcd to replacements
f5ccdff
Map the compute-gcd package to a snippet::gcd replacement, mirroring the
compute-lcm entry. The snippet computes the greatest common divisor of two
integers recursively and keeps the sign handling of the package by taking the
absolute value of the base case.
@maksimgm

maksimgm commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

checked it against [email protected] and it matches for pairs of integers, including negatives and zero. the package also takes more than two values (gcd(12, 18, 24)), so maybe reduce over ...values like the lcm snippet in #1231

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@43081j

43081j commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

i think we can keep it simple, to two values. the user can figure it out if they need more 👍

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@43081j
43081j merged commit 2646d76 into e18e:main Nov 25, 2026
5 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Replacement]: compute-gcd

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@lyn1dev @maksimgm @43081j
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.