Skip to content
Open
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
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions recipes/slow-buffer-to-buffer-alloc-unsafe-slow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SlowBuffer to Buffer.allocUnsafeSlow Codemod

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 be synced with new function

## Example

**Before:**

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

**After:**

```javascript
import { Buffer } from "buffer";
const buf = Buffer.allocUnsafeSlow(1024);
```
23 changes: 23 additions & 0 deletions recipes/slow-buffer-to-buffer-alloc-unsafe-slow/codemod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
schema_version: "1.0"
name: "@nodejs/slow-buffer-to-buffer-alloc-unsafe-slow"
version: "1.0.0"
description: Handle DEP0030 via transforming SlowBuffer usage to Buffer.allocUnsafeSlow().
author: lluisemper(Lluis Semper Lloret)
license: MIT
workflow: workflow.yaml
category: migration

targets:
languages:
- javascript
- typescript

keywords:
- transformation
- migration
- buffer
- slowbuffer
Comment on lines +18 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexbit-codemod could you confirm that this keywords is good idea for ours codemods ??? The published codemods only use transformation & migration keywords.

Copy link
Contributor

@alexbit-codemod alexbit-codemod Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry! Just saw this! and I know it’s already approved so I don’t want to block it. The tags are ok as is, but if you want to make it more useful, here’s a guide for applying tags:
https://go.codemod.com/tags-guide

Tags are optional, but they’ll show up in the codemod registry so users can quickly tell what the codemod is about. Words like transformation or migration aren’t very helpful. cc @lluisemper @AugustinMauroy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- buffer
- slowbuffer

So let's not use it for now

https://go.codemod.com/tags-guide

  • Point 1 is fitable here
  • Point 2, I think I should be handle by a "meta"/parent codemod so I don't think it's usefull
  • point 3, it's covered by our scope


registry:
access: public
visibility: public
24 changes: 24 additions & 0 deletions recipes/slow-buffer-to-buffer-alloc-unsafe-slow/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@nodejs/slow-buffer-to-buffer-alloc-unsafe-slow",
"version": "1.0.0",
"description": "Handle DEP0030 via transforming SlowBuffer usage to Buffer.allocUnsafeSlow().",
"type": "module",
"scripts": {
"test": "npx codemod jssg test -l typescript ./src/workflow.ts ./"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nodejs/userland-migrations.git",
"directory": "recipes/slow-buffer-to-buffer-alloc-unsafe-slow",
"bugs": "https://github.com/nodejs/userland-migrations/issues"
},
"author": "lluisemper(Lluis Semper Lloret)",
"license": "MIT",
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/slow-buffer-to-buffer-alloc-unsafe-slow/README.md",
"dependencies": {
"@nodejs/codemod-utils": "*"
},
"devDependencies": {
"@codemod.com/jssg-types": "^1.0.3"
}
}
Loading
Loading