# @types/sha

> TypeScript definitions for sha

Latest version **3.0.5** (published 2023-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/sha
pnpm add @types/sha
yarn add @types/sha
bun add @types/sha
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.5 |
| Published | 2023-11-22 |
| First published | 2018-12-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51439 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/sha
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha
- npm.io page: https://npm.io/package/@types/sha

## Dependencies (1)

- [@types/node](https://npm.io/package/@types/node.md) *

## Recent versions

- 3.0.5 (latest) — 2023-11-22
- 3.0.1 (ts3.6) — 2021-07-06
- 3.0.0 (ts2.0) — 2019-02-23
- 3.0.4 — 2023-11-07
- 3.0.3 — 2023-10-18
- 3.0.2 — 2023-09-25
- 2.0.0 — 2018-12-18

## README

# Installation
> `npm install --save @types/sha`

# Summary
This package contains type definitions for sha (https://github.com/ForbesLindesay/sha).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/sha/index.d.ts)
````ts
/// <reference types="node" />

import { Transform } from "stream";

export type CheckCallback<R> = (err: Error | null) => R;
export type GetCallback = (err: Error | null, actual: string) => void;

export interface ShaOptions {
    /** defaults to `sha1` and can be any of the algorithms supported by `crypto.createHash` */
    algorithm?: string | undefined;
}

/**
 * Asynchronously check that `fileName` has a "hash" of `expected`. The callback will be called with either `null`
 * or an error (indicating that they did not match).
 */
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
export function check<R>(fileName: string, expected: string, cb: CheckCallback<R>): void | R;
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
export function check<R>(fileName: string, expected: string, options: ShaOptions, cb: CheckCallback<R>): void | R;
/**
 * Synchronously check that `fileName` has a "hash" of `expected`. Throws if they do not match.
 */
export function checkSync(fileName: string, expected: string, options?: ShaOptions): void;
/**
 * Asynchronously get the "hash" of `fileName`. The callback will be called with an optional `error` object and the
 * (lower cased) hex digest of the hash.
 */
export function get(fileName: string, cb: GetCallback): void;
export function get(fileName: string, options: ShaOptions, cb: GetCallback): void;
/** Synchronously get the "hash" of `fileName`. */
export function getSync(fileName: string, options?: ShaOptions): string;
/**
 * Check the hash of a stream without ever buffering it.  This is a pass through stream so you can do things like:
 *
 *     fs.createReadStream('src')
 *       .pipe(sha.stream('expected'))
 *       .pipe(fs.createWriteStream('dest'))
 *
 * `dest` will be a complete copy of `src` and an error will be emitted if the hash did not match `'expected'`.
 */
export function stream(expected: string, options?: ShaOptions): Transform;

````

### Additional Details
 * Last updated: Wed, 22 Nov 2023 00:24:48 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node)

# Credits
These definitions were written by [Oscar Busk](https://github.com/oBusk).

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