Socket
Socket
Sign inDemoInstall

kiritobuf

Package Overview
Dependencies
434
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    kiritobuf

Interface description language | Kirito


Version published
Maintainers
1
Install size
17.1 MB
Created

Readme

Source

kiritobuf

Interface Description Language | Kirito

Travis Node Version npm

Install

$ npm i kiritobuf --save

Get Started

  1. Define the kirito suffix file
# test

service testService {
  method ping (reqMsg, resMsg)
}

struct reqMsg {
  @1 age = Int16;
  @2 name = Text;
}

struct resMsg {
  @1 age = Int16;
  @2 name = Text;
}
  1. Generate AST
'use strict';

const path = require('path');
const kirito = require('kiritobuf');
const kiritoProto = './test.kirito';

const k = new kirito();

const AST = k.parse(path.join(__dirname, kiritoProto));

console.log(JSON.stringify(AST, null, 2));
  1. AST struct
{
  "type": "Program",
  "body": [
    {
      "type": "StructDeclaration",
      "name": "service",
      "value": "testService",
      "params": [
        {
          "type": "StructDeclaration",
          "name": "method",
          "value": "ping",
          "params": [
            {
              "type": "Identifier",
              "value": "reqMsg"
            },
            {
              "type": "Identifier",
              "value": "resMsg"
            }
          ]
        }
      ]
    },
    {
      "type": "StructDeclaration",
      "name": "struct",
      "value": "reqMsg",
      "params": [
        {
          "type": "VariableDeclaration",
          "name": "@",
          "value": "1",
          "params": [
            {
              "type": "Identifier",
              "value": "age"
            },
            {
              "type": "DataType",
              "value": "Int16"
            }
          ]
        },
        {
          "type": "VariableDeclaration",
          "name": "@",
          "value": "2",
          "params": [
            {
              "type": "Identifier",
              "value": "name"
            },
            {
              "type": "DataType",
              "value": "Text"
            }
          ]
        }
      ]
    },
    {
      "type": "StructDeclaration",
      "name": "struct",
      "value": "resMsg",
      "params": [
        {
          "type": "VariableDeclaration",
          "name": "@",
          "value": "1",
          "params": [
            {
              "type": "Identifier",
              "value": "age"
            },
            {
              "type": "DataType",
              "value": "Int16"
            }
          ]
        },
        {
          "type": "VariableDeclaration",
          "name": "@",
          "value": "2",
          "params": [
            {
              "type": "Identifier",
              "value": "name"
            },
            {
              "type": "DataType",
              "value": "Text"
            }
          ]
        }
      ]
    }
  ]
}

Author

Kiritobuf © Ricky 泽阳, Released under the MIT License.

Keywords

FAQs

Last updated on 02 Aug 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc