Skip to content

feat: handle SlowBuffer depreciation #125

@AugustinMauroy

Description

@AugustinMauroy

Description

This codemod should migrate SlowBuffer to Buffer.allocUnsafeSlow(). It's useful to migrate code that uses the deprecated SlowBuffer class which has been removed.

It should handle both constructor usage and static method calls. It should support both SlowBuffer direct usage and destructured imports from buffer module.

Examples

Case 1

Before:

const SlowBuffer = require('buffer').SlowBuffer;

// Using SlowBuffer constructor
const buf1 = new SlowBuffer(1024);
const buf2 = SlowBuffer(512);

// Direct import
const { SlowBuffer } = require('buffer');
const buf3 = new SlowBuffer(256);

After:

const { Buffer } = require('buffer');

// Using Buffer.allocUnsafeSlow()
const buf1 = Buffer.allocUnsafeSlow(1024);
const buf2 = Buffer.allocUnsafeSlow(512);

// Direct import
const { Buffer } = require('buffer');
const buf3 = Buffer.allocUnsafeSlow(256);

Case 2

Before:

import { SlowBuffer } from 'buffer';
const buf = new SlowBuffer(1024);

After:

import { Buffer } from 'buffer';
const buf = Buffer.allocUnsafeSlow(1024);

REFS

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    🔖 Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions