A high-performance Node.js library for efficient reading of large files and streams with advanced buffering capabilities.
- Efficient memory usage with customizable buffer sizes
- Support for large file handling without memory issues
- Stream-based reading capabilities
- Async/await interface for modern JavaScript applications
- Configurable reading strategies
- Comprehensive error handling
# Clone the repository
git clone https://github.com/Singhadarsh2612/BufferedReader.git
# Navigate to the project directory
cd Buffered-Reader
# Install dependencies
npm i
# Build the project
npm run build- Create your environment configuration:
# Copy the example environment file
cp .env.example .env
## 📖 Usage
Start the server:
```bash
node server.cjsconst { BufferedReader } = require("buffered-reader");
async function example() {
const reader = new BufferedReader("/path/to/large/file.txt");
// Read the file in chunks
for await (const chunk of reader.read()) {
console.log(`Read ${chunk.length} bytes`);
// Process chunk...
}
// Or read the entire file at once (not recommended for very large files)
const content = await reader.readAll();
}
example().catch(console.error);The main class for reading files with buffering.
new BufferedReader(filePath, options);filePath- Path to the file to readoptions- Configuration object with the following properties:bufferSize- Size of the buffer in bytes (default: 8192)encoding- File encoding (default: 'utf8')
read()- Returns an async iterator for reading chunksreadAll()- Reads and returns the entire file contentclose()- Closes the reader and releases resources
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.