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.3.0
to
0.3.1
+6
-2
index.d.ts
// Copyright 2026 will Farrell, and datastream contributors.
// SPDX-License-Identifier: MIT
import type { StreamOptions, StreamResult } from "@datastream/core";
import type {
DatastreamPassThrough,
StreamOptions,
StreamResult,
} from "@datastream/core";

@@ -13,3 +17,3 @@ export type DigestAlgorithm =

type DigestStreamResult = unknown & {
type DigestStreamResult = DatastreamPassThrough & {
result: () => StreamResult<string>;

@@ -16,0 +20,0 @@ };

@@ -17,2 +17,5 @@ import { createPassThroughStream } from "@datastream/core";

const digestStream = async ({ algorithm, resultKey }, streamOptions = {}) => {
if (!algorithms[algorithm]) {
throw new Error(`Unsupported algorithm: ${algorithm}`);
}
const hash = await algorithms[algorithm]();

@@ -19,0 +22,0 @@ const passThrough = (chunk) => {

{
"version": 3,
"sources": ["index.web.js"],
"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;",
"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\tif (!algorithms[algorithm]) {\n\t\tthrow new Error(`Unsupported algorithm: ${algorithm}`);\n\t}\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,MAAI,CAAC,WAAW,SAAS,GAAG;AAC3B,UAAM,IAAI,MAAM,0BAA0B,SAAS,EAAE;AAAA,EACtD;AACA,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.3.0",
"version": "0.3.1",
"description": "Cryptographic hash digest pass-through streams",

@@ -63,5 +63,5 @@ "type": "module",

"dependencies": {
"@datastream/core": "0.3.0",
"@datastream/core": "0.3.1",
"hash-wasm": "4.12.0"
}
}