@E18e/Has Own Prop

1.0.5Last update Aug 9, 2024
by@e18e

has-own-prop Codemod

Introduction

This codemod replaces the usage of the has-own-prop npm module with the built-in Object.hasOwn method. This change aims to reduce unnecessary dependencies and improve performance by utilizing native JavaScript features.

Before

import hasOwnProp from 'has-own-prop';
const obj = { key: 'value' };
if (hasOwnProp(obj, 'key')) {
console.log('Key exists!');
}

After

const obj = { key: 'value' };
if (Object.hasOwn(obj, 'key')) {
console.log('Key exists!');
}

Build custom codemods

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

background illustrationGet Started Now