Skip to content

Commit

Permalink
lib: runtime deprecate SlowBuffer
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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>
  • Loading branch information
RafaelGSS authored and tpoisseau committed Nov 21, 2024
1 parent e720550 commit 607e931
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,9 @@ Type: End-of-Life

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/55175
description: Runtime deprecation.
- version: v6.12.0
pr-url: https://github.com/nodejs/node/pull/10116
description: A deprecation code has been assigned.
Expand All @@ -703,7 +706,7 @@ changes:
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

The [`SlowBuffer`][] class is deprecated. Please use
[`Buffer.allocUnsafeSlow(size)`][] instead.
Expand Down
6 changes: 5 additions & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const {
kIsEncodingSymbol,
defineLazyProperties,
encodingsMap,
deprecate,
} = require('internal/util');
const {
isAnyArrayBuffer,
Expand Down Expand Up @@ -1322,7 +1323,10 @@ function isAscii(input) {

module.exports = {
Buffer,
SlowBuffer,
SlowBuffer: deprecate(
SlowBuffer,
'SlowBuffer() is deprecated. Please use Buffer.allocUnsafeSlow()',
'DEP0030'),
transcode,
isUtf8,
isAscii,
Expand Down
8 changes: 7 additions & 1 deletion test/parallel/test-buffer-slow.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
'use strict';

require('../common');
const common = require('../common');
const assert = require('assert');
const buffer = require('buffer');
const SlowBuffer = buffer.SlowBuffer;

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

common.expectWarning(
'DeprecationWarning',
'SlowBuffer() is deprecated. Please use Buffer.allocUnsafeSlow()',
'DEP0030'
);

// Should create a Buffer
let sb = SlowBuffer(4);
assert(sb instanceof Buffer);
Expand Down

0 comments on commit 607e931

Please sign in to comment.