Skip to content

Commit

Permalink
Merge pull request ethereumjs#48 from ethereumjs/kk/remove-utils
Browse files Browse the repository at this point in the history
remove custom util functions, use already existing ones
  • Loading branch information
krzkaczor authored Dec 13, 2018
2 parents f512289 + 9107735 commit 1122ba4
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { RLPInput, RLPDecoded } from './types'
import BN from 'bn.js'
import { isNumber, isString } from 'util'

import { RLPInput, RLPDecoded } from './types'

/**
* RLP Encoding based on: https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP
Expand Down Expand Up @@ -237,7 +239,7 @@ function toBuffer(v: RLPInput): Buffer {
return Buffer.from([])
} else if (v instanceof Uint8Array) {
return Buffer.from(v as any)
} else if (isBN(v)) {
} else if (BN.isBN(v)) {
// converts a BN to a Buffer
return Buffer.from(v.toArray())
} else {
Expand All @@ -246,19 +248,3 @@ function toBuffer(v: RLPInput): Buffer {
}
return v
}

// Check is input is a number
function isString(input: RLPInput): input is string {
return typeof input === 'string'
}

// Check is input is a number
function isNumber(input: RLPInput): input is number {
return typeof input === 'number'
}

// Check if an input is a BigNumber
function isBN(input: RLPInput): input is BN {
if (!input) return false
return !!input.hasOwnProperty('toArray')
}

0 comments on commit 1122ba4

Please sign in to comment.