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

@vgerbot/channel-transformer

v1.0.1

Published

A typescript transformer which is used to simplify the use of the @vgerbot/channel

Downloads

12

Readme

@vgerbot/channel-transformer

A typescript transformer, which is used to simplify the use of the @vgerbot/channel library. It has the following conversion features:

  • Convert the members of the interface passed to the get_class method to an array:

    // Automatically the generate class id
    interface RmAPI {
        method();
    }
    
    // before:
    chnl.get_class<RmAPI>();
    // after transformed:
    var RmAPIMembers1 = ['method'];
    chnl.get_class('RmAPI', RmAPIMembers1);
    // Use Interface name as class Id
    interface RmAPI {
      method();
    }
    
    // before
    chnl.get_class<RmAPI>('other-RmAPI');
    // after
    var RmAPIMembers1 = ['method'];
    chnl.get_class('other-RmAPI', RmAPIMembers1);
  • Auto-generated class id and passed to def_class method:

    class ClassA {}
    // before
    chnl.def_class(ClassA);
    // after
    chnl.def_class('ClassA', ClassA);
    interface API {
        method();
    }
    class APIImpl implements API{
        method() {}
    }
    // before
    chnl.def_class(APIImpl);
    // after
    chnl.def_class('APIImpl', APIImpl);
  • Auto-generated method id and passed to def_method method:

    // before
    chnl.def_method(function named_method() {});
    // after
    chnl.def_method('named_method', function named_method() {});
    function named_method() {}
    // before
    chnl.def_method(named_method);
    // after
    chnl.def_method('named_method', named_method);
    const named_method = () => {};
    // before
    chnl.def_method(named_method);
    // after
    chnl.def_method('named_method', named_method);

For more examples, please refer to Unit Tests and Snapshots.

Requirement

Typescript >= 3.2.2

Setup

Webpack(with ts-loader or awesome-typescript-loader)

// webpack.config.js
const tschannelTransformer = require('@vgerbot/channel-transformer').default;
module.exports = {
    // ...
    module: {
        rules: [{
            test: /\.tsx?/,
            loader: 'ts-loader', // or 'awesome-typescript-loader'
            options: {
                getCustomTransformers:program => tschannelTransformer(program)
            }
        }]
    }
}

Rollup(with rollup-plugin-typescript2)

// rollup.config.js
import typescript from "rollup-plugin-typescript2";
const tschannelTransformer = require('@vgerbot/channel-transformer').default;
export default {
  // ...
  plugins: [
    typescript({
      transformers: [
        (languageService) => {
            const program = languageService.getProgram();
            return {
                before: [tschannelTransformer(program)]
            };
        }
      ]
    })
  ]
};

ttypescript

tsconfig.json

{
    "compilerOptions": {
        "plugins": [{
            "transform": "@vgerbot/channel-transformer"
        }]
    }
}

License

License MIT