Socket
Socket
Sign inDemoInstall

@dxos/codec-protobuf

Package Overview
Dependencies
Maintainers
3
Versions
2980
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dxos/codec-protobuf - npm Package Compare versions

Comparing version 1.1.0-beta.2 to 1.1.0-beta.3

84

dist/codec-protobuf.js

@@ -210,18 +210,8 @@ "use strict";

if (fieldType === 'google.protobuf.Any') {
const encodeAny = any => {
const {
__type_url: typeUrl
} = any;
return {
type_url: typeUrl,
value: this.encodeByType(any, typeUrl)
};
}; // NOTE: Each ANY is separately encoded so that it can be optionally decoded (e.g., if the type is not known).
// NOTE: Each ANY is separately encoded so that it can be optionally decoded (e.g., if the type is not known).
if (value[field]) {
if (repeated) {
object[field] = value[field].map(value => encodeAny(value));
object[field] = value[field].map(value => this._encodeAny(value));
} else {
object[field] = encodeAny(value[field]);
object[field] = this._encodeAny(value[field]);
}

@@ -313,34 +303,7 @@ }

if (fieldType === 'google.protobuf.Any' && options.recursive) {
const decodeAny = any => {
// Test if already decoded.
if (any.__type_url) {
return any;
} // Check known type, otherwise leave decoded ANY object in place.
const {
type_url: typeUrl,
value: buffer
} = any;
const type = this.getType(typeUrl);
if (!type) {
if (options.strict) {
throw new Error(`Unknown type: ${typeUrl}`);
}
return any;
} // Recursively decode the object.
return Object.assign(this.decodeByType(buffer, typeUrl, options), {
__type_url: typeUrl
});
};
if (object[field] !== undefined) {
if (repeated) {
object[field] = object[field].map(any => decodeAny(any));
object[field] = object[field].map(any => this._decodeAny(any, options));
} else {
object[field] = decodeAny(object[field]);
object[field] = this._decodeAny(object[field], options);
}

@@ -354,2 +317,39 @@ }

_encodeAny(any) {
const {
__type_url: typeUrl
} = any;
return {
type_url: typeUrl,
value: this.encodeByType(any, typeUrl)
};
}
_decodeAny(any, options) {
// Test if already decoded.
if (any.__type_url) {
return any;
} // Check known type, otherwise leave decoded ANY object in place.
const {
type_url: typeUrl,
value: buffer
} = any;
const type = this.getType(typeUrl);
if (!type) {
if (options.strict) {
throw new Error(`Unknown type: ${typeUrl}`);
}
return any;
} // Recursively decode the object.
return Object.assign(this.decodeByType(buffer, typeUrl, options), {
__type_url: typeUrl
});
}
}

@@ -356,0 +356,0 @@

{
"name": "@dxos/codec-protobuf",
"version": "1.1.0-beta.2",
"version": "1.1.0-beta.3",
"description": "Value encoding for protobuf.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/dxos/codec-protobuf#readme",

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