Skip to content

Commit

Permalink
doc: modules.md: fix distance definition
Browse files Browse the repository at this point in the history
It's somewhat esoteric at best to define distance in terms of squared
length!

PR-URL: #57046
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
  • Loading branch information
alexweej authored Feb 16, 2025
1 parent 69fdce2 commit b6cd6b7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,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
Expand Down Expand Up @@ -269,7 +269,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' }
```

Expand All @@ -293,7 +293,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; }
Expand Down

0 comments on commit b6cd6b7

Please sign in to comment.