Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@datastream/digest

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datastream/digest - npm Package Compare versions

Comparing version
0.0.42
to
0.1.4
+25
index.d.ts
// Copyright 2026 will Farrell, and datastream contributors.
// SPDX-License-Identifier: MIT
import type { StreamOptions, StreamResult } from "@datastream/core";
export type DigestAlgorithm =
| "SHA2-256"
| "SHA2-384"
| "SHA2-512"
| "SHA3-256"
| "SHA3-384"
| "SHA3-512";
export function digestStream(
options: {
algorithm: DigestAlgorithm;
resultKey?: string;
},
streamOptions?: StreamOptions,
): Promise<
unknown & {
result: () => StreamResult<string>;
}
>;
export default digestStream;
<div align="center">
<h1>&lt;datastream&gt; `digest`</h1>
<img alt="datastream logo" src="https://raw.githubusercontent.com/willfarrell/datastream/main/docs/img/datastream-logo.svg"/>
<p><strong>Hash and checksum streams.</strong></p>
<p>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-unit.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-unit.yml/badge.svg" alt="GitHub Actions unit test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-dast.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-dast.yml/badge.svg" alt="GitHub Actions dast test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-perf.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-perf.yml/badge.svg" alt="GitHub Actions perf test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-sast.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-sast.yml/badge.svg" alt="GitHub Actions SAST test status"></a>
<a href="https://github.com/willfarrell/datastream/actions/workflows/test-lint.yml"><img src="https://github.com/willfarrell/datastream/actions/workflows/test-lint.yml/badge.svg" alt="GitHub Actions lint test status"></a>
<br/>
<a href="https://www.npmjs.com/package/@datastream/digest"><img alt="npm version" src="https://img.shields.io/npm/v/@datastream/digest.svg"></a>
<a href="https://packagephobia.com/result?p=@datastream/digest"><img src="https://packagephobia.com/badge?p=@datastream/digest" alt="npm install size"></a>
<a href="https://www.npmjs.com/package/@datastream/digest">
<img alt="npm weekly downloads" src="https://img.shields.io/npm/dw/@datastream/digest.svg"></a>
<a href="https://www.npmjs.com/package/@datastream/digest#provenance">
<img alt="npm provenance" src="https://img.shields.io/badge/provenance-Yes-brightgreen"></a>
<br/>
<a href="https://scorecard.dev/viewer/?uri=github.com/willfarrell/datastream"><img src="https://api.scorecard.dev/projects/github.com/willfarrell/datastream/badge" alt="Open Source Security Foundation (OpenSSF) Scorecard"></a>
<a href="https://slsa.dev"><img src="https://slsa.dev/images/gh-badge-level3.svg" alt="SLSA 3"></a>
<a href="https://github.com/willfarrell/datastream/blob/main/docs/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg"></a>
<a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a>
<a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
<a href="https://github.com/willfarrell/datastream/blob/main/package.json#L32">
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-95%25-brightgreen"></a>
</p>
<p>You can read the documentation at: <a href="https://datastream.js.org">https://datastream.js.org</a></p>
</div>
## Install
To install datastream you can use NPM:
```bash
npm install --save @datastream/digest
```
## Documentation and examples
For documentation and examples, refer to the main [datastream monorepo on GitHub](https://github.com/willfarrell/datastream) or [datastream official website](https://datastream.js.org).
## Contributing
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/willfarrell/datastream/issues) or to [submit Pull Requests](https://github.com/willfarrell/datastream/pulls).
## License
Licensed under [MIT License](LICENSE). Copyright (c) 2026 [will Farrell](https://github.com/willfarrell), and [datastream contributors](https://github.com/willfarrell/datastream/graphs/contributors).
+2
-2
{
"version": 3,
"sources": ["index.node.js"],
"sourcesContent": ["import { createHash } from \"node:crypto\";\nimport { createPassThroughStream } from \"@datastream/core\";\n\nconst algorithmMap = {\n\t\"SHA2-256\": \"SHA256\",\n\t\"SHA2-384\": \"SHA384\",\n\t\"SHA2-512\": \"SHA512\",\n};\n\nexport const digestStream = ({ algorithm, resultKey }, streamOptions = {}) => {\n\tconst hash = createHash(algorithmMap[algorithm] ?? algorithm);\n\tconst passThrough = (chunk) => {\n\t\thash.update(chunk);\n\t};\n\tconst stream = createPassThroughStream(passThrough, streamOptions);\n\tlet checksum;\n\tstream.result = () => {\n\t\tchecksum ??= hash.digest(\"hex\");\n\t\treturn {\n\t\t\tkey: resultKey ?? \"digest\",\n\t\t\tvalue: `${algorithm}:${checksum}`,\n\t\t};\n\t};\n\treturn stream;\n};\n\nexport default digestStream;\n"],
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,+BAA+B;AAExC,MAAM,eAAe;AAAA,EACpB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACb;AAEO,MAAM,eAAe,CAAC,EAAE,WAAW,UAAU,GAAG,gBAAgB,CAAC,MAAM;AAC7E,QAAM,OAAO,WAAW,aAAa,SAAS,KAAK,SAAS;AAC5D,QAAM,cAAc,CAAC,UAAU;AAC9B,SAAK,OAAO,KAAK;AAAA,EAClB;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,MAAI;AACJ,SAAO,SAAS,MAAM;AACrB,iBAAa,KAAK,OAAO,KAAK;AAC9B,WAAO;AAAA,MACN,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,IAChC;AAAA,EACD;AACA,SAAO;AACR;AAEA,IAAO,qBAAQ;",
"sourcesContent": ["// Copyright 2026 will Farrell, and datastream contributors.\n// SPDX-License-Identifier: MIT\nimport { createHash } from \"node:crypto\";\nimport { createPassThroughStream } from \"@datastream/core\";\n\nconst algorithmMap = {\n\t\"SHA2-256\": \"SHA256\",\n\t\"SHA2-384\": \"SHA384\",\n\t\"SHA2-512\": \"SHA512\",\n};\n\nexport const digestStream = ({ algorithm, resultKey }, streamOptions = {}) => {\n\tconst hash = createHash(algorithmMap[algorithm] ?? algorithm);\n\tconst passThrough = (chunk) => {\n\t\thash.update(chunk);\n\t};\n\tconst stream = createPassThroughStream(passThrough, streamOptions);\n\tlet checksum;\n\tstream.result = () => {\n\t\tchecksum ??= hash.digest(\"hex\");\n\t\treturn {\n\t\t\tkey: resultKey ?? \"digest\",\n\t\t\tvalue: `${algorithm}:${checksum}`,\n\t\t};\n\t};\n\treturn stream;\n};\n\nexport default digestStream;\n"],
"mappings": "AAEA,SAAS,kBAAkB;AAC3B,SAAS,+BAA+B;AAExC,MAAM,eAAe;AAAA,EACpB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACb;AAEO,MAAM,eAAe,CAAC,EAAE,WAAW,UAAU,GAAG,gBAAgB,CAAC,MAAM;AAC7E,QAAM,OAAO,WAAW,aAAa,SAAS,KAAK,SAAS;AAC5D,QAAM,cAAc,CAAC,UAAU;AAC9B,SAAK,OAAO,KAAK;AAAA,EAClB;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,MAAI;AACJ,SAAO,SAAS,MAAM;AACrB,iBAAa,KAAK,OAAO,KAAK;AAC9B,WAAO;AAAA,MACN,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,IAChC;AAAA,EACD;AACA,SAAO;AACR;AAEA,IAAO,qBAAQ;",
"names": []
}
{
"version": 3,
"sources": ["index.web.js"],
"sourcesContent": ["import { createPassThroughStream } from \"@datastream/core\";\nimport {\n\tcreateSHA3,\n\tcreateSHA256,\n\tcreateSHA384,\n\tcreateSHA512,\n} from \"hash-wasm\";\n\nconst algorithms = {\n\t\"SHA2-256\": createSHA256,\n\t\"SHA2-384\": createSHA384,\n\t\"SHA2-512\": createSHA512,\n\t\"SHA3-256\": () => createSHA3(256),\n\t\"SHA3-384\": () => createSHA3(384),\n\t\"SHA3-512\": () => createSHA3(512),\n};\n\nexport const digestStream = async (\n\t{ algorithm, resultKey },\n\tstreamOptions = {},\n) => {\n\tconst hash = await algorithms[algorithm]();\n\tconst passThrough = (chunk) => {\n\t\thash.update(chunk);\n\t};\n\tconst stream = createPassThroughStream(passThrough, streamOptions);\n\tlet checksum;\n\tstream.result = () => {\n\t\tchecksum ??= hash.digest();\n\t\treturn {\n\t\t\tkey: resultKey ?? \"digest\",\n\t\t\tvalue: `${algorithm}:${checksum}`,\n\t\t};\n\t};\n\treturn stream;\n};\n\nexport default digestStream;\n"],
"mappings": "AAAA,SAAS,+BAA+B;AACxC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,MAAM,aAAa;AAAA,EAClB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY,MAAM,WAAW,GAAG;AAAA,EAChC,YAAY,MAAM,WAAW,GAAG;AAAA,EAChC,YAAY,MAAM,WAAW,GAAG;AACjC;AAEO,MAAM,eAAe,OAC3B,EAAE,WAAW,UAAU,GACvB,gBAAgB,CAAC,MACb;AACJ,QAAM,OAAO,MAAM,WAAW,SAAS,EAAE;AACzC,QAAM,cAAc,CAAC,UAAU;AAC9B,SAAK,OAAO,KAAK;AAAA,EAClB;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,MAAI;AACJ,SAAO,SAAS,MAAM;AACrB,iBAAa,KAAK,OAAO;AACzB,WAAO;AAAA,MACN,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,IAChC;AAAA,EACD;AACA,SAAO;AACR;AAEA,IAAO,oBAAQ;",
"sourcesContent": ["// Copyright 2026 will Farrell, and datastream contributors.\n// SPDX-License-Identifier: MIT\nimport { createPassThroughStream } from \"@datastream/core\";\nimport {\n\tcreateSHA3,\n\tcreateSHA256,\n\tcreateSHA384,\n\tcreateSHA512,\n} from \"hash-wasm\";\n\nconst algorithms = {\n\t\"SHA2-256\": createSHA256,\n\t\"SHA2-384\": createSHA384,\n\t\"SHA2-512\": createSHA512,\n\t\"SHA3-256\": () => createSHA3(256),\n\t\"SHA3-384\": () => createSHA3(384),\n\t\"SHA3-512\": () => createSHA3(512),\n};\n\nexport const digestStream = async (\n\t{ algorithm, resultKey },\n\tstreamOptions = {},\n) => {\n\tconst hash = await algorithms[algorithm]();\n\tconst passThrough = (chunk) => {\n\t\thash.update(chunk);\n\t};\n\tconst stream = createPassThroughStream(passThrough, streamOptions);\n\tlet checksum;\n\tstream.result = () => {\n\t\tchecksum ??= hash.digest();\n\t\treturn {\n\t\t\tkey: resultKey ?? \"digest\",\n\t\t\tvalue: `${algorithm}:${checksum}`,\n\t\t};\n\t};\n\treturn stream;\n};\n\nexport default digestStream;\n"],
"mappings": "AAEA,SAAS,+BAA+B;AACxC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEP,MAAM,aAAa;AAAA,EAClB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY,MAAM,WAAW,GAAG;AAAA,EAChC,YAAY,MAAM,WAAW,GAAG;AAAA,EAChC,YAAY,MAAM,WAAW,GAAG;AACjC;AAEO,MAAM,eAAe,OAC3B,EAAE,WAAW,UAAU,GACvB,gBAAgB,CAAC,MACb;AACJ,QAAM,OAAO,MAAM,WAAW,SAAS,EAAE;AACzC,QAAM,cAAc,CAAC,UAAU;AAC9B,SAAK,OAAO,KAAK;AAAA,EAClB;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,MAAI;AACJ,SAAO,SAAS,MAAM;AACrB,iBAAa,KAAK,OAAO;AACzB,WAAO;AAAA,MACN,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,IAChC;AAAA,EACD;AACA,SAAO;AACR;AAEA,IAAO,oBAAQ;",
"names": []
}
{
"name": "@datastream/digest",
"version": "0.0.42",
"description": "",
"version": "0.1.4",
"description": "Cryptographic hash digest pass-through streams",
"type": "module",

@@ -13,3 +13,3 @@ "engines": {

},
"main": "./index.web.mjs",
"main": "./index.node.mjs",
"module": "./index.web.mjs",

@@ -22,6 +22,2 @@ "exports": {

"default": "./index.node.mjs"
},
"__require": {
"types": "./index.d.ts",
"default": "./index.node.cjs"
}

@@ -42,3 +38,2 @@ },

"*.mjs",
"*.cjs",
"*.map",

@@ -71,7 +66,5 @@ "*.d.ts"

"dependencies": {
"@datastream/core": "0.0.42",
"@datastream/digest": "0.0.42",
"@datastream/core": "0.1.4",
"hash-wasm": "4.12.0"
},
"gitHead": "6ddc0fadabf5f3702a51aebae1fc6b252c6ae8d4"
}
}