Registry
A

remove-iswhitespace

No description available

alexbit-codemod13 executions

  • Legacy
  • e18e
  • micro-utilities
  • optimization
  • cleanup
Connect a repo
npx codemod remove-iswhitespace

Removes isWhitespace calls and is-whitespace imports and replaces them with trim() calls.

is-whitespace is a small utility that checks if a string contains only whitespace characters.
It's not a very performant way to check for whitespace, especially when used in a loop.

Before

ts
//this could be any shape of import statement for is-whitespace
const isWhitespace = require('is-whitespace');

let str = '   ';
let str2 = 'Hello';

console.log(isWhitespace(str1)); // true
console.log(isWhitespace(str2)); // false

After

ts
//remove the import statement related to is-whitespace. and replace isWhitespace with its equivalent implementation as shown below.

let str = '   ';
let str2 = 'Hello';

console.log(str1.trim() === ''); // true
console.log(str2.trim() === ''); // false

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.