# morphize

> Schema-based object transform & remapping library.

Latest version **0.1.2** (published 2023-02-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install morphize
pnpm add morphize
yarn add morphize
bun add morphize
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-02-16 |
| First published | 2023-02-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sir Eatsalot |
| Maintainers | sireatsalot |

## Links

- npm: https://www.npmjs.com/package/morphize
- npm.io page: https://npm.io/package/morphize

## Dependencies (1)

- [neverthrow](https://npm.io/package/neverthrow.md) ^6.0.0

## Recent versions

- 0.1.2 (latest) — 2023-02-16
- 0.1.1 — 2023-02-16

## README

# Morphize

A (work in progress) [Zod](https://github.com/colinhacks/zod)-inspired object transform & remapping library with static type inference.

## Usage

```ts
import { m } from "morphize";

const schema = m.object({
    example: m.object({
        foo: m.to("bar"),
        test_status: m.enum([0, 1, 2], ["Success", "Pending", "Failed"]).to("testStatus")
    }).to("somewhereElse"),
});

const example = schema.map({
    example: {
        foo: "c:",
        test_status: 0,
    }
});

// returns: 
//{
//    somewhereElse: {
//        bar: "c:",
//        testStatus: "Success"
//    }
//}
```

For type inference, simply use `m.infer<TSchema, TInput>`:

```ts
import { m } from "morphize";

const TestSchema = m.object({
    test: m.to("tested"),
});

type Input = {
    test: string,
    unaffected: boolean
}

type Test = m.infer<typeof TestSchema, Input>; // { tested: string, unaffected: boolean }
```

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