# enum-converter

> Convert Enums from one language to another

Latest version **1.4.11** (published 2021-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install enum-converter
pnpm add enum-converter
yarn add enum-converter
bun add enum-converter
```

Provides the command `enumc`.

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.11 |
| Published | 2021-10-14 |
| First published | 2018-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 166.7 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Nitzan.o |
| Maintainers | nitzano |
| Keywords | enum-converter, enum, enums, converter, transpiler, enumc |

## Links

- npm: https://www.npmjs.com/package/enum-converter
- Repository: https://github.com/nitzano/enum-converter
- Homepage: https://github.com/nitzano/enum-converter#readme
- Issues: https://github.com/nitzano/enum-converter/issues
- npm.io page: https://npm.io/package/enum-converter

## Dependencies (13)

- [tmp](https://npm.io/package/tmp.md) 0.2.1
- [yargs](https://npm.io/package/yargs.md) 17.2.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [filbert](https://npm.io/package/filbert.md) 0.1.20
- [antlr4ts](https://npm.io/package/antlr4ts.md) ^0.4.1-alpha.0
- [java-ast](https://npm.io/package/java-ast.md) ^0.1.0
- [swap-case](https://npm.io/package/swap-case.md) ^2.0.2
- [lower-case](https://npm.io/package/lower-case.md) ^2.0.2
- [title-case](https://npm.io/package/title-case.md) ^3.0.3
- [typescript](https://npm.io/package/typescript.md) ^4.3.5
- [upper-case](https://npm.io/package/upper-case.md) ^2.0.2
- [change-case](https://npm.io/package/change-case.md) 4.1.2
- [estree-walker](https://npm.io/package/estree-walker.md) 2.0.2

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.4.11 (latest) — 2021-10-14
- 1.3.7-alpha (alpha) — 2021-08-07
- 1.4.10 — 2021-09-27
- 1.4.9 — 2021-09-23
- 1.4.8 — 2021-09-16
- 1.4.7 — 2021-09-16
- 1.4.6 — 2021-09-16
- 1.4.5 — 2021-09-16
- 1.4.4 — 2021-09-16
- 1.4.3 — 2021-09-16
- 1.4.2 — 2021-09-16
- 1.4.1 — 2021-09-16
- 1.3.10 — 2021-09-16
- 1.4.0 — 2021-09-16
- 1.3.9 — 2021-09-16
- … 15 more at https://npm.io/package/enum-converter/versions

## README

<h1 align="center">Enum Converter (enumc)</h1>


<div align="center">

Convert Enums from one language to another.   

Live demo :  https://enum-converter.vercel.app
 ([source](https://github.com/nitzano/enum-converter-demo))

</div>

<div align="center">

[![npm](https://img.shields.io/npm/v/enum-converter)](https://www.npmjs.com/package/enum-converter)
[![npm-next](https://img.shields.io/npm/v/enum-converter/next)](https://www.npmjs.com/package/enum-converter)
[![npm-downloads-week](https://img.shields.io/npm/dw/enum-converter.svg)](https://www.npmjs.com/package/enum-converter)
![test workflow](https://github.com/nitzano/enum-converter/actions/workflows/test.yml/badge.svg)
![release workflow](https://github.com/nitzano/enum-converter/actions/workflows/release.yml/badge.svg)

[![license](https://img.shields.io/github/license/nitzano/enum-converter.svg)](https://github.com/nitzano/enum-converter/blob/master/LICENSE)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

</div>



---

- [Supported languages](#supported-languages)
- [Installation](#installation)
- [Usage](#usage)
  - [CLI](#cli)
  - [API](#api)
- [Options](#options)
  - [Conversion](#conversion)
  - [Styling](#styling)


## Supported languages

* [x] Java
* [x] Json
* [x] Python
* [x] Typescript
* [ ] C/C++
* [ ] C#
* [ ] Go


## Installation

```
npm install -g enum-converter
```

## Usage

### CLI

> ``` enumc <file> [options] ```

```
// convert files
enumc enums.py --to typescript
enumc enums.ts --to python --out my-enums.py
enumc enums.x --from python --to json
enumc enums.py --to typescript --sort-enums asc

// modify existing files
enumc enums.py --modify --name-style kebab --key-style upper 
enumc enums.py --modify --sort-enums=asc --sort-values=value_desc
```

### API

```typescript
import {
  convert,
  EnumsOrder,
  Language,
  modify,
  StringStyle,
  ValuesOrder,
} from 'enum-converter';

// convert files
convert('enums.py', Language.Typescript);

convert('enums.ts', Language.Python, {
  out: 'my-enums.py'
});

convert('enums.x', Language.Json, {
  from: Language.Python
});

convert('enums.py', Language.Typescript, {
  sortEnums: EnumsOrder.Ascending
});

// modify exiting files
modify('enums.py' {
  nameStyle: StringStyle.KebabCase,
  keyStyle: StringStyle.UpperCase,
})

modify('enums.py' {
  sortEnums: EnumsOrder.Ascending,
  sortValues: ValuesOrder.ValueDescending,
})
```


## Options

### Conversion

| Name   | Meaning                    | type     | default |
| ------ | -------------------------- | -------- | ------- |
| from   | source language (explicit) | Language |         |
| to     | destination language       | Language |         |
| out    | destination file           | string   |         |
| modify | modify existing file       | boolean  | false   |


### Styling

| Name           | Meaning                                   | type        | default |
| -------------- | ----------------------------------------- | ----------- | ------- |
| emit-file-name | emit source file name to destination file | boolean     | true    |
| emit-stats     | emit stats to destination file            | boolean     | true    |
| sort-enums     | sort enums in files                       | EnumsOrder  |         |
| sort-values    | sort values in enums                      | ValuesOrder |         |
| key-style      | style enum key string                     | StringStyle |         |
| name-style     | style enum name string                    | StringStyle |         |
| value-style    | style enum value (strings only)           | StringStyle |         |

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