@datastream/digest
Advanced tools
+2
-2
@@ -0,3 +1,3 @@ | ||
| import { createHash } from "node:crypto"; | ||
| import { createPassThroughStream } from "@datastream/core"; | ||
| import { createHash } from "node:crypto"; | ||
| const algorithmMap = { | ||
@@ -8,3 +8,3 @@ "SHA2-256": "SHA256", | ||
| }; | ||
| const digestStream = ({ algorithm, resultKey }, streamOptions) => { | ||
| const digestStream = ({ algorithm, resultKey }, streamOptions = {}) => { | ||
| const hash = createHash(algorithmMap[algorithm] ?? algorithm); | ||
@@ -11,0 +11,0 @@ const passThrough = (chunk) => { |
| { | ||
| "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 = ({ algorithm, resultKey }, streamOptions) => {\n const hash = createHash(algorithmMap[algorithm] ?? algorithm)\n const passThrough = (chunk) => {\n hash.update(chunk)\n }\n const stream = createPassThroughStream(passThrough, 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,SAAS,+BAA+B;AACxC,SAAS,kBAAkB;AAE3B,MAAM,eAAe;AAAA,EACnB,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;AAEO,MAAM,eAAe,CAAC,EAAE,WAAW,UAAU,GAAG,kBAAkB;AACvE,QAAM,OAAO,WAAW,aAAa,SAAS,KAAK,SAAS;AAC5D,QAAM,cAAc,CAAC,UAAU;AAC7B,SAAK,OAAO,KAAK;AAAA,EACnB;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,MAAI;AACJ,SAAO,SAAS,MAAM;AACpB,iBAAa,KAAK,OAAO,KAAK;AAC9B,WAAO;AAAA,MACL,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,IACjC;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAO,qBAAQ;", | ||
| "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;", | ||
| "names": [] | ||
| } |
+3
-3
| import { createPassThroughStream } from "@datastream/core"; | ||
| import { | ||
| createSHA3, | ||
| createSHA256, | ||
| createSHA384, | ||
| createSHA512, | ||
| createSHA3 | ||
| createSHA512 | ||
| } from "hash-wasm"; | ||
@@ -16,3 +16,3 @@ const algorithms = { | ||
| }; | ||
| const digestStream = async ({ algorithm, resultKey }, streamOptions) => { | ||
| const digestStream = async ({ algorithm, resultKey }, streamOptions = {}) => { | ||
| const hash = await algorithms[algorithm](); | ||
@@ -19,0 +19,0 @@ const passThrough = (chunk) => { |
| { | ||
| "version": 3, | ||
| "sources": ["index.web.js"], | ||
| "sourcesContent": ["import { createPassThroughStream } from '@datastream/core'\nimport {\n createSHA256,\n createSHA384,\n createSHA512,\n createSHA3\n} from 'hash-wasm'\n\nconst algorithms = {\n 'SHA2-256': createSHA256,\n 'SHA2-384': createSHA384,\n 'SHA2-512': createSHA512,\n 'SHA3-256': () => createSHA3(256),\n 'SHA3-384': () => createSHA3(384),\n 'SHA3-512': () => createSHA3(512)\n}\n\nexport const digestStream = async ({ algorithm, resultKey }, streamOptions) => {\n const hash = await algorithms[algorithm]()\n const passThrough = (chunk) => {\n hash.update(chunk)\n }\n const stream = createPassThroughStream(passThrough, streamOptions)\n let checksum\n stream.result = () => {\n checksum ??= hash.digest()\n return {\n key: resultKey ?? 'digest',\n value: `${algorithm}:${checksum}`\n }\n }\n return stream\n}\n\nexport default digestStream\n"], | ||
| "mappings": "AAAA,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,aAAa;AAAA,EACjB,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;AAClC;AAEO,MAAM,eAAe,OAAO,EAAE,WAAW,UAAU,GAAG,kBAAkB;AAC7E,QAAM,OAAO,MAAM,WAAW,SAAS,EAAE;AACzC,QAAM,cAAc,CAAC,UAAU;AAC7B,SAAK,OAAO,KAAK;AAAA,EACnB;AACA,QAAM,SAAS,wBAAwB,aAAa,aAAa;AACjE,MAAI;AACJ,SAAO,SAAS,MAAM;AACpB,iBAAa,KAAK,OAAO;AACzB,WAAO;AAAA,MACL,KAAK,aAAa;AAAA,MAClB,OAAO,GAAG,SAAS,IAAI,QAAQ;AAAA,IACjC;AAAA,EACF;AACA,SAAO;AACT;AAEA,IAAO,oBAAQ;", | ||
| "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;", | ||
| "names": [] | ||
| } |
+71
-71
| { | ||
| "name": "@datastream/digest", | ||
| "version": "0.0.40", | ||
| "description": "", | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
| "engineStrict": true, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "main": "./index.web.mjs", | ||
| "module": "./index.web.mjs", | ||
| "exports": { | ||
| ".": { | ||
| "node": { | ||
| "webstream": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| }, | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| } | ||
| } | ||
| }, | ||
| "types": "index.d.ts", | ||
| "files": [ | ||
| "*.mjs", | ||
| "*.cjs", | ||
| "*.map", | ||
| "*.d.ts" | ||
| ], | ||
| "scripts": { | ||
| "test": "npm run test:unit", | ||
| "test:unit": "node --test", | ||
| "test:benchmark": "node __benchmarks__/index.js" | ||
| }, | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "Web Stream API", | ||
| "Node Stream API" | ||
| ], | ||
| "author": { | ||
| "name": "datastream contributors", | ||
| "url": "https://github.com/willfarrell/datastream/graphs/contributors" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "github:willfarrell/datastream", | ||
| "directory": "packages/digest" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/willfarrell/datastream/issues" | ||
| }, | ||
| "homepage": "https://datastream.js.org", | ||
| "dependencies": { | ||
| "@datastream/core": "0.0.40", | ||
| "@datastream/digest": "0.0.40", | ||
| "hash-wasm": "4.11.0" | ||
| }, | ||
| "gitHead": "4dbeb8efee8daea0f19b14573f064afc77499094" | ||
| "name": "@datastream/digest", | ||
| "version": "0.0.41", | ||
| "description": "", | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=22" | ||
| }, | ||
| "engineStrict": true, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "main": "./index.web.mjs", | ||
| "module": "./index.web.mjs", | ||
| "exports": { | ||
| ".": { | ||
| "node": { | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.mjs" | ||
| }, | ||
| "__require": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.node.cjs" | ||
| } | ||
| }, | ||
| "import": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| } | ||
| }, | ||
| "./webstream": { | ||
| "types": "./index.d.ts", | ||
| "default": "./index.web.mjs" | ||
| } | ||
| }, | ||
| "types": "index.d.ts", | ||
| "files": [ | ||
| "*.mjs", | ||
| "*.cjs", | ||
| "*.map", | ||
| "*.d.ts" | ||
| ], | ||
| "scripts": { | ||
| "test": "npm run test:unit", | ||
| "test:unit": "node --test", | ||
| "test:benchmark": "node __benchmarks__/index.js" | ||
| }, | ||
| "license": "MIT", | ||
| "keywords": [ | ||
| "Web Stream API", | ||
| "Node Stream API" | ||
| ], | ||
| "author": { | ||
| "name": "datastream contributors", | ||
| "url": "https://github.com/willfarrell/datastream/graphs/contributors" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "github:willfarrell/datastream", | ||
| "directory": "packages/digest" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/willfarrell/datastream/issues" | ||
| }, | ||
| "homepage": "https://datastream.js.org", | ||
| "dependencies": { | ||
| "@datastream/core": "0.0.41", | ||
| "@datastream/digest": "0.0.41", | ||
| "hash-wasm": "4.12.0" | ||
| }, | ||
| "gitHead": "6ddc0fadabf5f3702a51aebae1fc6b252c6ae8d4" | ||
| } |
| import { createPassThroughStream } from "@datastream/core"; | ||
| import { | ||
| createSHA256, | ||
| createSHA384, | ||
| createSHA512, | ||
| createSHA3 | ||
| } from "hash-wasm"; | ||
| const algorithms = { | ||
| "SHA2-256": createSHA256, | ||
| "SHA2-384": createSHA384, | ||
| "SHA2-512": createSHA512, | ||
| "SHA3-256": () => createSHA3(256), | ||
| "SHA3-384": () => createSHA3(384), | ||
| "SHA3-512": () => createSHA3(512) | ||
| }; | ||
| const digestStream = async ({ algorithm, resultKey }, streamOptions) => { | ||
| const hash = await algorithms[algorithm](); | ||
| const passThrough = (chunk) => { | ||
| hash.update(chunk); | ||
| }; | ||
| const stream = createPassThroughStream(passThrough, streamOptions); | ||
| let checksum; | ||
| stream.result = () => { | ||
| checksum ??= hash.digest(); | ||
| return { | ||
| key: resultKey ?? "digest", | ||
| value: `${algorithm}:${checksum}` | ||
| }; | ||
| }; | ||
| return stream; | ||
| }; | ||
| var index_web_default = digestStream; | ||
| export { | ||
| index_web_default as default, | ||
| digestStream | ||
| }; |
-21
| MIT License | ||
| Copyright (c) 2022 will Farrell | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
6109
-24.79%5
-28.57%64
-36%+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated