kk-proto
v1.0.1
Published
依赖:protobufjs,是对这个库的一个包装
Downloads
2
Readme
kk-proto
依赖:protobufjs,是对这个库的一个包装
使用说明
浏览器端
npm install kk-proto --save
webpack.config.js
module: {
rules: [{
test: /\.proto$/,
use: 'kk-proto/loader/index.js'
}]
}
const ProtoBuf = require('kk-proto/client')
const proto = require('path to proto')
let message = new ProtoBuf(proto.Message)
message.set({name:"1",email:"xxx"})
const buffer = message.encode()
const decodeMessage = message.decode(buffer)
node端
npm install kk-proto --save
const ProtoBuf = require('kk-proto')
let root = await ProtoBuf.load("path to proto")
let person = root.create('awesomepackage.Person')
person.set({
name:"test",
id:1
})
console.log(person.toJson())