Codemod Registry
Explore community-led codemods to migrate, optimize, and transform your codebase.
Ready to contribute?
Build your own codemod and share it with the community.
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Explore community-led codemods to migrate, optimize, and transform your codebase.
# Xtend Codemod ## Introduction This codemod eliminates the `xtend` npm module by refactoring code to use the built-in JavaScript spread operator. This reduces the dependency on an external package, thereby decreasing the bundle size and improving the performance of the codebase. ### Before ```javascript import xtend from 'xtend'; const merged = xtend(object1, object2); ``` ### After ```javascript const merged = { ...object1, ...object2 }; ```
# typedarray.prototype.slice Codemod ## Introduction This codemod removes the dependency on the `typedarray.prototype.slice` package and replaces its usage with the built-in `slice` method available on TypedArray objects. This change helps reduce unnecessary dependencies and improves the performance of the codebase by utilizing native features. ### Before ```javascript import slice from 'typedarray.prototype.slice'; const typedArray = new Uint8Array([1, 2, 3]); const newArray = slice(typedArray, 0, 2); ``` ### After ```javascript const typedArray = new Uint8Array([1, 2, 3]); const newArray = typedArray.slice(0, 2); ```
# Typed Array Length Codemod ## Introduction This codemod removes the dependency on the `typed-array-length` package and replaces its usage with the native `length` property of typed arrays. The goal is to reduce unnecessary dependencies, minimize bundle size, and leverage built-in JavaScript features for improved performance. ### Before ```javascript import typedArrayLength from 'typed-array-length'; const array = new Uint8Array(10); const length = typedArrayLength(array); ``` ### After ```javascript const array = new Uint8Array(10); const length = array.length; ```
# Typed Array Byte Offset Codemod ## Introduction This codemod replaces the `typed-array-byte-offset` npm module with built-in ES features. It eliminates the dependency by transforming calls to the module into direct usage of the `byteOffset` property from typed array instances. The ultimate goal is to reduce unnecessary dependencies and improve performance within the codebase. ### Before ```javascript import byteOffset from 'typed-array-byte-offset'; const offset = byteOffset(new Uint8Array(buffer)); ``` ### After ```javascript const offset = new Uint8Array(buffer).byteOffset; ```
# Typed Array Byte Length Codemod ## Introduction This codemod removes the dependency on the `typed-array-byte-length` module and replaces its usage with the native `byteLength` property from typed arrays. This reduces unnecessary dependencies, optimizes bundle size, and leverages built-in JavaScript features for better performance. ### Before ```javascript import typedArrayByteLength from 'typed-array-byte-length'; const length = typedArrayByteLength(new Uint8Array([1, 2, 3])); ``` ### After ```javascript const length = new Uint8Array([1, 2, 3]).byteLength; ```
# Typed Array Buffer Codemod ## Introduction This codemod replaces instances of the `typed-array-buffer` npm module with built-in JavaScript functionalities. Specifically, it transforms calls to `typed-array-buffer` into the corresponding `buffer` property of typed arrays, thereby reducing the number of dependencies and enhancing the performance of the codebase. ### Before ```javascript import getBuffer from 'typed-array-buffer'; const buffer = getBuffer(myTypedArray); ``` ### After ```javascript const buffer = myTypedArray.buffer; ```
# Symbol Prototype Description Codemod ## Introduction This codemod removes the dependency on the `symbol.prototype.description` module and replaces its usage with the built-in ES feature. It eliminates the need for additional imports, reduces bundle size, and enhances code performance by directly accessing the `description` property of `Symbol` instances. ### Before ```javascript import description from 'symbol.prototype.description'; const mySymbol = description(Symbol('foo')); console.log(mySymbol); // Output: 'foo' ``` ### After ```javascript const mySymbol = Symbol('foo').description; console.log(mySymbol); // Output: 'foo' ```
# String.raw Codemod ## Introduction This codemod replaces the usage of the `string.raw` package with the built-in `String.raw` method. By transforming tagged template expressions that utilize `string.raw`, this codemod helps reduce the number of external dependencies in the codebase and improves performance by leveraging native JavaScript features. ### Before ```js import string from 'string.raw'; const result = string.raw`Hello, ${name}!`; ``` ### After ```js const result = String.raw`Hello, ${name}!`; ```
# string.prototype.trimstart Codemod ## Introduction This codemod replaces occurrences of the non-standard `string.prototype.trimstart` method with the standardized `String.prototype.trimStart` method. This update improves code consistency and reduces reliance on non-standard features, enhancing overall code quality. ### Before ```javascript const str = ' hello world '; const trimmed = str.trimstart(); ``` ### After ```javascript const str = ' hello world '; const trimmed = str.trimStart(); ```
# Codemod: Replace `String.prototype.trimRight` with `String.prototype.trimEnd` ## Introduction This codemod replaces instances of `String.prototype.trimRight` with the built-in `String.prototype.trimEnd` method. This change not only reduces unnecessary dependencies by utilizing modern JavaScript features but also improves performance by leveraging native functionalities. ### Before ```javascript const myString = " Hello, World! "; const trimmedString = myString.trimRight(); ``` ### After ```javascript const myString = " Hello, World! "; const trimmedString = myString.trimEnd(); ```
# string.prototype.trimleft Codemod ## Introduction This codemod replaces the usage of the deprecated `String.prototype.trimleft` method with its modern alternative, `String.prototype.trimStart`. This transformation not only helps in maintaining compatibility with up-to-date JavaScript standards but also reduces the risk of issues arising from the use of obsolete methods. ### Before ```javascript const myString = " Hello, World! "; const trimmedString = myString.trimleft(); ``` ### After ```javascript const myString = " Hello, World! "; const trimmedString = myString.trimStart(); ```
# String.prototype.trimend Codemod ## Introduction This codemod transforms instances of `string.prototype.trimend` into the more standardized `String.prototype.trimEnd`. This change not only aligns the code with current JavaScript standards but also facilitates better performance by using built-in methods without the need for additional dependencies. ### Before ```javascript const result = myString.trimend(); ``` ### After ```javascript const result = myString.trimEnd(); ```
Build your own codemod and share it with the community.