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

Commit

Permalink
Merge 21b1654 into 943abb8
Browse files Browse the repository at this point in the history
  • Loading branch information
krzkaczor committed Dec 13, 2018
2 parents 943abb8 + 21b1654 commit 6a2c0f9
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 76 deletions.
12 changes: 1 addition & 11 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
"reporter": [
"lcov",
"text"
],
"include": [
"src/**/*.ts"
],
"extension": [
".ts"
],
"all": true
"extends": "@ethereumjs/config-nyc"
}
6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ matrix:
- os: linux
node_js: "6"
env: TEST_SUITE=lint
- os: linux
node_js: "6"
env: TEST_SUITE=build
script: npm run $TEST_SUITE
2 changes: 1 addition & 1 deletion bin/rlp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const rlp = require('../index.js')
const rlp = require('./dist/index.js')
const command = process.argv[2]
var raw = process.argv[3]

Expand Down
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"name": "rlp",
"version": "2.1.0",
"description": "Recursive Length Prefix Encoding Module",
"main": "index.js",
"directories": {
"test": "test"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist/**",
"bin/**"
],
"scripts": {
"build": "tsc",
"build": "tsc -p ./tsconfig.prod.json",
"coverage": "nyc mocha --reporter spec --require ts-node/register test/index.ts",
"coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
"format": "prettier --list-different **/*.{ts,json,md,gql}",
Expand Down Expand Up @@ -45,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
1 change: 1 addition & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@ethereumjs/config-prettier')
11 changes: 3 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +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 = 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 @@ -101,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
19 changes: 2 additions & 17 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./src",
"outDir": "./dist",
"sourceMap": false,
"declaration": false,
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitAny": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018"]
}
"extends": "@ethereumjs/config-tsc",
"include": ["src/**/*.ts", "test/**/*.ts"]
}
7 changes: 7 additions & 0 deletions tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@ethereumjs/config-tsc",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["src/**/*.ts"]
}
12 changes: 1 addition & 11 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{
"extends": "typestrict",
"rules": {
"no-console": true,
"no-debugger": true,
"mocha-avoid-only": true,
"prefer-const": true,
"no-var-keyword": true,
"interface-name": [true, "never-prefix"],
"no-commented-code": true,
"no-use-before-declare": false
}
"extends": "@ethereumjs/config-tslint"
}

0 comments on commit 6a2c0f9

Please sign in to comment.