1.4.11 • Published 3 years ago

enum-converter v1.4.11

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

Convert Enums from one language to another.

Live demo : https://enum-converter.vercel.app (source)

npm npm-next npm-downloads-week test workflow release workflow

license semantic-release Commitizen friendly


Supported languages

  • Java
  • Json
  • Python
  • 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

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

NameMeaningtypedefault
fromsource language (explicit)Language
todestination languageLanguage
outdestination filestring
modifymodify existing filebooleanfalse

Styling

NameMeaningtypedefault
emit-file-nameemit source file name to destination filebooleantrue
emit-statsemit stats to destination filebooleantrue
sort-enumssort enums in filesEnumsOrder
sort-valuessort values in enumsValuesOrder
key-stylestyle enum key stringStringStyle
name-stylestyle enum name stringStringStyle
value-stylestyle enum value (strings only)StringStyle
1.4.11

3 years ago

1.4.10

3 years ago

1.4.9

3 years ago

1.4.6

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.10

3 years ago

1.4.8

3 years ago

1.3.9

3 years ago

1.4.7

3 years ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.7-alpha

3 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago