Skip to content

Commit 58bf7ff

Browse files
connorsheaCopilot
andauthored
docs: Add links to Node.js API docs in various module replacements pages. (#618)
* docs: Add links to Node.js API docs in various module replacements pages. And some minor, general improvements otherwise. Also note in the md5 page that is is insecure and has been for a long time. * Update docs/modules/through.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/modules/md5.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update docs/modules/split.md * Revert one change to doc page --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f7a1c5d commit 58bf7ff

File tree

12 files changed

+19
-11
lines changed

12 files changed

+19
-11
lines changed

docs/modules/buf-compare.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Native Node.js alternatives to the buf-compare package for buffer c
66

77
## `Buffer.compare` (native)
88

9-
`Buffer.compare` is a native method which achieves the same result as `buf-compare`, available since Node v0.11.13.
9+
[`Buffer.compare`](https://nodejs.org/api/buffer.html#static-method-buffercomparebuf1-buf2) is a native method which achieves the same result as `buf-compare`, available since Node v0.11.13.
1010

1111
Example:
1212

docs/modules/buffer-equal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Native Node.js alternatives to the buffer-equal package for buffer
66

77
## `Buffer#equals` (native)
88

9-
Buffers have an `equals` method since Node 0.12.
9+
Buffers have an [`equals`](https://nodejs.org/api/buffer.html#bufequalsotherbuffer) method since Node v0.12.
1010

1111
Example:
1212

docs/modules/buffer-equals.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Native Node.js alternatives to the buffer-equals package for buffer
66

77
## `Buffer#equals` (native)
88

9-
Buffers have an `equals` method since Node 0.12.
9+
Buffers have an [`equals`](https://nodejs.org/api/buffer.html#bufequalsotherbuffer) method since Node v0.12.
1010

1111
Example:
1212

docs/modules/builtin-modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Native Node.js alternatives to the builtin-modules package for list
66

77
## `builtinModules` (native, since Node.js 6.x)
88

9-
For getting the list of built-in modules, you can use [builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules):
9+
For getting the list of built-in modules, you can use [`builtinModules`](https://nodejs.org/api/module.html#modulebuiltinmodules):
1010

1111
```ts
1212
import builtinModulesList from 'builtin-modules' // [!code --]

docs/modules/fs-extra.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Modern alternatives to the fs-extra package for working with the fi
66

77
## `fs` and `fs/promises` (native, Node.js)
88

9-
Modern Node.js includes built-in `fs` and `fs/promises` APIs that cover what [`fs-extra`](https://github.com/jprichardson/node-fs-extra) historically provided.
9+
Modern Node.js includes built-in [`fs`](https://nodejs.org/api/fs.html) and [`fs/promises`](https://nodejs.org/api/fs.html#promises-api) APIs that cover what [`fs-extra`](https://github.com/jprichardson/node-fs-extra) historically provided.
1010

1111
```js
1212
import fsExtra from 'fs-extra' // [!code --]

docs/modules/get-stream.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function streamToString(stream) {
2020

2121
## Converting stream to Array
2222

23-
You can convert a stream to an array using `Array.fromAsync`:
23+
You can convert a stream to an array using [`Array.fromAsync`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync) in Node 22+:
2424

2525
```ts
2626
await Array.fromAsync(stream)
@@ -38,7 +38,7 @@ async function streamToArray(stream) {
3838

3939
## Converting stream to Buffer
4040

41-
You can convert a stream to a `Buffer` using `Array.fromAsync` with a mapper:
41+
You can convert a stream to a `Buffer` using [`Array.fromAsync`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fromAsync) with a mapper:
4242

4343
```ts
4444
async function streamToBuffer(stream) {

docs/modules/inherits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Modern alternatives to the inherits package
66

77
## ES6 classes `extends` syntax
88

9-
ES6 classes `extends` syntax is a native way to implement prototype inheritance.
9+
ES6 classes [`extends`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/extends) syntax is a native way to implement prototype inheritance.
1010

1111
Example:
1212

docs/modules/md5.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ description: Native Node.js alternatives to the md5 package for MD5 hash generat
66

77
## `crypto` (native)
88

9-
If you're using the [`md5`](https://github.com/pvorb/node-md5) package, consider using a stronger algorithm where possible. If you must keep MD5 for compatibility, Node.js provides a native alternative via the `crypto` module.
9+
If you're using the [`md5`](https://github.com/pvorb/node-md5) package, _strongly_ consider moving to a stronger algorithm if your usage is security-sensitive (for example, passwords). MD5 is [not secure](https://en.wikipedia.org/wiki/MD5#Security) and hasn't been secure for many years.
10+
11+
If you must keep MD5 for compatibility, Node.js provides a native alternative via the [`crypto` module](https://nodejs.org/api/crypto.html#crypto).
1012

1113
```ts
1214
import crypto from 'node:crypto' // [!code ++]

docs/modules/object-hash.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const h = hash(obj) // [!code ++]
2020

2121
## Web Crypto
2222

23-
Use the standard `SubtleCrypto.digest` available in modern runtimes. Pair it with a stable serializer (e.g., [`safe-stable-stringify`](https://github.com/BridgeAR/safe-stable-stringify)) to ensure deterministic key ordering.
23+
Use the standard [`SubtleCrypto.digest`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest) available in modern runtimes. Pair it with a stable serializer (e.g., [`safe-stable-stringify`](https://github.com/BridgeAR/safe-stable-stringify)) to ensure deterministic key ordering.
2424

2525
Example:
2626

docs/modules/split.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ description: Native Node.js alternatives to the split package for splitting stre
66

77
## `readline.createInterface` (native, since Node.js v6.6.0)
88

9+
The [`readline.createInterface`](https://nodejs.org/api/readline.html#readlinecreateinterfaceoptions)
10+
method can be used to read a stream line by line, effectively replacing the functionality of the `split` package.
11+
912
Example:
1013

1114
<!-- prettier-ignore -->
1215
```js
1316
import split from 'split' // [!code --]
1417
import { createInterface } from 'node:readline' // [!code ++]
18+
import * as fs from 'node:fs'
1519

1620
const input = fs.createReadStream('file.txt')
1721

0 commit comments

Comments
 (0)