Socket
Socket
Sign inDemoInstall

@eth-optimism/core-utils

Package Overview
Dependencies
Maintainers
5
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eth-optimism/core-utils - npm Package Compare versions

Comparing version 0.0.1-alpha.17 to 0.0.1-alpha.18

build/test/app/buffer.spec.js

22

build/src/app/buffer.js

@@ -39,5 +39,6 @@ "use strict";

const numberToBuffer = (num, numBytes = 4, bufferBytes = 32, bigEndian = true) => {
const buf = Buffer.alloc(bufferBytes);
const minBytes = Math.max(bufferBytes, numBytes);
const buf = Buffer.alloc(minBytes);
if (bigEndian) {
buf.writeIntBE(num, bufferBytes - numBytes, numBytes);
buf.writeIntBE(num, minBytes - numBytes, numBytes);
}

@@ -49,2 +50,18 @@ else {

};
const numberToBufferPacked = (num, minLength = 1) => {
const buf = Buffer.alloc(4);
buf.writeInt32BE(num, 0);
return removeEmptyBytes(buf, minLength);
};
const removeEmptyBytes = (buf, minLength) => {
let firstNonZeroIndex = 0;
while (firstNonZeroIndex < buf.length && buf[firstNonZeroIndex] === 0) {
firstNonZeroIndex++;
}
const startIndex = Math.min(firstNonZeroIndex, buf.length - 1);
const index = buf.length - startIndex < minLength ? buf.length - minLength : startIndex;
return index < 0
? Buffer.concat([Buffer.from('00'.repeat(0 - index), 'hex'), buf])
: buf.slice(index);
};
const numbersEqual = (first, second) => {

@@ -78,2 +95,3 @@ const firstString = misc_1.remove0x(misc_1.bufToHexString(first));

numberToBuffer,
numberToBufferPacked,
numbersEqual,

@@ -80,0 +98,0 @@ bufferToAddress,

4

package.json
{
"name": "@eth-optimism/core-utils",
"version": "0.0.1-alpha.17",
"version": "0.0.1-alpha.18",
"description": "Optimism Core Utils",

@@ -63,3 +63,3 @@ "main": "build/index.js",

},
"gitHead": "80ca22191f0e2233ad27930ee1adfb9655d1fdb8"
"gitHead": "c43809d91ea0371bd618f95551630c27dd65c859"
}
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