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

@liskhq/lisk-codec

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liskhq/lisk-codec - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

7

dist-node/boolean.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeBoolean = (value) => value ? Buffer.from('01', 'hex') : Buffer.from('00', 'hex');
exports.readBoolean = (buffer, offset) => [
exports.readBoolean = exports.writeBoolean = void 0;
const writeBoolean = (value) => value ? Buffer.from('01', 'hex') : Buffer.from('00', 'hex');
exports.writeBoolean = writeBoolean;
const readBoolean = (buffer, offset) => [
buffer[offset] !== 0x00,
1,
];
exports.readBoolean = readBoolean;
//# sourceMappingURL=boolean.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readBytes = exports.writeBytes = void 0;
const varint_1 = require("./varint");
exports.writeBytes = (bytes) => Buffer.concat([varint_1.writeUInt32(bytes.length), bytes]);
exports.readBytes = (buffer, offset) => {
const writeBytes = (bytes) => Buffer.concat([varint_1.writeUInt32(bytes.length), bytes]);
exports.writeBytes = writeBytes;
const readBytes = (buffer, offset) => {
const [byteLength, keySize] = varint_1.readUInt32(buffer, offset);
return [buffer.subarray(offset + keySize, offset + keySize + byteLength), byteLength + keySize];
};
exports.readBytes = readBytes;
//# sourceMappingURL=bytes.js.map

@@ -9,3 +9,3 @@ /// <reference types="node" />

export declare class Codec {
private readonly _compileSchemas;
private _compileSchemas;
addSchema(schema: Schema): boolean;

@@ -18,4 +18,5 @@ encode(schema: Schema, message: object): Buffer;

fromJSON<T = object>(schema: Schema, message: object): T;
clearCache(): void;
private _compileSchema;
}
export declare const codec: Codec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.codec = exports.Codec = exports.validateSchema = void 0;
const lisk_validator_1 = require("@liskhq/lisk-validator");

@@ -8,3 +9,3 @@ const lisk_utils_1 = require("@liskhq/lisk-utils");

const json_wrapper_1 = require("./json_wrapper");
exports.validateSchema = (schema) => {
const validateSchema = (schema) => {
var _a;

@@ -28,2 +29,3 @@ lisk_validator_1.validator.removeSchema(schema.$id);

};
exports.validateSchema = validateSchema;
class Codec {

@@ -76,2 +78,5 @@ constructor() {

}
clearCache() {
this._compileSchemas = {};
}
_compileSchema(schema, compiledSchema, dataPath) {

@@ -78,0 +83,0 @@ if (schema.type === 'object') {

@@ -5,3 +5,3 @@ /// <reference types="node" />

export declare const readObject: (message: Buffer, offset: number, compiledSchema: CompiledSchemasArray, terminateIndex: number) => [GenericObject, number];
export declare const readArray: (message: Buffer, offset: number, compiledSchema: CompiledSchemasArray, terminateIndex: number) => [any[], number];
export declare const writeArray: (compiledSchema: CompiledSchema[], message: unknown[], chunks: Buffer[]) => [Buffer[], number];
export declare const readArray: (message: Buffer, offset: number, compiledSchema: CompiledSchemasArray, terminateIndex: number) => [Array<any>, number];
export declare const writeArray: (compiledSchema: CompiledSchema[], message: Array<unknown>, chunks: Buffer[]) => [Buffer[], number];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeArray = exports.readArray = exports.readObject = exports.writeObject = void 0;
const varint_1 = require("./varint");

@@ -27,3 +28,3 @@ const string_1 = require("./string");

};
exports.writeObject = (compiledSchema, message, chunks) => {
const writeObject = (compiledSchema, message, chunks) => {
let simpleObjectSize = 0;

@@ -69,3 +70,4 @@ for (let i = 0; i < compiledSchema.length; i += 1) {

};
exports.readObject = (message, offset, compiledSchema, terminateIndex) => {
exports.writeObject = writeObject;
const readObject = (message, offset, compiledSchema, terminateIndex) => {
let index = offset;

@@ -119,3 +121,4 @@ const result = {};

};
exports.readArray = (message, offset, compiledSchema, terminateIndex) => {
exports.readObject = readObject;
const readArray = (message, offset, compiledSchema, terminateIndex) => {
let index = offset;

@@ -186,3 +189,4 @@ if (index >= message.length) {

};
exports.writeArray = (compiledSchema, message, chunks) => {
exports.readArray = readArray;
const writeArray = (compiledSchema, message, chunks) => {
if (message.length === 0) {

@@ -231,2 +235,3 @@ return [chunks, 0];

};
exports.writeArray = writeArray;
//# sourceMappingURL=collection.js.map
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./codec"));
__exportStar(require("./codec"), exports);
//# sourceMappingURL=index.js.map

@@ -8,2 +8,2 @@ import { IteratableGenericObject, IteratorReturnValue, SchemaProps } from './types';

};
export declare const recursiveTypeCast: (mode: "toJSON" | "fromJSON", object: IteratableGenericObject, schema: SchemaProps, dataPath: string[]) => void;
export declare const recursiveTypeCast: (mode: 'toJSON' | 'fromJSON', object: IteratableGenericObject, schema: SchemaProps, dataPath: string[]) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.recursiveTypeCast = exports.iterator = void 0;
const mappers = {

@@ -40,3 +41,3 @@ toJSON: {

const isObject = (item) => typeof item === 'object' && item !== null && !Array.isArray(item) && !Buffer.isBuffer(item);
exports.iterator = function iterator() {
const iterator = function iterator() {
let index = 0;

@@ -57,3 +58,4 @@ const properties = Object.keys(this);

};
exports.recursiveTypeCast = (mode, object, schema, dataPath) => {
exports.iterator = iterator;
const recursiveTypeCast = (mode, object, schema, dataPath) => {
var _a;

@@ -102,2 +104,3 @@ for (const { key, value } of object) {

};
exports.recursiveTypeCast = recursiveTypeCast;
//# sourceMappingURL=json_wrapper.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readKey = void 0;
const WIRE_TYPE_TWO = 2;
const WIRE_TYPE_ZERO = 0;
exports.readKey = (value) => {
const readKey = (value) => {
const wireType = value & 7;

@@ -13,2 +14,3 @@ if (wireType === WIRE_TYPE_TWO || wireType === WIRE_TYPE_ZERO) {

};
exports.readKey = readKey;
//# sourceMappingURL=keys.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readString = exports.writeString = void 0;
const bytes_1 = require("./bytes");
exports.writeString = (value) => {
const writeString = (value) => {
const stringBuffer = Buffer.from(value, 'utf8');
return bytes_1.writeBytes(stringBuffer);
};
exports.readString = (buffer, offset) => {
exports.writeString = writeString;
const readString = (buffer, offset) => {
const [value, size] = bytes_1.readBytes(buffer, offset);
return [value.toString('utf8'), size];
};
exports.readString = readString;
//# sourceMappingURL=string.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultValue = (dataType) => {
exports.getDefaultValue = void 0;
const getDefaultValue = (dataType) => {
switch (dataType) {

@@ -21,2 +22,3 @@ case 'string':

};
exports.getDefaultValue = getDefaultValue;
//# sourceMappingURL=default_value.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findObjectByPath = (message, pathArr) => {
exports.findObjectByPath = void 0;
const findObjectByPath = (message, pathArr) => {
let result = message;

@@ -13,2 +14,3 @@ for (let i = 0; i < pathArr.length; i += 1) {

};
exports.findObjectByPath = findObjectByPath;
//# sourceMappingURL=find_path.js.map
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./key"));
__export(require("./find_path"));
__exportStar(require("./key"), exports);
__exportStar(require("./find_path"), exports);
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateKey = void 0;
const varint_1 = require("../varint");
exports.generateKey = (schemaProp) => {
const generateKey = (schemaProp) => {
var _a;

@@ -22,2 +23,3 @@ let wireType;

};
exports.generateKey = generateKey;
//# sourceMappingURL=key.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.readSInt64 = exports.readSInt32 = exports.readUInt64 = exports.readUInt32 = exports.writeSInt64 = exports.writeUInt64 = exports.writeSInt32 = exports.writeUInt32 = void 0;
const msg = 0x80;
const rest = 0x7f;
exports.writeUInt32 = (value) => {
const writeUInt32 = (value) => {
const result = [];

@@ -16,3 +17,4 @@ let index = 0;

};
exports.writeSInt32 = (value) => {
exports.writeUInt32 = writeUInt32;
const writeSInt32 = (value) => {
if (value >= 0) {

@@ -23,3 +25,4 @@ return exports.writeUInt32(2 * value);

};
exports.writeUInt64 = (value) => {
exports.writeSInt32 = writeSInt32;
const writeUInt64 = (value) => {
const result = [];

@@ -35,3 +38,4 @@ let index = 0;

};
exports.writeSInt64 = (value) => {
exports.writeUInt64 = writeUInt64;
const writeSInt64 = (value) => {
if (value >= BigInt(0)) {

@@ -42,3 +46,4 @@ return exports.writeUInt64(BigInt(2) * value);

};
exports.readUInt32 = (buffer, offset) => {
exports.writeSInt64 = writeSInt64;
const readUInt32 = (buffer, offset) => {
let result = 0;

@@ -62,3 +67,4 @@ let index = offset;

};
exports.readUInt64 = (buffer, offset) => {
exports.readUInt32 = readUInt32;
const readUInt64 = (buffer, offset) => {
let result = BigInt(0);

@@ -82,3 +88,4 @@ let index = offset;

};
exports.readSInt32 = (buffer, offset) => {
exports.readUInt64 = readUInt64;
const readSInt32 = (buffer, offset) => {
const [varInt, size] = exports.readUInt32(buffer, offset);

@@ -90,3 +97,4 @@ if (varInt % 2 === 0) {

};
exports.readSInt64 = (buffer, offset) => {
exports.readSInt32 = readSInt32;
const readSInt64 = (buffer, offset) => {
const [varInt, size] = exports.readUInt64(buffer, offset);

@@ -98,2 +106,3 @@ if (varInt % BigInt(2) === BigInt(0)) {

};
exports.readSInt64 = readSInt64;
//# sourceMappingURL=varint.js.map
{
"name": "@liskhq/lisk-codec",
"version": "0.1.2",
"version": "0.2.0",
"description": "Implementation of decoder and encoder using Lisk JSON schema according to the Lisk protocol",

@@ -39,27 +39,26 @@ "author": "Lisk Foundation <admin@lisk.io>, lightcurve GmbH <admin@lightcurve.io>",

"dependencies": {
"@liskhq/lisk-utils": "^0.1.0",
"@liskhq/lisk-validator": "^0.5.2"
"@liskhq/lisk-utils": "^0.2.0",
"@liskhq/lisk-validator": "^0.6.0"
},
"devDependencies": {
"@types/jest": "26.0.13",
"@types/jest-when": "2.7.1",
"@types/node": "12.12.11",
"@typescript-eslint/eslint-plugin": "3.10.1",
"@typescript-eslint/parser": "3.10.1",
"@types/jest": "26.0.21",
"@types/jest-when": "2.7.2",
"@types/node": "12.20.6",
"@typescript-eslint/eslint-plugin": "4.19.0",
"@typescript-eslint/parser": "4.19.0",
"benchmark": "2.1.4",
"eslint": "7.8.1",
"eslint-config-lisk-base": "1.2.2",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jest": "24.0.0",
"jest": "26.4.2",
"eslint": "7.22.0",
"eslint-config-lisk-base": "2.0.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.3.2",
"jest": "26.6.3",
"jest-extended": "0.11.5",
"jest-when": "2.7.2",
"prettier": "2.0.5",
"jest-when": "3.2.1",
"prettier": "2.2.1",
"source-map-support": "0.5.19",
"ts-jest": "26.3.0",
"ts-node": "8.6.2",
"ts-jest": "26.5.4",
"ts-node": "9.1.1",
"tsconfig-paths": "3.9.0",
"typescript": "3.8.3"
"typescript": "4.2.3"
}
}

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

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