Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
add real packages as dependencies, reformat codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Dec 13, 2018
1 parent 9a082d0 commit 5423792
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .nycrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "ethereumjs-config-nyc"
"extends": "@ethereumjs/config-nyc"
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
"safe-buffer": "^5.1.1"
},
"devDependencies": {
"@ethereumjs/config-nyc": "^1.0.0",
"@ethereumjs/config-prettier": "^1.0.0",
"@ethereumjs/config-tsc": "^1.0.0",
"@ethereumjs/config-tslint": "^1.0.0",
"@types/bn.js": "^4.11.3",
"@types/mocha": "^5.2.5",
"@types/node": "^10.12.2",
Expand Down
2 changes: 1 addition & 1 deletion prettier.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('ethereumjs-config-prettier')
module.exports = require('@ethereumjs/config-prettier')
15 changes: 3 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,8 @@ function encodeLength(len: number, offset: number): Buffer {
**/
export function decode(input: Buffer, stream?: boolean): Buffer
export function decode(input: Buffer[], stream?: boolean): Buffer[]
export function decode(
input: RLPInput,
stream?: boolean,
): Buffer[] | Buffer | RLPDecoded
export function decode(
input: RLPInput,
stream: boolean = false,
): Buffer[] | Buffer | RLPDecoded {
export function decode(input: RLPInput, stream?: boolean): Buffer[] | Buffer | RLPDecoded
export function decode(input: RLPInput, stream: boolean = false): Buffer[] | Buffer | RLPDecoded {
if (!input || (<any>input).length === 0) {
return Buffer.from([])
}
Expand Down Expand Up @@ -105,10 +99,7 @@ export function getLength(input: RLPInput): Buffer | number {
} else {
// a list over 55 bytes long
const llength = firstByte - 0xf6
const length = safeParseInt(
inputBuffer.slice(1, llength).toString('hex'),
16,
)
const length = safeParseInt(inputBuffer.slice(1, llength).toString('hex'), 16)
return llength + length
}
}
Expand Down
10 changes: 1 addition & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import BN from 'bn.js'

export type RLPInput =
| Buffer
| string
| number
| Uint8Array
| BN
| RLPObject
| RLPArray
| null
export type RLPInput = Buffer | string | number | Uint8Array | BN | RLPObject | RLPArray | null

export interface RLPArray extends Array<RLPInput> {}
interface RLPObject {
Expand Down
10 changes: 2 additions & 8 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ describe('nested lists:', function() {
let encoded: Buffer
it('encode a nested list', function() {
encoded = RLP.encode(nestedList)
assert.deepEqual(
encoded,
Buffer.from([0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0]),
)
assert.deepEqual(encoded, Buffer.from([0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0]))
})

it('should decode a nested list', function() {
Expand Down Expand Up @@ -355,10 +352,7 @@ describe('offical tests', function() {
}

const encoded = RLP.encode(incoming)
assert.equal(
encoded.toString('hex'),
officalTests[test].out.toLowerCase(),
)
assert.equal(encoded.toString('hex'), officalTests[test].out.toLowerCase())
}
done()
})
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "ethereumjs-config-tsc",
"extends": "@ethereumjs/config-tsc",
"include": ["src/**/*.ts", "test/**/*.ts"]
}
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "ethereumjs-config-tslint"
"extends": "@ethereumjs/config-tslint"
}

0 comments on commit 5423792

Please sign in to comment.