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

Commit

Permalink
Merge pull request #37 from ethereumjs/typescript
Browse files Browse the repository at this point in the history
Typescript rewrite
  • Loading branch information
holgerd77 authored Dec 14, 2018
2 parents 5849c7b + a3c8ded commit 12eea01
Show file tree
Hide file tree
Showing 17 changed files with 722 additions and 613 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ package-lock.json



dist
.nyc_output
3 changes: 3 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@ethereumjs/config-nyc"
}
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.vscode
package.json
dist
.nyc_output
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
25 changes: 16 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [v2.1.0] - 2018-06-28

- Updated supported Node versions, PR [#13](https://github.com/ethereumjs/rlp/pull/13)
- Switched to ``safe-buffer`` for backwards compatibility, PR [#18](https://github.com/ethereumjs/rlp/pull/18)
- Switched to `safe-buffer` for backwards compatibility, PR [#18](https://github.com/ethereumjs/rlp/pull/18)
- Increased test coverage, PR [#22](https://github.com/ethereumjs/rlp/pull/22)
- Example code tweaks, PR [#12](https://github.com/ethereumjs/rlp/pull/12)
- Fix test runs on Windows, Issue [#7](https://github.com/ethereumjs/rlp/issues/7)
Expand All @@ -17,33 +18,39 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
[v2.1.0]: https://github.com/ethereumjs/rlp/compare/2.0.0...v2.1.0

## [2.0.0] - 2015-09-23
- User ``Buffer`` values as input for encoding

- User `Buffer` values as input for encoding

[2.0.0]: https://github.com/ethereumjs/rlp/compare/1.1.2...2.0.0

## [1.1.2] - 2015-09-22

- Fix zero encoding

[1.1.2]: https://github.com/ethereumjs/rlp/compare/1.1.1...1.1.2

## [1.1.1] - 2015-09-21
- Fixes for ``bin``

- Fixes for `bin`

[1.1.1]: https://github.com/ethereumjs/rlp/compare/1.1.0...1.1.1

## [1.1.0] - 2015-09-21
- Added ``getLength()`` method
- Added hex prefix stripping (``isHexPrefix()`` / ``stripHexPrefix()``)

- Added `getLength()` method
- Added hex prefix stripping (`isHexPrefix()` / `stripHexPrefix()`)
- Code formatting clean-ups

[1.1.0]: https://github.com/ethereumjs/rlp/compare/1.0.1...1.1.0

## [1.0.1] - 2015-06-27

- Code formatting clean-ups

[1.0.1]: https://github.com/ethereumjs/rlp/compare/1.0.0...1.0.1

## [1.0.0] - 2015-06-06

- Added check for invalid 0
- Hardened rlp

Expand All @@ -53,4 +60,4 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)

- [0.0.14](https://github.com/ethereumjs/rlp/compare/0.0.13...0.0.14) - 2015-03-31
- [0.0.13](https://github.com/ethereumjs/rlp/compare/0.0.12...0.0.13) - 2015-03-30
- [0.0.12](https://github.com/ethereumjs/rlp/compare/0.0.11...0.0.12) - 2014-12-26
- [0.0.12](https://github.com/ethereumjs/rlp/compare/0.0.11...0.0.12) - 2014-12-26
52 changes: 23 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,47 @@
SYNOPSIS
=====
# SYNOPSIS

[![NPM Package](https://img.shields.io/npm/v/rlp.svg?style=flat-square)](https://www.npmjs.org/package/rlp)
[![Build Status](https://img.shields.io/travis/ethereumjs/rlp.svg?branch=master&style=flat-square)](https://travis-ci.org/ethereumjs/rlp)
[![Coverage Status](https://img.shields.io/coveralls/ethereumjs/rlp.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/rlp)
[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode

[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)


[Recursive Length](https://github.com/ethereum/wiki/wiki/RLP) Prefix Encoding for node.js.

INSTALL
======
`npm install rlp`
## INSTALL

`npm install rlp`

install with `-g` if you want to use the cli.

USAGE
=======
## USAGE

```javascript
var RLP = require('rlp');
var assert = require('assert');

var nestedList = [ [], [[]], [ [], [[]] ] ];
var encoded = RLP.encode(nestedList);
var decoded = RLP.decode(encoded);
assert.deepEqual(nestedList, decoded);

var RLP = require('rlp')
var assert = require('assert')

var nestedList = [[], [[]], [[], [[]]]]
var encoded = RLP.encode(nestedList)
var decoded = RLP.decode(encoded)
assert.deepEqual(nestedList, decoded)
```

API
=====
## API

`rlp.encode(plain)` - RLP encodes an `Array`, `Buffer` or `String` and returns a `Buffer`.

`rlp.decode(encoded, [skipRemainderCheck=false])` - Decodes an RLP encoded `Buffer`, `Array` or `String` and returns a `Buffer` or an `Array` of `Buffers`. If `skipRemainderCheck` is enabled, `rlp` will just decode the first rlp sequence in the buffer. By default, it would throw an error if there are more bytes in Buffer than used by rlp sequence.

CLI
===
`rlp decode <hex string>`
`rlp encode <json String>`
## CLI

`rlp decode <hex string>`
`rlp encode <json String>`

## TESTS

Test uses mocha. To run tests and linting: `npm test`. To auto fix linting problems use: `npm run test:fix`.

TESTS
=====
Test uses mocha. To run `npm test`
## CODE COVERAGE

CODE COVERAGE
=============
Install dev dependencies
`npm install`

Expand Down
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
Loading

0 comments on commit 12eea01

Please sign in to comment.