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

egg-thing-parser

v1.4.0

Published

thing model parser

Downloads

8

Readme

egg-thing-parser

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-thing-parser --save

Usage

// {app_root}/config/plugin.js
exports.thingParser = {
  enable: true,
  package: 'egg-thing-parser'
};

Configuration

// {app_root}/config/config.default.js
exports.thingParser = {};

see config/config.default.js for more detail.

Example

数据解析

// TLV数据解析:app.thing.tlv.parser.parse(buffer)
// 输入:Buffer
// 输出:
{
  version: "1.0.0",
  id:xxxx, // 消息id,4字节无符号整数
  operations: {
    code: xxxx, // 操作码,1字节无符号整数
    operation: 'response', // 操作类型 'request','response'
    type: 'device', // 设备类型 'device'-普通设备,'subDevice'-子设备
    target: 'resource', // 操作对象 'resource'-资源,'system'-系统
    method:'read', // 操作名 'read', 'write', 'notify', 'reset', 'recovery', 'register', 'deregister','enable','disable','label','upgrade','online','offline'
  }, // 操作码信息
  code: xxxx, // 响应码,1字节无符号整数
  time: "xxxxxx", // 时间戳(插件注入,非设备上报)
  data: {
    groupId: 3, // 组合功能点Id
    params: {
      3: {
        value: {
          1: {
            value: "xxxx",
            type: "boolean", // 数据类型 - ['boolean', 'enum', 'integer', 'float', 'buffer', 'string', 'exception']
            resource: "common", // 资源类型 - ['common'-普通, 'static'-固定, 'combine'-组合]
            message: "property" // 功能点类型 - ['property'-属性, 'event'-事件, 'reserve'-保留字段, 'custom'-自定义]
          }
        },
        type: "buffer",
        resource: "combine",
        message: "property",
      },
      2: {
        value: "xxxx",
        type: "boolean",
        resource: "static",
        message: "property",
      }
    }
  }
}

数据封装

// TLV数据封装: app.thing.tlv.packager.package(json)
// 输出:Buffer
// 输入:
{
  version: '1.0.0', // 版本号:1.0.0
  id: xxxx, // 消息id,4字节无符号整数
  operations: {
    code: xxxx, // 操作码,1字节无符号整数(当code存在时,code的值即为操作码值,否则需要通过method、target、type和operation共同计算出操作码)
    operation: 'response', // 操作类型 'request','response'
    type: 'device', // 设备类型 'device','subDevice'
    target: 'resource', // 操作对象 'resource','system'
    method:'read', // 操作名 'read', 'write', 'notify', 'reset', 'recovery', 'register', 'deregister','enable','disable','label','upgrade','online','offline'
  }, // 操作码信息
  code: xxxx, // 响应码,1字节无符号整数(operation为response时必须传)
  data: {
     groupId: xxxx, // 组合功能点id,2字节无符号整数(当groupId存在时,data为其包含的子功能点数据)
     params: [{
      functionId: xxxx, // 功能点id,2字节无符号整数
      valueType: 'string', // 数据类型 [ 'boolean', 'enum', 'integer', 'float', 'buffer', 'exception', 'string' ]
      value: 'asdf'
    }], // 当method为read且operation为request时,只需传functionId即可
  }
}

Questions & Suggestions

Please open an issue here.

License

MIT