Skip to content

codeverter 1.0.0

Install from the command line:
Learn more about npm packages
$ npm install @southworks/codeverter@1.0.0
Install via package.json:
"@southworks/codeverter": "1.0.0"

About this version

Welcome to Codeverter!

Codeverter is a tool to convert a TypeScript source file (*.ts) into different languages (go or c# by the moment).

Codeverter Build Codeverter tests Codeverter Playground NPM


Playground

If you want to try it, click here!

Installing

NPM

Public registry

npm install -g @southworks/codeverter

Locally

cd ./path-to-codeverter
npm run build:prod
npm install -g

Building

Prerequisites

Dependencies

In order to build the project you must install the required dependencies by running the following command npm install

Compilation

The project is written in TypeScript so you need to call the tsc compiler. To start the compilation process use the command npm run build once finished you will have all the final JavaScript files at ./out folder.

For production use the command npm run build:prod

Testing

To run the available test suites run the command npm test

  • The test framework is Jest so you can use any flag you want. For example: npm test -- -t "constant"

Usage

Command 'cdv'

cdv is the command to execute the tool

For example: cdv --src xxx --lang zzz --dest yyy <path>

Args

--src: Path to the source file or directory.

  • Default value: .

--lang: Target language.

  • Values: csharp | go
  • Default value: go

--dest: Destination

  • Values: console | file
    • file has an extra parameter <destination path>
  • Default value: console

Support

Constants/Variables

Examples

TS C# GO
const CONST_VALUE: string = "THIS IS A CONSTANT"; public const string CONST_VALUE = "THIS IS A CONSTANT"; const CONST_VALUE string = "THIS IS A CONSTANT"
let foo: number = 50; public static int Foo = 50; var Foo int = 50
var foo: number = 50; public static int Foo = 50; var Foo int = 50
  • In C# those are wrapped into a static class
namespace xxx
{
    public static class Helper
    {
        public static int Foo = 50;
    }
}

Support

C# GO
Global Y Y
Function/Constructor body Y Y

Enums

Examples

TS C# GO
export enum Animals {
Dog = 1,
Cat = 2
}
public enum Animals
{
Dog = 1,
Cat = 2
}
const (
Dog int = 1
Cat = 2
)
export enum Animals {
Dog = "dog",
Cat = "cat"
}
public enum Animals
{
Dog = "dog",
Cat = "cat"
}
const (
Dog string = "dog"
Cat = "cat"
)
export enum Animals {
Dog,
Cat
}
public enum Animals {
Dog,
Cat
}
const (
Dog int = iota
Cat
)

Support

C# GO
Numeric Y Y
String Y Y
Implicit Y Y

Interfaces

Examples

TS C# GO
export interface Printable {
content: string;
doPrint(): void;
}
public interface IPrintable
{
string Content { get; set; }
void DoPrint();
}
type Printable interface {
DoPrint()
}

Support

C# GO
Members Y N
Method/Functions Y Y
Inheritance Y N
Implementation Y Y

Classes

Support

C# GO
Inheritance Y Y*
Interfaces Y Y
Visibility Y Y**
Static P P

*In a go way, using composition **Using naming conventions

Constructors

Examples

Consider a class named Cat

TS C# GO
constructor(arg: number) {
/*content*/
}
public Cat(int arg)
{
// /*content*/
}
func NewCat(arg int) *Cat {
c := Cat{}
// /*content*/
return &c
}

Support

C# GO
Visibility Y N
Parameters Y Y
Body AS COMMENT AS COMMENT

Properties

Examples

TS C# GO
public name: string; public string Name { get; set; } Name string
protected name: string; protected string Name { get; set; } name string
private name: string; private string Name { get; set; } name string

Support

C# GO
Visibility Y Y*

*Naming convention for pubic or private, protected is considered private

Methods/Functions

Examples

TS C# GO
public  foo(): void {
/* a lot of work! */
}
public void Foo()
{
///* a lot of work! */
return;
}
func (f *Cat) Foo() {
///* a lot of work! */
return
}

Support

C# GO
Visibility Y Y*
Parameters Y Y
Return type Y Y
Default return value Y Y

*Naming convention for pubic or private, protected is considered private

Details


Assets

  • codeverter-1.0.0.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0