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

proto3-json-serializer

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proto3-json-serializer - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

build/src/enum.d.ts
import * as protobuf from 'protobufjs';
import { JSONValue } from './types';
export declare function resolveEnumValueToString(enumType: protobuf.Enum, enumValue: JSONValue): string;
export declare function resolveEnumValueToString(enumType: protobuf.Enum, enumValue: JSONValue): string | number;

@@ -18,6 +18,10 @@ "use strict";

function resolveEnumValueToString(enumType, enumValue) {
// for unknown enum values, do not fail and try to do the best we could.
// protobuf.js fromObject() will likely ignore unknown values, but at least
// we won't fail.
if (typeof enumValue === 'number') {
const value = enumType.valuesById[enumValue];
if (typeof value === 'undefined') {
throw new Error(`enumFromProto3JSON: unknown value id ${enumValue}`);
// unknown value, cannot convert to string, returning number as is
return enumValue;
}

@@ -27,6 +31,3 @@ return value;

if (typeof enumValue === 'string') {
const id = enumType.values[enumValue];
if (typeof id === 'undefined') {
throw new Error(`enumFromProto3JSON: unknown value ${enumValue}`);
}
// for strings, just accept what we got
return enumValue;

@@ -33,0 +34,0 @@ }

# Changelog
### [0.1.3](https://www.github.com/googleapis/proto3-json-serializer-nodejs/compare/v0.1.2...v0.1.3) (2021-08-18)
### Bug Fixes
* do not fail for unknown enum values ([#11](https://www.github.com/googleapis/proto3-json-serializer-nodejs/issues/11)) ([ff9f0f1](https://www.github.com/googleapis/proto3-json-serializer-nodejs/commit/ff9f0f1881b1aafacd693b4e24eaee9e56aff79c))
### [0.1.2](https://www.github.com/googleapis/proto3-json-serializer-nodejs/compare/v0.1.1...v0.1.2) (2021-08-17)

@@ -4,0 +11,0 @@

{
"name": "proto3-json-serializer",
"version": "0.1.2",
"version": "0.1.3",
"repository": "googleapis/proto3-json-serializer-nodejs",

@@ -5,0 +5,0 @@ "description": "Support for proto3 JSON serialiazation/deserialization for protobuf.js",

Sorry, the diff of this file is not supported yet

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