@E18e/Object.Hasown

1.0.5Last update Aug 9, 2024
by@e18e

Object.hasOwn Codemod

Introduction

This codemod replaces instances of object.hasown with the built-in Object.hasOwn method. This not only reduces dependencies by removing unnecessary imports but also leverages modern JavaScript features for better performance and simpler code.

Before

import { hasown as objectHasOwn } from 'object.hasown';
const hasOwnProperty = objectHasOwn(obj, 'propertyName');

After

const hasOwnProperty = Object.hasOwn(obj, 'propertyName');

Build custom codemods

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

background illustrationGet Started Now