# @codepatch/core

> Transform code the easy way

Latest version **1.0.1** (published 2023-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @codepatch/core
pnpm add @codepatch/core
yarn add @codepatch/core
bun add @codepatch/core
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-09-23 |
| First published | 2023-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 31.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Florian Reuschel |
| Maintainers | loilo |
| Keywords | ast, transform, rewrite, transpile, source, syntax, traverse, tree |

## Links

- npm: https://www.npmjs.com/package/@codepatch/core
- Repository: https://github.com/loilo/codepatch
- Homepage: https://github.com/loilo/codepatch/tree/main/packages/core#readme
- Issues: https://github.com/loilo/codepatch/issues
- npm.io page: https://npm.io/package/@codepatch/core

## Dependencies (1)

- [magic-string](https://npm.io/package/magic-string.md) ^0.30.0

## Alternatives

- [update-check](https://npm.io/package/update-check.md) — 4.0M weekly downloads
- [react-native-onesignal](https://npm.io/package/react-native-onesignal.md) — 134.5K weekly downloads
- [react-redux-toastr](https://npm.io/package/react-redux-toastr.md) — 33.7K weekly downloads
- [@nocobase/plugin-notification-manager](https://npm.io/package/@nocobase/plugin-notification-manager.md) — 2.0K weekly downloads
- [react-simple-toasts](https://npm.io/package/react-simple-toasts.md) — 1.9K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-09-23
- 1.0.0 — 2023-09-23

## README

# `@codepatch/core`

> Make small changes to your code the easy way

This package is the architectural core of the [Codepatch](https://github.com/loilo/codepatch) family of tools.
It provides the foundation and unified API for tools like [`@codepatch/javascript`](https://github.com/loilo/codepatch/tree/main/packages/javascript) or [`@codepatch/php`](https://github.com/loilo/codepatch/tree/main/packages/php).

## Installation

**NOTE:** This package is not intended to be used directly. It should be used a dependency of a Codepatch modifier implementation.

```
npm install @codepatch/core
```

**IMPORTANT:** `@codepatch/core` is an ESM-only package. [Read more.](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)

## Usage

`@codepatch/core` exports the `createModifier` function that allows creating a Codepatch modifier implementation by passing it a configuration object with four methods:

- `parse(code, options)` – Parse the `code` string into an AST. The `options` object is what users of your modifier pass as the `parser` option and thus is optional.
- `isNode(value)` – Check whether a value from inside the AST is a node.
- `collectChildNodes(node)` – Given a node, return an array of its child nodes.
- `getNodeLocation(node)` – From a node, get a two-item array with the node's start and end position (as offset characters) in the originally parsed code.

To improve type safety of your modifiers for your users, you can take a look at how the Codepatch modifiers utilize TypeScript.

## Related

`@codepatch/core` is part of the Codepatch family of tools. Codepatch is a collection of tools that make it easy to programmatically make simple modifications to code of various languages.

Check out the [Codepatch repository](https://github.com/loilo/codepatch) to find tools for other languages or information about how to write your own Codepatch modifier.

---
_Source: https://npm.io/package/@codepatch/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
