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.9.1 to 2.9.2

2

build/commonjs/message-type.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageType = void 0;
const message_type_contract_1 = require("./message-type-contract");
const reflection_info_1 = require("./reflection-info");

@@ -27,2 +28,3 @@ const reflection_type_check_1 = require("./reflection-type-check");

this.options = options !== null && options !== void 0 ? options : {};
this.messagePrototype = Object.defineProperty({}, message_type_contract_1.MESSAGE_TYPE, { value: this });
this.refTypeCheck = new reflection_type_check_1.ReflectionTypeCheck(this);

@@ -29,0 +31,0 @@ this.refJsonReader = new reflection_json_reader_1.ReflectionJsonReader(this);

@@ -11,4 +11,15 @@ "use strict";

function reflectionCreate(type) {
const msg = {};
Object.defineProperty(msg, message_type_contract_1.MESSAGE_TYPE, { enumerable: false, value: type });
/**
* This ternary can be removed in the next major version.
* The `Object.create()` code path utilizes a new `messagePrototype`
* property on the `IMessageType` which has this same `MESSAGE_TYPE`
* non-enumerable property on it. Doing it this way means that we only
* pay the cost of `Object.defineProperty()` once per `IMessageType`
* class of once per "instance". The falsy code path is only provided
* for backwards compatibility in cases where the runtime library is
* updated without also updating the generated code.
*/
const msg = type.messagePrototype
? Object.create(type.messagePrototype)
: Object.defineProperty({}, message_type_contract_1.MESSAGE_TYPE, { value: type });
for (let field of type.fields) {

@@ -15,0 +26,0 @@ let name = field.localName;

@@ -0,1 +1,2 @@

import { MESSAGE_TYPE } from "./message-type-contract";
import { normalizeFieldInfo } from "./reflection-info";

@@ -24,2 +25,3 @@ import { ReflectionTypeCheck } from "./reflection-type-check";

this.options = options !== null && options !== void 0 ? options : {};
this.messagePrototype = Object.defineProperty({}, MESSAGE_TYPE, { value: this });
this.refTypeCheck = new ReflectionTypeCheck(this);

@@ -26,0 +28,0 @@ this.refJsonReader = new ReflectionJsonReader(this);

@@ -8,4 +8,15 @@ import { reflectionScalarDefault } from "./reflection-scalar-default";

export function reflectionCreate(type) {
const msg = {};
Object.defineProperty(msg, MESSAGE_TYPE, { enumerable: false, value: type });
/**
* This ternary can be removed in the next major version.
* The `Object.create()` code path utilizes a new `messagePrototype`
* property on the `IMessageType` which has this same `MESSAGE_TYPE`
* non-enumerable property on it. Doing it this way means that we only
* pay the cost of `Object.defineProperty()` once per `IMessageType`
* class of once per "instance". The falsy code path is only provided
* for backwards compatibility in cases where the runtime library is
* updated without also updating the generated code.
*/
const msg = type.messagePrototype
? Object.create(type.messagePrototype)
: Object.defineProperty({}, MESSAGE_TYPE, { value: type });
for (let field of type.fields) {

@@ -12,0 +23,0 @@ let name = field.localName;

@@ -52,2 +52,7 @@ import type { FieldInfo, MessageInfo } from "./reflection-info";

/**
* Contains the prototype for messages returned by create() which
* includes the `MESSAGE_TYPE` symbol pointing back to `this`.
*/
readonly messagePrototype?: Readonly<{}>;
/**
* Create a new message with default values.

@@ -54,0 +59,0 @@ *

@@ -38,2 +38,7 @@ import type { IMessageType, PartialMessage } from "./message-type-contract";

readonly options: JsonOptionsMap;
/**
* Contains the prototype for messages returned by create() which
* includes the `MESSAGE_TYPE` symbol pointing back to `this`.
*/
readonly messagePrototype: Readonly<{}> | undefined;
protected readonly defaultCheckDepth = 16;

@@ -40,0 +45,0 @@ protected readonly refTypeCheck: ReflectionTypeCheck;

4

package.json
{
"name": "@protobuf-ts/runtime",
"version": "2.9.1",
"version": "2.9.2",
"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": "15e71e2133631e00e13e570c191186b711377c9b"
"gitHead": "96b4656be1904ff85f285dfe99455ab7bd5e8bc8"
}
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