Skip to main content
This recipe transforms the usage of deprecated util._extend() to use Object.assign() to handle Node.js DEP0060.

What It Does

This codemod replaces:
  • util._extend() calls with Object.assign()
  • Removes unnecessary util imports when no longer needed

Before/After

Before:
After:

Usage

Run this codemod on your project:
Object.assign() is the standard ECMAScript method for copying properties from one or more source objects to a target object. It’s more widely supported and follows JavaScript standards.
Both util._extend() and Object.assign() mutate the target object. If you need a non-mutating merge, use the spread operator: const result = { ...target, ...source }.