Gathering detailed insights and metrics for @alexssmusica/peek-readable
Gathering detailed insights and metrics for @alexssmusica/peek-readable
Gathering detailed insights and metrics for @alexssmusica/peek-readable
Gathering detailed insights and metrics for @alexssmusica/peek-readable
A promise based asynchronous stream reader, which makes reading from a stream easy.
npm install @alexssmusica/peek-readable
Typescript
Module System
Min. Node Version
Node Version
NPM Version
70.1
Supply Chain
97.7
Quality
75.2
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Total Downloads
373
Last Day
1
Last Week
7
Last Month
14
Last Year
194
MIT License
8 Stars
887 Commits
7 Forks
2 Watchers
8 Branches
3 Contributors
Updated on May 07, 2025
Latest Version
5.0.0
Package Id
@alexssmusica/peek-readable@5.0.0
Unpacked Size
15.86 kB
Size
4.92 kB
File Count
11
NPM Version
6.14.17
Node Version
14.19.3
Published on
Jul 24, 2023
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
133.3%
7
Compared to previous week
Last Month
-66.7%
14
Compared to previous month
Last Year
8.4%
194
Compared to previous year
20
A promise based asynchronous stream reader, which makes reading from a stream easy.
Allows to read and peek from a Readable Stream
Note that peek-readable was formally released as then-read-stream.
1npm install --save peek-readable
The peek-readable
contains one class: StreamReader
, which reads from a stream.Readable.
Module: version 5 migrated from CommonJS to pure ECMAScript Module (ESM). JavaScript is compliant with ECMAScript 2019 (ES10). Requires Node.js ≥ 14.16 engine.
In the following example we read the first 16 bytes from a stream and store them in our buffer. Source code of examples can be found here.
1import fs from 'node:fs'; 2import { StreamReader } from 'peek-readable'; 3 4(async () => { 5 const readable = fs.createReadStream('JPEG_example_JPG_RIP_001.jpg'); 6 const streamReader = new StreamReader(readable); 7 const uint8Array = new Uint8Array(16); 8 const bytesRead = await streamReader.read(uint8Array, 0, 16);; 9 // buffer contains 16 bytes, if the end-of-stream has not been reached 10})();
End-of-stream detection:
1(async () => { 2 3 const fileReadStream = fs.createReadStream('JPEG_example_JPG_RIP_001.jpg'); 4 const streamReader = new StreamReader(fileReadStream); 5 const buffer = Buffer.alloc(16); // or use: new Uint8Array(16); 6 7 try { 8 await streamReader.read(buffer, 0, 16); 9 // buffer contains 16 bytes, if the end-of-stream has not been reached 10 } catch(error) { 11 if (error instanceof EndOfStreamError) { 12 console.log('End-of-stream reached'); 13 } 14 } 15})();
With peek you can read ahead:
1import fs from 'node:fs'; 2import { StreamReader } from 'peek-readable'; 3 4const fileReadStream = fs.createReadStream('JPEG_example_JPG_RIP_001.jpg'); 5const streamReader = new StreamReader(fileReadStream); 6const buffer = Buffer.alloc(20); 7 8(async () => { 9 let bytesRead = await streamReader.peek(buffer, 0, 3); 10 if (bytesRead === 3 && buffer[0] === 0xFF && buffer[1] === 0xD8 && buffer[2] === 0xFF) { 11 console.log('This is a JPEG file'); 12 } else { 13 throw Error('Expected a JPEG file'); 14 } 15 16 bytesRead = await streamReader.read(buffer, 0, 20); // Read JPEG header 17 if (bytesRead === 20) { 18 console.log('Got the JPEG header'); 19 } else { 20 throw Error('Failed to read JPEG header'); 21 } 22})();
No vulnerabilities found.
Reason
15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
SAST tool is run on all commits
Details
Reason
0 existing vulnerabilities detected
Reason
Found 0/23 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More