@dxos/codec-protobuf
Advanced tools
Comparing version 2.12.20 to 2.12.21
@@ -8,2 +8,9 @@ "use strict"; | ||
const mapping_1 = require("./mapping"); | ||
const OBJECT_CONVERSION_OPTIONS = { | ||
// Represent long integers as strings. | ||
longs: String, | ||
// Will set empty repeated fields to [] instead of undefined. | ||
// TODO(marik-d): Type repeated fields as non-optional arrays. | ||
arrays: true | ||
}; | ||
class Codec { | ||
@@ -20,3 +27,3 @@ constructor(_type, _mapping, _schema) { | ||
decode(data) { | ||
const obj = this._type.toObject(this._type.decode(data)); | ||
const obj = this._type.toObject(this._type.decode(data), OBJECT_CONVERSION_OPTIONS); | ||
return mapping_1.mapMessage(this._type, this._mapping.decode, obj, [this._schema]); | ||
@@ -23,0 +30,0 @@ } |
{ | ||
"name": "@dxos/codec-protobuf", | ||
"version": "2.12.20", | ||
"version": "2.12.21", | ||
"license": "AGPL-3.0", | ||
@@ -5,0 +5,0 @@ "author": "DXOS.org", |
@@ -5,3 +5,3 @@ // | ||
import protobufjs from 'protobufjs'; | ||
import protobufjs, { IConversionOptions } from 'protobufjs'; | ||
@@ -11,2 +11,11 @@ import { BidirectionalMapingDescriptors, mapMessage } from './mapping'; | ||
const OBJECT_CONVERSION_OPTIONS: IConversionOptions = { | ||
// Represent long integers as strings. | ||
longs: String, | ||
// Will set empty repeated fields to [] instead of undefined. | ||
// TODO(marik-d): Type repeated fields as non-optional arrays. | ||
arrays: true | ||
}; | ||
export class Codec<T = any> { | ||
@@ -25,3 +34,3 @@ constructor ( | ||
decode (data: Uint8Array): T { | ||
const obj = this._type.toObject(this._type.decode(data)); | ||
const obj = this._type.toObject(this._type.decode(data), OBJECT_CONVERSION_OPTIONS); | ||
return mapMessage(this._type, this._mapping.decode, obj, [this._schema]); | ||
@@ -28,0 +37,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91766
1171