@E18e/Is Primitive

1.0.5Last update Aug 9, 2024
by@e18e

Codemod: is-primitive

Introduction

This codemod replaces the usage of the is-primitive npm module with a custom implementation of the isPrimitive function. This change aims to reduce unnecessary dependencies and improve the performance of the codebase by utilizing a built-in approach to validate primitive values.

Before

import isPrimitive from 'is-primitive';
const value = 'Hello, World!';
const result = isPrimitive(value);

After

const val = 'Hello, World!';
const result = (() => {
if (typeof val === 'object') {
return val === null;
}
return typeof val !== 'function';
})();

Build custom codemods

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

background illustrationGet Started Now