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

tsbuffer-validator

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsbuffer-validator - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

2

package.json
{
"name": "tsbuffer-validator",
"version": "0.3.3",
"version": "0.3.4",
"description": "Validator for TSBuffer values",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,2 +13,3 @@ import { TSBufferProto, TSBufferSchema } from "tsbuffer-schema";

isTypeReference(schema: TSBufferSchema): schema is TypeReference;
extendsUnionFields(unionFields: string[], schemas: TSBufferSchema[]): void;
/**

@@ -15,0 +16,0 @@ * 将interface及其引用转换为展平的schema

@@ -94,2 +94,29 @@ "use strict";

};
ProtoHelper.prototype.extendsUnionFields = function (unionFields, schemas) {
for (var i = 0, len = schemas.length; i < len; ++i) {
var schema = schemas[i];
if (this.isTypeReference(schema)) {
schema = this.parseReference(schema);
}
// Interface及其Ref 加入interfaces
if (this.isInterface(schema)) {
var flat = this.getFlatInterfaceSchema(schema);
flat.properties.forEach(function (v) {
if (unionFields.binarySearch(v.name) === -1) {
unionFields.binaryInsert(v.name);
}
});
if (flat.indexSignature) {
var is = "[[" + flat.indexSignature.keyType + "]]";
if (unionFields.binarySearch(is) === -1) {
unionFields.binaryInsert(is);
}
}
}
// Intersection/Union 递归合并unionFields
else if (schema.type === 'Intersection' || schema.type === 'Union') {
var sub = this.extendsUnionFields(unionFields, schema.members.map(function (v) { return v.type; }));
}
}
};
/**

@@ -96,0 +123,0 @@ * 将interface及其引用转换为展平的schema

@@ -45,3 +45,2 @@ import { TSBufferSchema, TSBufferProto } from 'tsbuffer-schema';

validateIntersectionType(value: any, schema: IntersectionTypeSchema, unionFields?: string[]): ValidateResult;
private _extendsUnionFields;
private _isNumberKey;

@@ -48,0 +47,0 @@ private _validateInterfaceOrReference;

@@ -257,3 +257,3 @@ "use strict";

if (!unionFields) {
this._extendsUnionFields(unionFields = [], schema.members.map(function (v) { return v.type; }));
this.protoHelper.extendsUnionFields(unionFields = [], schema.members.map(function (v) { return v.type; }));
}

@@ -290,3 +290,3 @@ // 有一成功则成功

if (!unionFields) {
this._extendsUnionFields(unionFields = [], schema.members.map(function (v) { return v.type; }));
this.protoHelper.extendsUnionFields(unionFields = [], schema.members.map(function (v) { return v.type; }));
}

@@ -322,29 +322,2 @@ // 有一失败则失败

};
TSBufferValidator.prototype._extendsUnionFields = function (unionFields, schemas) {
for (var i = 0, len = schemas.length; i < len; ++i) {
var schema = schemas[i];
if (this.protoHelper.isTypeReference(schema)) {
schema = this.protoHelper.parseReference(schema);
}
// Interface及其Ref 加入interfaces
if (this.protoHelper.isInterface(schema)) {
var flat = this.protoHelper.getFlatInterfaceSchema(schema);
flat.properties.forEach(function (v) {
if (unionFields.binarySearch(v.name) === -1) {
unionFields.binaryInsert(v.name);
}
});
if (flat.indexSignature) {
var is = "[[" + flat.indexSignature.keyType + "]]";
if (unionFields.binarySearch(is) === -1) {
unionFields.binaryInsert(is);
}
}
}
// Intersection/Union 递归合并unionFields
else if (schema.type === 'Intersection' || schema.type === 'Union') {
var sub = this._extendsUnionFields(unionFields, schema.members.map(function (v) { return v.type; }));
}
}
};
TSBufferValidator.prototype._isNumberKey = function (key) {

@@ -351,0 +324,0 @@ var int = parseInt(key);

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