Skip to content

Commit 019efe1

Browse files
authored
lib: runtime deprecate SlowBuffer
PR-URL: #55175 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 2545b9e commit 019efe1

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

doc/api/deprecations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ Type: End-of-Life
695695

696696
<!-- YAML
697697
changes:
698+
- version: REPLACEME
699+
pr-url: https://github.com/nodejs/node/pull/55175
700+
description: Runtime deprecation.
698701
- version: v6.12.0
699702
pr-url: https://github.com/nodejs/node/pull/10116
700703
description: A deprecation code has been assigned.
@@ -703,7 +706,7 @@ changes:
703706
description: Documentation-only deprecation.
704707
-->
705708

706-
Type: Documentation-only
709+
Type: Runtime
707710

708711
The [`SlowBuffer`][] class is deprecated. Please use
709712
[`Buffer.allocUnsafeSlow(size)`][] instead.

lib/buffer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const {
8888
kIsEncodingSymbol,
8989
defineLazyProperties,
9090
encodingsMap,
91+
deprecate,
9192
} = require('internal/util');
9293
const {
9394
isAnyArrayBuffer,
@@ -1322,7 +1323,10 @@ function isAscii(input) {
13221323

13231324
module.exports = {
13241325
Buffer,
1325-
SlowBuffer,
1326+
SlowBuffer: deprecate(
1327+
SlowBuffer,
1328+
'SlowBuffer() is deprecated. Please use Buffer.allocUnsafeSlow()',
1329+
'DEP0030'),
13261330
transcode,
13271331
isUtf8,
13281332
isAscii,

test/parallel/test-buffer-slow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44
const assert = require('assert');
55
const buffer = require('buffer');
66
const SlowBuffer = buffer.SlowBuffer;
77

88
const ones = [1, 1, 1, 1];
99

10+
common.expectWarning(
11+
'DeprecationWarning',
12+
'SlowBuffer() is deprecated. Please use Buffer.allocUnsafeSlow()',
13+
'DEP0030'
14+
);
15+
1016
// Should create a Buffer
1117
let sb = SlowBuffer(4);
1218
assert(sb instanceof Buffer);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy