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

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎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+
constcommon=require('../common');
44
constassert=require('assert');
55
constbuffer=require('buffer');
66
constSlowBuffer=buffer.SlowBuffer;
77

88
constones=[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
letsb=SlowBuffer(4);
1218
assert(sbinstanceofBuffer);

0 commit comments

Comments
 (0)