New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@barchart/binary-serializer-ts

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@barchart/binary-serializer-ts - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

dist/src/entities/entity-manager.d.ts

18

dist/src/index.d.ts

@@ -10,17 +10,23 @@ export * from './buffers/exceptions/insufficient-capacity-exception';

export * from './buffers/data-writer.interface';
export * from './entities/exceptions/entity-not-found-exception';
export * from './entities/factories/entity-manager-factory';
export * from './entities/keys/entity-key.interface';
export * from './entities/keys/entity-key';
export * from './entities/entity-manager';
export * from './headers/header';
export * from './headers/binary-header-serializer';
export * from './headers/exceptions/invalid-header-exception';
export * from './schemas/collections/schema-item-list';
export * from './schemas/collections/schema-item-list-primitive';
export * from './schemas/exceptions/key-mismatch-exception';
export * from './schemas/exceptions/key-undefined-exception';
export * from './schemas/exceptions/header-mismatch-exception';
export * from './schemas/factories/schema-factory';
export * from './schemas/factories/serialization-schema-factory.interface';
export * from './schemas/schema';
export * from './schemas/schema-definition.interface';
export * from './schemas/collections/schema-item-list';
export * from './schemas/collections/schema-item-list-primitive';
export * from './schemas/schema-field.type';
export * from './schemas/schema-item';
export * from './schemas/schema-item-definition.interface';
export * from './schemas/schema-item-nested';
export * from './schemas/schema-item';
export * from './schemas/schema';
export * from './schemas/schema-field.type';
export * from './serializers/serializer';

@@ -51,2 +57,2 @@ export * from './serializers/serializer-builder';

export * from './types/data-types';
export * from './utilities/utilities';
export * from './utilities/serialization';

@@ -26,17 +26,23 @@ "use strict";

__exportStar(require("./buffers/data-writer.interface"), exports);
__exportStar(require("./entities/exceptions/entity-not-found-exception"), exports);
__exportStar(require("./entities/factories/entity-manager-factory"), exports);
__exportStar(require("./entities/keys/entity-key.interface"), exports);
__exportStar(require("./entities/keys/entity-key"), exports);
__exportStar(require("./entities/entity-manager"), exports);
__exportStar(require("./headers/header"), exports);
__exportStar(require("./headers/binary-header-serializer"), exports);
__exportStar(require("./headers/exceptions/invalid-header-exception"), exports);
__exportStar(require("./schemas/collections/schema-item-list"), exports);
__exportStar(require("./schemas/collections/schema-item-list-primitive"), exports);
__exportStar(require("./schemas/exceptions/key-mismatch-exception"), exports);
__exportStar(require("./schemas/exceptions/key-undefined-exception"), exports);
__exportStar(require("./schemas/exceptions/header-mismatch-exception"), exports);
__exportStar(require("./schemas/factories/schema-factory"), exports);
__exportStar(require("./schemas/factories/serialization-schema-factory.interface"), exports);
__exportStar(require("./schemas/schema"), exports);
__exportStar(require("./schemas/schema-definition.interface"), exports);
__exportStar(require("./schemas/collections/schema-item-list"), exports);
__exportStar(require("./schemas/collections/schema-item-list-primitive"), exports);
__exportStar(require("./schemas/schema-field.type"), exports);
__exportStar(require("./schemas/schema-item"), exports);
__exportStar(require("./schemas/schema-item-definition.interface"), exports);
__exportStar(require("./schemas/schema-item-nested"), exports);
__exportStar(require("./schemas/schema-item"), exports);
__exportStar(require("./schemas/schema"), exports);
__exportStar(require("./schemas/schema-field.type"), exports);
__exportStar(require("./serializers/serializer"), exports);

@@ -67,3 +73,3 @@ __exportStar(require("./serializers/serializer-builder"), exports);

