Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@protobuf-ts/runtime

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@protobuf-ts/runtime - npm Package Compare versions

Comparing version 2.0.7 to 2.1.0

30

build/commonjs/reflection-json-writer.js

@@ -24,25 +24,17 @@ "use strict";

const json = {}, source = message;
for (const field of this.fields.filter(f => !f.oneof)) {
let jsonValue = this.field(field, source[field.localName], options);
if (jsonValue !== undefined)
json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
}
// flatten all oneof`s
for (const field of this.fields) {
if (!field.oneof)
// field is not part of a oneof, simply write as is
if (!field.oneof) {
let jsonValue = this.field(field, source[field.localName], options);
if (jsonValue !== undefined)
json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
continue;
}
// field is part of a oneof
const group = source[field.oneof];
if (group.oneofKind !== field.localName)
// if field is not selected, skip
continue;
let jsonValue = undefined;
if (field.kind == 'scalar' || field.kind == 'enum')
// for a selected oneof member, we must emit the default value
jsonValue = this.field(field, group[field.localName], {
enumAsInteger: options.enumAsInteger,
useProtoFieldName: options.useProtoFieldName,
emitDefaultValues: true
});
else
jsonValue = this.field(field, group[field.localName], options);
continue; // not selected, skip
const opt = field.kind == 'scalar' || field.kind == 'enum'
? Object.assign(Object.assign({}, options), { emitDefaultValues: true }) : options;
let jsonValue = this.field(field, group[field.localName], opt);
assert_1.assert(jsonValue !== undefined);

@@ -49,0 +41,0 @@ json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;

@@ -21,25 +21,17 @@ import { base64encode } from "./base64";

const json = {}, source = message;
for (const field of this.fields.filter(f => !f.oneof)) {
let jsonValue = this.field(field, source[field.localName], options);
if (jsonValue !== undefined)
json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
}
// flatten all oneof`s
for (const field of this.fields) {
if (!field.oneof)
// field is not part of a oneof, simply write as is
if (!field.oneof) {
let jsonValue = this.field(field, source[field.localName], options);
if (jsonValue !== undefined)
json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;
continue;
}
// field is part of a oneof
const group = source[field.oneof];
if (group.oneofKind !== field.localName)
// if field is not selected, skip
continue;
let jsonValue = undefined;
if (field.kind == 'scalar' || field.kind == 'enum')
// for a selected oneof member, we must emit the default value
jsonValue = this.field(field, group[field.localName], {
enumAsInteger: options.enumAsInteger,
useProtoFieldName: options.useProtoFieldName,
emitDefaultValues: true
});
else
jsonValue = this.field(field, group[field.localName], options);
continue; // not selected, skip
const opt = field.kind == 'scalar' || field.kind == 'enum'
? Object.assign(Object.assign({}, options), { emitDefaultValues: true }) : options;
let jsonValue = this.field(field, group[field.localName], opt);
assert(jsonValue !== undefined);

@@ -46,0 +38,0 @@ json[options.useProtoFieldName ? field.name : field.jsonName] = jsonValue;

{
"name": "@protobuf-ts/runtime",
"version": "2.0.7",
"version": "2.1.0",
"description": "Runtime library for code generated by the protoc plugin \"protobuf-ts\"",

@@ -40,3 +40,3 @@ "license": "(Apache-2.0 AND BSD-3-Clause)",

},
"gitHead": "360626e838b67cbd13937c12bb9669f4de83cc25"
"gitHead": "bc8be3ac6a109d66d3c602b1309e136980933c1d"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc