Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: runtime deprecate SlowBuffer #55175

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1324,7 +1325,10 @@ function isAscii(input) {

module.exports = {
Buffer,
SlowBuffer,
SlowBuffer: deprecate(
SlowBuffer,
'SlowBuffer() is deprecated. Please use Buffer.allocUnsafeSlow()',
RafaelGSS marked this conversation as resolved.
Show resolved Hide resolved
'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
Loading