__exportStar(require("./types/data-types"), exports);
__exportStar(require("./utilities/utilities"), exports);
__exportStar(require("./utilities/serialization"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaItemListPrimitive = void 0;
var utilities_1 = require("../../utilities/utilities");
var serialization_1 = require("../../utilities/serialization");
/**

@@ -30,4 +30,4 @@ * Manages the serialization and deserialization of a list or array of primitive declarations associated with an entity

var items = source[this.name];
utilities_1.Serialization.writeMissingFlag(writer, false);
utilities_1.Serialization.writeNullFlag(writer, items === null);
serialization_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeNullFlag(writer, items === null);
if (items === null) {

@@ -38,3 +38,3 @@ return;

items.forEach(function (item) {
utilities_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeMissingFlag(writer, false);
_this.elementSerializer.encode(writer, item);

@@ -45,3 +45,3 @@ });

if (this.getEquals(current, previous)) {
utilities_1.Serialization.writeMissingFlag(writer, true);
serialization_1.Serialization.writeMissingFlag(writer, true);
return;

@@ -51,4 +51,4 @@ }

var previousItems = previous[this.name];
utilities_1.Serialization.writeMissingFlag(writer, false);
utilities_1.Serialization.writeNullFlag(writer, currentItems === null);
serialization_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeNullFlag(writer, currentItems === null);
if (currentItems !== null) {

@@ -59,7 +59,7 @@ this.writeItems(writer, currentItems, previousItems);

SchemaItemListPrimitive.prototype.decode = function (reader, target) {
if (utilities_1.Serialization.readMissingFlag(reader)) {
if (serialization_1.Serialization.readMissingFlag(reader)) {
return;
}
var currentItems = target[this.name];
if (utilities_1.Serialization.readNullFlag(reader)) {
if (serialization_1.Serialization.readNullFlag(reader)) {
if (currentItems !== null) {

@@ -73,3 +73,3 @@ target[this.name] = null;

for (var i = 0; i < itemCount; i++) {
if (utilities_1.Serialization.readMissingFlag(reader)) {
if (serialization_1.Serialization.readMissingFlag(reader)) {
items.push(currentItems[i]);

@@ -124,6 +124,6 @@ }

if (currentItem !== undefined && previousItem !== undefined && this.elementSerializer.getEquals(currentItem, previousItem)) {
utilities_1.Serialization.writeMissingFlag(writer, true);
serialization_1.Serialization.writeMissingFlag(writer, true);
}
else {
utilities_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeMissingFlag(writer, false);
this.elementSerializer.encode(writer, currentItem);

@@ -130,0 +130,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaItemList = void 0;
var utilities_1 = require("../../utilities/utilities");
var serialization_1 = require("../../utilities/serialization");
/**

@@ -30,4 +30,4 @@ * Manages the serialization and deserialization of list or array of complex declarations within a binary data context.

var items = source[this.name];
utilities_1.Serialization.writeMissingFlag(writer, false);
utilities_1.Serialization.writeNullFlag(writer, items === null);
serialization_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeNullFlag(writer, items === null);
if (items === null) {

@@ -39,7 +39,7 @@ return;

if (item !== null) {
utilities_1.Serialization.writeNullFlag(writer, false);
serialization_1.Serialization.writeNullFlag(writer, false);
_this.itemSchema.serialize(writer, item);
}
else {
utilities_1.Serialization.writeNullFlag(writer, true);
serialization_1.Serialization.writeNullFlag(writer, true);
}

@@ -51,3 +51,3 @@ });

if (this.getEquals(current, previous)) {
utilities_1.Serialization.writeMissingFlag(writer, true);
serialization_1.Serialization.writeMissingFlag(writer, true);
return;

@@ -57,4 +57,4 @@ }

var previousItems = previous[this.name];
utilities_1.Serialization.writeMissingFlag(writer, false);
utilities_1.Serialization.writeNullFlag(writer, currentItems === null);
serialization_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeNullFlag(writer, currentItems === null);
if (currentItems === null) {

@@ -65,8 +65,8 @@ return;

currentItems.forEach(function (item, index) {
if (currentItems[index] === null) {
utilities_1.Serialization.writeNullFlag(writer, true);
if (currentItems[index] === null && currentItems.length > index && currentItems[index] === null) {
serialization_1.Serialization.writeNullFlag(writer, true);
return;
}
utilities_1.Serialization.writeNullFlag(writer, false);
if (previousItems != null && previousItems[index] !== null) {
serialization_1.Serialization.writeNullFlag(writer, false);
if (previousItems != null && previousItems.length > index && previousItems[index] !== null) {
_this.itemSchema.serializeChanges(writer, item, previousItems[index]);

@@ -80,6 +80,6 @@ }

SchemaItemList.prototype.decode = function (reader, target) {
if (utilities_1.Serialization.readMissingFlag(reader)) {
if (serialization_1.Serialization.readMissingFlag(reader)) {
return;
}
if (utilities_1.Serialization.readNullFlag(reader)) {
if (serialization_1.Serialization.readNullFlag(reader)) {
target[this.name] = null;

@@ -92,11 +92,11 @@ return;

for (var i = 0; i < count; i++) {
if (utilities_1.Serialization.readNullFlag(reader)) {
if (serialization_1.Serialization.readNullFlag(reader)) {
items.push(null);
}
else {
if (currentItems != null && currentItems.length > i) {
if (currentItems != null && currentItems.length > i && currentItems[i] !== null) {
items.push(this.itemSchema.deserializeChanges(reader, currentItems[i], true));
}
else {
items.push(this.itemSchema.deserialize(reader, true));
items.push(this.itemSchema.deserialize(reader));
}

@@ -103,0 +103,0 @@ }

@@ -17,2 +17,3 @@ import { SerializationSchemaFactory } from "./serialization-schema-factory.interface";

make<TEntity extends object>(entityId: number | undefined, fields: SchemaField[]): SchemaDefinition<TEntity>;
private makeInternal;
private createMemberDataDefinition;

@@ -19,0 +20,0 @@ private createPrimitiveMemberData;

@@ -25,6 +25,12 @@ "use strict";

SchemaFactory.prototype.make = function (entityId, fields) {
if (entityId === void 0) { entityId = 0; }
return this.makeInternal(entityId, fields, false);
};
SchemaFactory.prototype.makeInternal = function (entityId, fields, nested) {
var _this = this;
if (entityId === void 0) { entityId = 0; }
if (!nested && entityId == 0) {
throw new Error("Entity ID cannot be [ 0 ].");
}
var memberDataContainer = fields.map(function (field) {
return _this.createMemberDataDefinition(entityId, field);
return _this.createMemberDataDefinition(field);
});

@@ -34,9 +40,9 @@ memberDataContainer.sort(function (a, b) { return _this.compareSchemaItems(a, b); });

};
SchemaFactory.prototype.createMemberDataDefinition = function (entityId, field) {
SchemaFactory.prototype.createMemberDataDefinition = function (field) {
if (this.isNestedClass(field) && "fields" in field) {
var nestedSchema = this.make(entityId, field.fields);
var nestedSchema = this.makeInternal(0, field.fields, true);
return new schema_item_nested_1.SchemaItemNested(field.name, nestedSchema);
}
if (this.isList(field) && "fields" in field) {
var nestedSchema = this.make(entityId, field.fields);
var nestedSchema = this.makeInternal(0, field.fields, true);
return new schema_item_list_1.SchemaItemList(field.name, nestedSchema);

@@ -43,0 +49,0 @@ }

@@ -43,6 +43,5 @@ import { DataReader } from "../buffers/data-reader.interface";

* @param {DataReader} reader - A buffer of binary data which contains the serialized entity.
* @param {boolean} [isNestedMember] - Optional flag to indicate if the entity is a nested member.
* @returns {TEntity} A new instance of the TEntity class.
*/
deserialize(reader: DataReader, isNestedMember?: boolean): TEntity;
deserialize(reader: DataReader): TEntity;
/**

@@ -49,0 +48,0 @@ * Deserializes an entity, updating an existing instance of the TEntity class.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SchemaItemNested = void 0;
var utilities_1 = require("../utilities/utilities");
var serialization_1 = require("../utilities/serialization");
/**

@@ -27,4 +27,4 @@ * Provides a mechanism for handling the serialization and deserialization of nested properties within an entity,

var nested = source[this.name];
utilities_1.Serialization.writeMissingFlag(writer, false);
utilities_1.Serialization.writeNullFlag(writer, nested === null);
serialization_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeNullFlag(writer, nested === null);
if (nested !== null) {

@@ -36,3 +36,3 @@ this.schema.serialize(writer, nested);

var unchanged = this.getEquals(current, previous);
utilities_1.Serialization.writeMissingFlag(writer, unchanged);
serialization_1.Serialization.writeMissingFlag(writer, unchanged);
if (unchanged) {

@@ -43,3 +43,3 @@ return;

var nestedPrevious = previous[this.name];
utilities_1.Serialization.writeNullFlag(writer, nestedCurrent === null);
serialization_1.Serialization.writeNullFlag(writer, nestedCurrent === null);
if (nestedCurrent === null) {

@@ -56,3 +56,3 @@ return;

SchemaItemNested.prototype.decode = function (reader, target) {
if (utilities_1.Serialization.readMissingFlag(reader)) {
if (serialization_1.Serialization.readMissingFlag(reader)) {
return;

@@ -65,3 +65,3 @@ }

var nested = target[nestedKey];
if (utilities_1.Serialization.readNullFlag(reader)) {
if (serialization_1.Serialization.readNullFlag(reader)) {
if (nested !== null) {

@@ -72,3 +72,3 @@ target[this.name] = null;

else if (nested === null) {
target[this.name] = this.schema.deserialize(reader, true);
target[this.name] = this.schema.deserialize(reader);
}

@@ -75,0 +75,0 @@ else {

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

var key_mismatch_exception_1 = require("./exceptions/key-mismatch-exception");
var utilities_1 = require("../utilities/utilities");
var serialization_1 = require("../utilities/serialization");
/**

@@ -30,3 +30,3 @@ * Information regarding a single piece of data that can be serialized

if (!this.key) {
utilities_1.Serialization.writeMissingFlag(writer, false);
serialization_1.Serialization.writeMissingFlag(writer, false);
}

@@ -45,3 +45,3 @@ var member = source[this.name];

else {
utilities_1.Serialization.writeMissingFlag(writer, true);
serialization_1.Serialization.writeMissingFlag(writer, true);
}

@@ -53,3 +53,3 @@ };

if (!this.key) {
missing = utilities_1.Serialization.readMissingFlag(reader);
missing = serialization_1.Serialization.readMissingFlag(reader);
}

@@ -56,0 +56,0 @@ if (missing) {

@@ -44,2 +44,5 @@ "use strict";

Schema.prototype.serialize = function (writer, source) {
if (source === null) {
throw new Error("source cannot be null");
}
if (writer.bytesWritten === 0) {

@@ -57,2 +60,5 @@ this.headerSerializer.encode(writer, this.entityId, true);

Schema.prototype.serializeChanges = function (writer, current, previous) {
if (previous === null) {
return this.serialize(writer, current);
}
if (writer.bytesWritten === 0) {

@@ -74,2 +80,5 @@ this.headerSerializer.encode(writer, this.entityId, false);

if (existing === void 0) { existing = true; }
if (target === null) {
throw new Error("target cannot be null");
}
if (reader.bytesRead === 0) {

@@ -76,0 +85,0 @@ var header = this.readHeader(reader);

@@ -65,2 +65,10 @@ import { DataReaderFactory } from "../buffers/factories/data-reader-factory.interface";

/**
* Deserializes a header from the `serialized`.
*
* @public
* @param {Uint8Array} serialized - A byte array of binary data which contains the serialized entity.
* @returns {Header} The header of the entity.
*/
readHeader(serialized: Uint8Array): Header;
/**
* Deserializes a key value (only) from the `serialized`.

@@ -76,10 +84,2 @@ *

/**
* Deserializes a header from the `serialized`.
*
* @public
* @param {Uint8Array} serialized - A byte array of binary data which contains the serialized entity.
* @returns {Header} The header of the entity.
*/
readHeader(serialized: Uint8Array): Header;
/**
* Performs a deep equality check of two `TEntity` instances.

@@ -86,0 +86,0 @@ *

@@ -87,24 +87,24 @@ "use strict";

/**
* Deserializes a key value (only) from the `serialized`.
* Deserializes a header from the `serialized`.
*
* @public
* @template TMember - The type of the key value.
* @param {Uint8Array} serialized - A byte array of binary data which contains the serialized entity.
* @param {string} name - The name of the key property.
* @returns {TMember} The value of the key.
* @returns {Header} The header of the entity.
*/
Serializer.prototype.readKey = function (serialized, name) {
Serializer.prototype.readHeader = function (serialized) {
var reader = this.dataBufferReaderFactory.make(serialized);
return this.schema.readKey(reader, name);
return this.schema.readHeader(reader);
};
/**
* Deserializes a header from the `serialized`.
* Deserializes a key value (only) from the `serialized`.
*
* @public
* @template TMember - The type of the key value.
* @param {Uint8Array} serialized - A byte array of binary data which contains the serialized entity.
* @returns {Header} The header of the entity.
* @param {string} name - The name of the key property.
* @returns {TMember} The value of the key.
*/
Serializer.prototype.readHeader = function (serialized) {
Serializer.prototype.readKey = function (serialized, name) {
var reader = this.dataBufferReaderFactory.make(serialized);
return this.schema.readHeader(reader);
return this.schema.readKey(reader, name);
};

@@ -111,0 +111,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BinarySerializerNullable = void 0;
var utilities_1 = require("../utilities/utilities");
var serialization_1 = require("../utilities/serialization");
/**

@@ -18,3 +18,3 @@ * Reads (and writes) nullable values to (and from) a binary data source.

BinarySerializerNullable.prototype.encode = function (writer, value) {
utilities_1.Serialization.writeNullFlag(writer, value === null);
serialization_1.Serialization.writeNullFlag(writer, value === null);
if (value !== null) {

@@ -25,3 +25,3 @@ this.typeSerializer.encode(writer, value);

BinarySerializerNullable.prototype.decode = function (reader) {
if (utilities_1.Serialization.readNullFlag(reader)) {
if (serialization_1.Serialization.readNullFlag(reader)) {
return null;

@@ -28,0 +28,0 @@ }

{
"name": "@barchart/binary-serializer-ts",
"description": "Barchart Binary Serializer (TypeScript)",
"version": "1.1.1",
"version": "1.1.2",
"author": {

@@ -48,3 +48,3 @@ "name": "Luka Sotra",

"@typescript-eslint/parser": "^8.18.1",
"eslint": "^9.16.0",
"eslint": "^9.17.0",
"ts-node": "^10.9.2",

@@ -51,0 +51,0 @@ "typescript": "^5.7.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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