Registry
Nnodejs avatar

nodejs/slow-buffer-to-buffer-alloc-unsafe-slow

Handle DEP0030 via transforming SlowBuffer usage to Buffer.allocUnsafeSlow().

nodejs47 executions

  • transformation
  • migration
  • buffer
  • slowbuffer
Connect a repo
npx codemod @nodejs/slow-buffer-to-buffer-alloc-unsafe-slow

SlowBuffer to Buffer.allocUnsafeSlow Codemod

This codemod migrates deprecated SlowBuffer usage to Buffer.allocUnsafeSlow() to handle Node.js 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 be synced with new function

Example

diff
- import { SlowBuffer } from "buffer";
+ import { Buffer } from "buffer";
- const buf = new SlowBuffer(1024);
+ const buf = Buffer.allocUnsafeSlow(1024);

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.