doc: modules.md: fix distance definition

It's somewhat esoteric at best to define distance in terms of squared
length!

PR-URL: https://github.com/nodejs/node/pull/57046
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Alexander “weej” Jones authored and Marco Ippolito committed 2025-08-27 19:20:31 +02:00
1 parent 7b0ea9ab2d
commit cd8259cb4e
1 file changed
+3 -3
+3 -3
View File
@@ -213,7 +213,7 @@ With the following ES Modules:
```mjs
// distance.mjs
export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; }
export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }
```
```mjs
@@ -265,7 +265,7 @@ export default class Point {
// `distance` is lost to CommonJS consumers of this module, unless it's
// added to `Point` as a static property.
export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; }
export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }
export { Point as 'module.exports' }
```
@@ -289,7 +289,7 @@ named exports attached to it as properties. For example with the example above,
<!-- eslint-disable @stylistic/js/semi -->
```mjs
export function distance(a, b) { return (b.x - a.x) ** 2 + (b.y - a.y) ** 2; }
export function distance(a, b) { return Math.sqrt((b.x - a.x) ** 2 + (b.y - a.y) ** 2); }
export default class Point {
constructor(x, y) { this.x = x; this.y = y; }