npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@factor-sef/cs-to-ts

v1.2.0

Published

This is a simple package to convert C# class to typescript where user have flexibility to configure the library to get desired output.

Downloads

13

Readme

cs-to-ts

License: MIT CI status Package ver.

It is a simple package for converting a C# class to typescript, where the user can flexibly customize the library to get the desired result.

this package was inspired by @YuvrajSagarRana/csharp-to-typescript solution.

Installation

npm i @factor-sef/cs-to-ts

Usage

  1. After installation, you must import this package:
import Parser from '@factor-sef/cs-to-ts';
// or
const Parser = require('@factor-sef/cs-to-ts');
  1. Next, you must create a new parser class:
const parser = new Parser(config)

You can view this config options here

  1. In the end, you can pass any C # class in string format to the conversion method:
const codeForParse = `public class Address {
    public int Id { get; set; }
    public string Street { get; set; }
    public string City { get; set; }
}`

const output = parser.parse(codeForParse);

Output:

export class Address
{
    Id: number;
    Street: string;
    City: string;
}

Configuration

| param | type | default | description | | ----- | ---- | ------- | ----------- | | propertiesToCamelCase | boolean | true | transform properties names to camelCase | | trimPostfixes | string \| string[] | [] | Removes specified postfixes from property names, types & class names. | | recursiveTrimPostfixes | boolean | true | Whether or not trim postfixes recursive. (e.g. with postfixes 'A' & 'B' PersonAAB will become PersonAA when it's false and Person when it's true) | | ignoreInitializer | boolean | true | When true to initializers will be ignored | | removeMethodBodies | boolean | false | If true then method bodies will be removed, else preserve the method body as-is | | removeConstructors | boolean | true | When true to removing class constructor | | methodStyle | 'signature' \| 'lambda' \| 'controller' | 'signature' | 'signature' to emit a method signature. 'lambda' to emit a lambda function. 'controller' to emit a lambda to call an async controller. | | byteArrayToString | boolean | true | true to convert C# byte array type to Typescript string | | dateTypes | string \| string[] | 'Date \| string' | Convert C# types DateTime and DateTimeOffset to selected types | | removeWithModifier | string[] | [] | Remove fields or properties with the given modifiers (Ex. if you want to remove private and internal members set to ['private', 'internal']) | | removeNameRegex | string | null | If setted, any property or field that its name matches the given regex will be removed | | classToInterface | boolean | true | When true to classes will be converted to interfaces | | preserveModifiers | boolean | false | true to preserve fields and property modifiers | | maxBodyDepth | number | 8 | Maximum body depth | | maxExpressionDepth | number | 4 | Maximum expression depth |