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

ethereumjs-util

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-util - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

17

index.js

@@ -53,2 +53,19 @@ const SHA3 = require('sha3')

/**
* pads an array of buffer with trailing zeros till it has `length` bytes
* @method rpad
* @param {Buffer|Array} array
* @param {Integer} length the number of bytes the output should be
* @return {Buffer|Array}
*/
exports.rpad = function (msg, length) {
msg = exports.toBuffer(msg)
if (msg.length < length) {
var buf = exports.zeros(length)
msg.copy(buf)
return buf
}
return msg.slice(-length)
}
/**
* Trims leading zeros from a buffer or an array

@@ -55,0 +72,0 @@ *

2

package.json
{
"name": "ethereumjs-util",
"version": "2.1.0",
"version": "2.2.0",
"description": "a collection of utility functions for Ethereum",

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

@@ -34,2 +34,10 @@ # SYNOPSIS

### `rpad(val, length)`
pads an `array` or `buffer` with trailing zeros till it has `length` bytes
**Parameters**
- `val` - the value to pad
- `length` - the of the resulting value
**Return:** `array` or `buffer`
### `unpad(val)`

@@ -36,0 +44,0 @@ Trims leading zeros from a buffer or an array

@@ -55,2 +55,10 @@ var assert = require('assert')

describe('rpad', function () {
it('should right pad a Buffer', function () {
var buf = new Buffer([9, 9])
var padded = ethUtils.rpad(buf, 3)
assert.equal(padded.toString('hex'), '090900')
})
})
describe('intToHex', function () {

@@ -57,0 +65,0 @@ it('should convert a int to hex', function () {

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