{"library":"stream-equal","title":"Stream Equal","type":"library","description":"Stream Equal is a Node.js utility package designed to test if two readable streams emit the exact same data. The package is currently stable at version 2.0.1, with recent updates indicating active maintenance, including a fix for CommonJS imports. It operates by comparing streams chunk-by-chunk, pausing them as needed to keep them synchronized. This method is highlighted as being more efficient in terms of memory and CPU usage for large files compared to buffering entire stream contents or computing cryptographic hashes, especially when the streams are not equal. Its primary application is in testing scenarios where stream content verification is crucial, offering a performance-optimized alternative to traditional comparison methods.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install stream-equal"],"cli":null},"imports":["import streamEqual from 'stream-equal';","const streamEqual = require('stream-equal');","const streamEqual = require('stream-equal'); // For CJS modules"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/fent/node-stream-equal","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/stream-equal","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import streamEqual from 'stream-equal';\nimport { Readable } from 'stream';\n\nasync function compareStreams() {\n  // Create two identical streams from buffers\n  const stream1 = Readable.from(Buffer.from('Hello, World!'));\n  const stream2 = Readable.from(Buffer.from('Hello, World!'));\n\n  // Create two different streams\n  const stream3 = Readable.from(Buffer.from('Hello, Universe!'));\n  const stream4 = Readable.from(Buffer.from('Hello, World!'));\n\n  const areEqual1 = await streamEqual(stream1, stream2);\n  console.log('Stream 1 and Stream 2 are equal:', areEqual1); // Expected: true\n\n  const areEqual2 = await streamEqual(stream3, stream4);\n  console.log('Stream 3 and Stream 4 are equal:', areEqual2); // Expected: false\n}\n\ncompareStreams().catch(console.error);","lang":"javascript","description":"Demonstrates how to import and use `streamEqual` with async/await to compare two readable streams, showing both equal and unequal cases.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}