# @dashevo/dash-util

> Utility functions for Dash hashes and targets

Latest version **2.0.3** (published 2018-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dashevo/dash-util
pnpm add @dashevo/dash-util
yarn add @dashevo/dash-util
bun add @dashevo/dash-util
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2018-04-27 |
| First published | 2018-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt Bell |
| Maintainers | alex-werner, andyfreer, antouhou, cofresi, dreyacosta, kamuela, nmarley, pierrevr, seigler, shumkov, snogcel |
| Keywords | dash, webcoin, util, utils, hash, hashes, target, blockchain, dashevo |

## Links

- npm: https://www.npmjs.com/package/@dashevo/dash-util
- Repository: https://github.com/dashevo/dash-util
- Homepage: https://github.com/dashevo/dash-util#readme
- Issues: https://github.com/dashevo/dash-util/issues
- npm.io page: https://npm.io/package/@dashevo/dash-util

## Dependencies (2)

- [bn.js](https://npm.io/package/bn.js.md) ^4.6.4
- [buffer-reverse](https://npm.io/package/buffer-reverse.md) ^1.0.1

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 2.0.3 (latest) — 2018-04-27

## README

# dash-util

[![npm version](https://img.shields.io/npm/v/dash-util.svg)](https://www.npmjs.com/package/@dashevo/dash-util)
[![Build Status](https://travis-ci.org/dashpay/dash-util.svg?branch=master)](https://travis-ci.org/dashevo/dash-util)
[![Dependency Status](https://david-dm.org/dashpay/dash-util.svg)](https://david-dm.org/dashevo/dash-util)

**Utility functions for Dash hashes and targets**

## Usage

`npm install @dashevo/dash-util`

### Methods

#### `toHash(hex)`

Takes a hex string that contains a Dash hash as input, and returns a Dash-protocol-friendly little-endian Buffer. Throws an error if the hex string is not of length 64 (representing a 256-bit hash).

#### `compressTarget(target)`

Converts the difficulty target `target` to its compact representation (used in the "bits" field in block headers). `target` should be a `Buffer` (little-endian, the zeroes should be at the end). Returns a `number`.

#### `expandTarget(bits)`

Converts the compressed target integer `bits` to its target hash representation. Returns a `Buffer`.

---
_Source: https://npm.io/package/@dashevo/dash-util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
