Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

byte-range-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

byte-range-stream - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

src/index.d.ts

26

package.json
{
"name": "byte-range-stream",
"version": "2.0.1",
"version": "3.0.0",
"description": "Create a multipart/byteranges stream based on passed ranges",

@@ -14,3 +14,3 @@ "main": "src/index.js",

"engines": {
"node": ">=4.0.0"
"node": ">=18.0.0"
},

@@ -30,12 +30,14 @@ "keywords": [

"devDependencies": {
"eslint": "^4.11.0",
"eslint-config-prettier": "^2.8.0",
"eslint-config-sanity": "^3.1.0",
"@sanity/semantic-release-preset": "^4.1.4",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-sanity": "^6.0.0",
"express": "^4.16.2",
"jest": "^21.2.1",
"prettier": "^1.8.2",
"pump": "^1.0.3",
"jest": "^29.7.0",
"prettier": "^3.0.3",
"pump": "^3.0.0",
"sprom": "^3.0.0"
},
"dependencies": {
"@types/combined-stream": "^1.0.4",
"combined-stream": "^1.0.5",

@@ -46,3 +48,9 @@ "range-parser": "^1.2.0"

"src/"
]
],
"prettier": {
"bracketSpacing": false,
"printWidth": 100,
"semi": false,
"singleQuote": true
}
}
# byte-range-stream
[![npm version](http://img.shields.io/npm/v/byte-range-stream.svg?style=flat-square)](http://browsenpm.org/package/byte-range-stream)[![Build Status](http://img.shields.io/travis/rexxars/byte-range-stream/master.svg?style=flat-square)](https://travis-ci.org/rexxars/byte-range-stream)
[![npm version](http://img.shields.io/npm/v/byte-range-stream.svg?style=flat-square)](http://browsenpm.org/package/byte-range-stream)

@@ -20,7 +20,7 @@ Create a multipart/byteranges stream based on passed ranges.

const path = require('path')
const ByteRangeStream = require('../')
const ByteRangeStream = require('byte-range-stream')
const filePath = path.join(__dirname, 'example.js')
const totalSize = fs.statSync(filePath).size
const getChunk = range => fs.createReadStream(filePath, {start: range.start, end: range.end})
const getChunk = (range) => fs.createReadStream(filePath, {start: range.start, end: range.end})

@@ -31,3 +31,3 @@ const byteStream = new ByteRangeStream({

totalSize,
contentType: 'text/javascript'
contentType: 'text/javascript',
})

@@ -34,0 +34,0 @@

@@ -57,3 +57,3 @@ 'use strict'

this._numChunks++
this._append(range, next => Promise.resolve(this._options.getChunk(range)).then(next), isLast)
this._append(range, (next) => Promise.resolve(this._options.getChunk(range)).then(next), isLast)
})

@@ -67,22 +67,22 @@

ByteRangeStream.prototype.isValid = function() {
ByteRangeStream.prototype.isValid = function () {
return this._isValid
}
ByteRangeStream.prototype.isSatisfiable = function() {
ByteRangeStream.prototype.isSatisfiable = function () {
return this._isSatisfiable
}
ByteRangeStream.prototype.getRanges = function() {
ByteRangeStream.prototype.getRanges = function () {
return this._ranges
}
ByteRangeStream.prototype.getHeaders = function() {
ByteRangeStream.prototype.getHeaders = function () {
return {
'Content-Type': `multipart/byteranges; boundary=${this.getBoundary()}`,
'Content-Length': this.getLength()
'Content-Length': this.getLength(),
}
}
ByteRangeStream.prototype.getBoundary = function() {
ByteRangeStream.prototype.getBoundary = function () {
if (!this._boundary) {

@@ -95,7 +95,7 @@ this._generateBoundary()

ByteRangeStream.prototype.getChunkCount = function() {
ByteRangeStream.prototype.getChunkCount = function () {
return this._numChunks
}
ByteRangeStream.prototype.getLength = function() {
ByteRangeStream.prototype.getLength = function () {
let knownLength = this._overheadLength + this._valueLength

@@ -110,3 +110,3 @@

ByteRangeStream.prototype.toString = function() {
ByteRangeStream.prototype.toString = function () {
return '[object ByteRangeStream]'

@@ -119,3 +119,3 @@ }

ByteRangeStream.prototype._generateBoundary = function() {
ByteRangeStream.prototype._generateBoundary = function () {
// This generates a 50 character boundary similar to those used by Firefox.

@@ -131,3 +131,3 @@ // They are optimized for boyer-moore parsing.

ByteRangeStream.prototype._append = function(range, stream, isLast) {
ByteRangeStream.prototype._append = function (range, stream, isLast) {
const append = CombinedStream.prototype.append.bind(this)

@@ -145,12 +145,12 @@

ByteRangeStream.prototype._trackLength = function(header, range) {
this._valueLength += range.end - range.start
ByteRangeStream.prototype._trackLength = function (header, range) {
this._valueLength += range.end - range.start + 1
this._overheadLength += Buffer.byteLength(header) + ByteRangeStream.LINE_BREAK.length
}
ByteRangeStream.prototype._multiPartHeader = function(range, stream) {
ByteRangeStream.prototype._multiPartHeader = function (range, stream) {
const contentType = this._options.contentType || ByteRangeStream.DEFAULT_CONTENT_TYPE
const contentRange = contentRangeString('bytes', this._options.totalSize, range)
const contents = [`Content-Type: ${contentType}`, `Content-Range: ${contentRange}`].join(
ByteRangeStream.LINE_BREAK
ByteRangeStream.LINE_BREAK,
)

@@ -164,7 +164,7 @@

ByteRangeStream.LINE_BREAK,
ByteRangeStream.LINE_BREAK
ByteRangeStream.LINE_BREAK,
].join('')
}
ByteRangeStream.prototype._multiPartFooter = function(isLast) {
ByteRangeStream.prototype._multiPartFooter = function (isLast) {
let footer = ByteRangeStream.LINE_BREAK

@@ -179,3 +179,3 @@

ByteRangeStream.prototype._lastBoundary = function() {
ByteRangeStream.prototype._lastBoundary = function () {
return [this.getBoundary(), '--', ByteRangeStream.LINE_BREAK].join('')

@@ -182,0 +182,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc