diff --git a/README.md b/README.md index 2e8b2410..524cd006 100644 --- a/README.md +++ b/README.md @@ -5,17 +5,70 @@ [![Coverage Status](https://img.shields.io/coveralls/ethereumjs/ethereumjs-util.svg?style=flat-square)](https://coveralls.io/r/ethereumjs/ethereumjs-util) [![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode -A collection of utility functions for ethereum. It can be used in node.js or can be in the browser with browserify. +A collection of utility functions for Ethereum. It can be used in Node.js and in the browser with [browserify](http://browserify.org/). + +# INSTALL + +`npm install ethereumjs-util` + +# USAGE + +```js +import assert from 'assert' +import { isValidChecksumAddress, unpad, BN } from 'ethereumjs-util' + +const address = '0x2F015C60E0be116B1f0CD534704Db9c92118FB6A' +assert.ok(isValidChecksumAddress(address)) + +assert.equal(unpad('0000000006600'), '6600') + +assert.equal(new BN('dead', 16).add(new BN('101010', 2)), 57047) +``` # API -[./docs/](./docs/README.md) +## Documentation + +### Modules + +- [account](docs/modules/_account_.md) + - Private/public key and address-related functionality (creation, validation, conversion) +- [bytes](docs/modules/_bytes_.md) + - Byte-related helper and conversion functions +- [constants](docs/modules/_constants_.md) + - Exposed constants + - e.g. KECCAK256_NULL_S for string representation of Keccak-256 hash of null +- [hash](docs/modules/_hash_.md) + - Hash functions +- [object](docs/modules/_object_.md) + - Helper function for creating a binary object (`DEPRECATED`) +- [signature](docs/modules/_signature_.md) + - Signing, signature validation, conversion, recovery +- [externals](docs/modules/_externals_.md) + - Helper methods from `ethjs-util` + - Re-exports of `BN`, `rlp`, `secp256k1` + +### ethjs-util methods + +The following methods are available provided by [ethjs-util](https://github.com/ethjs/ethjs-util): -Most of the string manipulation methods are provided by [ethjs-util](https://github.com/ethjs/ethjs-util) +- arrayContainsArray +- toBuffer +- getBinarySize +- stripHexPrefix +- isHexPrefixed +- isHexString +- padToEven +- intToHex +- fromAscii +- fromUtf8 +- toUtf8 +- toAscii +- getKeys ---- +### Re-Exports -Additionally ethereumjs-util re-exports a few commonly-used libraries. These include: +Additionally `ethereumjs-util` re-exports a few commonly-used libraries. These include: - `BN` ([bn.js](https://github.com/indutny/bn.js)) - `rlp` ([rlp](https://github.com/ethereumjs/rlp)) diff --git a/docs/modules/_externals_.md b/docs/modules/_externals_.md index e9503464..8fb47642 100644 --- a/docs/modules/_externals_.md +++ b/docs/modules/_externals_.md @@ -3,5 +3,5 @@ # Module: "externals" Re-exports commonly used modules: -* Adds [`ethjsUtil`](https://github.com/ethjs/ethjs-util) methods. -* Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)`. +* Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods. +* Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/). diff --git a/src/externals.ts b/src/externals.ts index fba9626c..8e5b729f 100644 --- a/src/externals.ts +++ b/src/externals.ts @@ -1,7 +1,7 @@ /** * Re-exports commonly used modules: - * * Adds [`ethjsUtil`](https://github.com/ethjs/ethjs-util) methods. - * * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/)`. + * * Adds [`ethjs-util`](https://github.com/ethjs/ethjs-util) methods. + * * Exports [`BN`](https://github.com/indutny/bn.js), [`rlp`](https://github.com/ethereumjs/rlp), [`secp256k1`](https://github.com/cryptocoinjs/secp256k1-node/). * @packageDocumentation */