# sums

> A checksum generator for Node

Latest version **1.0.0** (published 2017-06-22) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install sums
pnpm add sums
yarn add sums
bun add sums
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-06-22 |
| First published | 2016-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jason Maurer |
| Maintainers | jsonmaur |
| Keywords | stream, checksum, sum, shasum, hash, sha1, sha256, md5, snapshot, filesize |

## Links

- npm: https://www.npmjs.com/package/sums
- Repository: https://github.com/jsonmaur/sums
- Homepage: https://github.com/jsonmaur/sums#readme
- Issues: https://github.com/jsonmaur/sums/issues
- npm.io page: https://npm.io/package/sums

## Dependencies (3)

- [through2](https://npm.io/package/through2.md) 2.0.3
- [is-stream](https://npm.io/package/is-stream.md) 1.1.0
- [concat-stream](https://npm.io/package/concat-stream.md) 1.6.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-06-22
- 0.2.4 — 2016-11-26
- 0.2.3 — 2016-11-26
- 0.2.2 — 2016-11-26
- 0.2.1 — 2016-11-26
- 0.2.0 — 2016-11-26
- 0.1.0 — 2016-10-25
- 0.0.1 — 2016-10-24

## README

# Sums

[![Build Status](https://travis-ci.org/zab/sums.svg?branch=master)](https://travis-ci.org/zab/sums)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

A Node library to quickly generate a checksum for multiple types of data. Works well with streams and files.

## Install

```bash
$ npm install sums
```

## Snapshots

Snapshots are a list of checksums and sizes for each file specified. It will also include a total size of all the files, and a checksum of the snapshot as a whole (e.g. `sum(checksum1:checksum2:checksum3)`) to determine if anything in the list of files has changed.

## Getting Started

#### Generating Checksum

```javascript
const fs = require('fs')
const sums = require('sums')

async function () {
  const stream = fs.createReadStream('path-to-file')
  return await sums.checksum(stream)
}
```

###### Example Response

```javascript
{
  sum: '7c3af16fe22fcb5f79dcd7cae12cf15cb91150c8',
  size: 1070
}
```

#### Generating Snapshot

```javascript
const glob = require('glob')
const sums = require('sums')

async function () {
  const files = glob.sync('**/*')
  return await sums.snapshot(files)
}
```

###### Example Response

```javascript
{
  sum: 'e178bb2a25115a2cb657f57cbd7906f5f89422ba',
  size: 4470,
  snapshot: [
    {
      name: 'path/to/file1',
      sum: '7c3af16fe22fcb5f79dcd7cae12cf15cb91150c8',
      size: 1070
    },
    {
      name: 'path/to/file2',
      sum: 'ca5e739f9c39d1a026de2ca31d6e5c50e0b8e24d',
      size: 3400
    }
  ]
}
```

## API

#### .checksum(stream:Stream, options:Object)

Generate a checksum of a stream.

- `options`
  - `algorithm` The hashing algorithm used to generate checksum (defaults to SHA1)

#### .snapshot(files:Array, options:Object)

Generate a snapshot of a list of files, which gives a size and checksum for each file, and for all of them together.

- `options`
  - `algorithm` The hashing algorithm used to generate checksum (defaults to SHA1)

## License

[MIT](license) © [Jason Maurer](http://maur.co)

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