@E18e/Is Plain Object

1.0.5Last update Aug 9, 2024
by@e18e

is-plain-object Codemod

Introduction

This codemod removes the dependency on the is-plain-object npm module by replacing its usage with a custom implementation using native JavaScript constructs. The goal is to eliminate unnecessary dependencies, thereby reducing bundle size and improving performance.

Before

import isPlainObject from 'is-plain-object';
function checkObject(value) {
return isPlainObject(value);
}

After

function checkObject(value) {
return !!value && typeof value === 'object' &&
(Object.getPrototypeOf(value) === null ||
Object.getPrototypeOf(value) === Object.prototype);
}

Build custom codemods

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

background illustrationGet Started Now