@datastream/digest
Advanced tools
+4
-4
| { | ||
| "name": "@datastream/digest", | ||
| "version": "0.0.12", | ||
| "version": "0.0.14", | ||
| "description": "", | ||
@@ -68,7 +68,7 @@ "type": "module", | ||
| "dependencies": { | ||
| "@datastream/core": "0.0.12", | ||
| "@datastream/digest": "0.0.12", | ||
| "@datastream/core": "0.0.14", | ||
| "@datastream/digest": "0.0.14", | ||
| "hash-wasm": "4.9.0" | ||
| }, | ||
| "gitHead": "e20a0a48431568bec2d53accc8e63e708527edc4" | ||
| "gitHead": "1727c02093df2870d40323f0c476e6bfdc383476" | ||
| } |
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| var index_node_exports = {}; | ||
| __export(index_node_exports, { | ||
| default: () => index_node_default, | ||
| digestStream: () => digestStream | ||
| }); | ||
| module.exports = __toCommonJS(index_node_exports); | ||
| var import_core = require("@datastream/core"); | ||
| var import_node_crypto = require("node:crypto"); | ||
| const algorithmMap = { | ||
| "SHA2-256": "SHA256", | ||
| "SHA2-384": "SHA384", | ||
| "SHA2-512": "SHA512" | ||
| }; | ||
| const digestStream = async ({ algorithm, resultKey }, streamOptions) => { | ||
| const hash = (0, import_node_crypto.createHash)(algorithmMap[algorithm] ?? algorithm); | ||
| const transform = (chunk) => { | ||
| hash.update(chunk); | ||
| }; | ||
| const stream = (0, import_core.createPassThroughStream)(transform, streamOptions); | ||
| let checksum; | ||
| stream.result = () => { | ||
| checksum ??= hash.digest("hex"); | ||
| return { | ||
| key: resultKey ?? "digest", | ||
| value: `${algorithm}:${checksum}` | ||
| }; | ||
| }; | ||
| return stream; | ||
| }; | ||
| var index_node_default = digestStream; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| digestStream | ||
| }); |
| { | ||
| "version": 3, | ||
| "sources": ["index.node.js"], | ||
| "sourcesContent": ["import { createPassThroughStream } from '@datastream/core'\nimport { createHash } from 'node:crypto'\n\nconst algorithmMap = {\n 'SHA2-256': 'SHA256',\n 'SHA2-384': 'SHA384',\n 'SHA2-512': 'SHA512'\n}\n\nexport const digestStream = async ({ algorithm, resultKey }, streamOptions) => {\n const hash = createHash(algorithmMap[algorithm] ?? algorithm)\n const transform = (chunk) => {\n hash.update(chunk)\n }\n const stream = createPassThroughStream(transform, streamOptions)\n let checksum\n stream.result = () => {\n checksum ??= hash.digest('hex')\n return {\n key: resultKey ?? 'digest',\n value: `${algorithm}:${checksum}`\n }\n }\n return stream\n}\n\nexport default digestStream\n"], | ||
| "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwC;AACxC,yBAA2B;AAE3B,MAAM,eAAe;AAAA,EACnB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;AAEO,MAAM,eAAe,OAAO,EAAE,WAAW,UAAU,GAAG,kBAAkB;AAC7E,QAAM,WAAO,+BAAW,aAAa,cAAc,SAAS;AAC5D,QAAM,YAAY,CAAC,UAAU;AAC3B,SAAK,OAAO,KAAK;AAAA,EACnB;AACA,QAAM,aAAS,qCAAwB,WAAW,aAAa;AAC/D,MAAI;AACJ,SAAO,SAAS,MAAM;AACpB,iBAAa,KAAK,OAAO,KAAK;AAC9B,WAAO;AAAA,MACL,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,aAAa;AAAA,IACzB;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAO,qBAAQ;", | ||
| "names": [] | ||
| } |
7138
-30.46%6
-25%64
-44.35%+ Added
- Removed
Updated
Updated