mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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:
committed by
GitHub
parent
69fdce2c7f
commit
b6cd6b7e31
@@ -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
|
||||
@@ -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' }
|
||||
```
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user