@liskhq/lisk-codec
Advanced tools
Comparing version 0.5.0-beta.0 to 0.5.0-rc.0
"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 lisk_validator_1 = require("@liskhq/lisk-validator"); | ||
const msg = 0x80; | ||
const rest = 0x7f; | ||
const writeUInt32 = (value) => { | ||
if (value > lisk_validator_1.MAX_UINT32) { | ||
throw new Error('Value out of range of uint32'); | ||
} | ||
const result = []; | ||
@@ -19,2 +23,5 @@ let index = 0; | ||
const writeSInt32 = (value) => { | ||
if (value > lisk_validator_1.MAX_SINT32) { | ||
throw new Error('Value out of range of sint32'); | ||
} | ||
if (value >= 0) { | ||
@@ -27,2 +34,5 @@ return (0, exports.writeUInt32)(2 * value); | ||
const writeUInt64 = (value) => { | ||
if (value > lisk_validator_1.MAX_UINT64) { | ||
throw new Error('Value out of range of uint64'); | ||
} | ||
const result = []; | ||
@@ -40,2 +50,5 @@ let index = 0; | ||
const writeSInt64 = (value) => { | ||
if (value > lisk_validator_1.MAX_SINT64) { | ||
throw new Error('Value out of range of sint64'); | ||
} | ||
if (value >= BigInt(0)) { | ||
@@ -42,0 +55,0 @@ return (0, exports.writeUInt64)(BigInt(2) * value); |
@@ -75,3 +75,3 @@ /* | ||
const mutation = utils.getRandomBytes(1); | ||
buffer = Buffer.concat([buffer.slice(0, index), mutation, buffer.slice(index)]); | ||
buffer = Buffer.concat([buffer.subarray(0, index), mutation, buffer.subarray(index)]); | ||
} | ||
@@ -84,3 +84,3 @@ // Remove a byte | ||
const index = Math.floor(Math.random() * buffer.length); | ||
buffer = Buffer.concat([buffer.slice(0, index), buffer.slice(index + 1)]); | ||
buffer = Buffer.concat([buffer.subarray(0, index), buffer.subarray(index + 1)]); | ||
} | ||
@@ -87,0 +87,0 @@ |
{ | ||
"name": "@liskhq/lisk-codec", | ||
"version": "0.5.0-beta.0", | ||
"version": "0.5.0-rc.0", | ||
"description": "Implementation of decoder and encoder using Lisk JSON schema according to the Lisk protocol", | ||
@@ -38,5 +38,5 @@ "author": "Lisk Foundation <admin@lisk.com>, lightcurve GmbH <admin@lightcurve.io>", | ||
"dependencies": { | ||
"@liskhq/lisk-cryptography": "^4.1.0-beta.1", | ||
"@liskhq/lisk-utils": "^0.4.0-beta.0", | ||
"@liskhq/lisk-validator": "^0.9.0-beta.0" | ||
"@liskhq/lisk-cryptography": "^4.1.0-rc.0", | ||
"@liskhq/lisk-utils": "^0.4.0-rc.0", | ||
"@liskhq/lisk-validator": "^0.9.0-rc.0" | ||
}, | ||
@@ -64,3 +64,4 @@ "devDependencies": { | ||
"typescript": "5.0.2" | ||
} | ||
}, | ||
"gitHead": "fef17823eb43545360c106386ff20bf0928636bb" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87293
47
1092