# fixed-length-stream **Repository Path**: mirrors_mikeal/fixed-length-stream ## Basic Information - **Project Name**: fixed-length-stream - **Description**: A useful stream when parsing protocols. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2025-09-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Fixed Length Stream This is a useful stream for parsing protocols. It will only pass through data until the specified length is reached, end(), and then pass any data past the specified length to a callback. `npm install fixed-length-stream` ## fixed(length[, cb]) ```javascript var fixed = require('fixed-length-stream') , assert = require('assert') , f = fixed(10, function (err, tail) { assert.ok(tail.toString() === 'ok') }) ; f.write(new Buffer('0123456789ok')) f.end() ``` You'll get an error if the stream is ended without satisfying the total length. The stream takes care of ending itself and will also unpipe itself from any streams you've previously piped to it.