Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
range-parsest
Advanced tools
Range header field parser.
You can install range-parsest
through NPM:
npm i range-parser
import { parse } from "range-parsest";
Parse the given header
string where size
is the size of the selected
representation that is to be partitioned into subranges. A ParseResult will be returned.
Example ParseResult:
// A file of size 255 and a header requesting the first 100 bytes.
const result = parse(255, "bytes=0-100");
// Result is
({
type: "bytes",
ranges: [{ start: 0, end: 100 }],
rangeCount: 1,
});
You can use a destructuring assignment to get these values quickly. For example:
// parse header from request
const { type, ranges } = parse(size, req.headers.range);
// the type of the subranges
if (type === "bytes") {
for (const { start, end } of ranges) {
// do something with start and end
}
}
parse()
method instead.This function is fully compatible with the original range-parser's parseRange. You use the exact same API, but instead of importing it as
var parseRange = require("range-parser");
you import it as
import { parseCompat as parseRange } from "range-parsest";
These properties are accepted in the options parameter of the parse function:
Specifies if overlapping & adjacent subranges should be combined, defaults to
false
. When true
, ranges will be combined and returned as if they were
specified that way in the header.
parseRange(100, "bytes=50-55,0-10,5-10,56-60", { combine: true });
// Results in
({
type: "bytes",
ranges: [
{ start: 50, end: 55 },
{ start: 0, end: 10 },
{ start: 50, end: 60 },
],
rangeCount: 3,
});
MIT
FAQs
Rewrite of the original range-parser package
The npm package range-parsest receives a total of 0 weekly downloads. As such, range-parsest popularity was classified as not popular.
We found that range-parsest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.