@E18e/Pad Left

/icons/calendar.svg

Last update

Aug 9, 2024

Pad Left Codemod

Introduction

This codemod replaces the use of the pad-left npm module with the built-in JavaScript String.prototype.padStart method. By removing the import of the external package and utilizing native functionality, this transformation reduces unnecessary dependencies and improves the performance of the codebase.

Before

import padLeft from 'pad-left';
const paddedString = padLeft('test', 5, '0');

After

const paddedString = 'test'.toString().padStart(5, '0');

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now