> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nodejs/userland-migrations/llms.txt
> Use this file to discover all available pages before exploring further.

# SlowBuffer to Buffer.allocUnsafeSlow

> Migrate deprecated SlowBuffer constructor to Buffer.allocUnsafeSlow() for Node.js DEP0030

This codemod migrates deprecated `SlowBuffer` usage to `Buffer.allocUnsafeSlow()` to handle Node.js [DEP0030](https://nodejs.org/api/deprecations.html#DEP0030).

## What It Does

This codemod transforms:

1. `SlowBuffer` constructor calls to `Buffer.allocUnsafeSlow()`
2. Direct `SlowBuffer` calls to `Buffer.allocUnsafeSlow()`
3. Import/require statements to use `Buffer` instead of `SlowBuffer`

## Before/After

<Tabs>
  <Tab title="ESM">
    **Before:**

    ```javascript theme={null}
    import { SlowBuffer } from "buffer";
    const buf = new SlowBuffer(1024);
    ```

    **After:**

    ```javascript theme={null}
    import { Buffer } from "buffer";
    const buf = Buffer.allocUnsafeSlow(1024);
    ```
  </Tab>

  <Tab title="CommonJS">
    **Before:**

    ```javascript theme={null}
    const { SlowBuffer } = require("buffer");
    const buf = new SlowBuffer(1024);
    ```

    **After:**

    ```javascript theme={null}
    const { Buffer } = require("buffer");
    const buf = Buffer.allocUnsafeSlow(1024);
    ```
  </Tab>
</Tabs>

<Warning>
  The `SlowBuffer` constructor was deprecated in Node.js v6.0.0 and removed in later versions. This migration is essential for maintaining compatibility with modern Node.js versions.
</Warning>

## Usage

Run this codemod on your project:

```bash theme={null}
npx codemod node/userland/slow-buffer-to-buffer-alloc-unsafe-slow
```

<Tip>
  `Buffer.allocUnsafeSlow()` creates a buffer outside the shared internal memory pool. Use this when you need a buffer that won't be pooled, but remember that the buffer contents are uninitialized and may contain sensitive data.
</Tip>

## Related Deprecations

* [DEP0030: SlowBuffer](https://nodejs.org/api/deprecations.html#DEP0030)
