1+
2+ # node-range-parser
3+
4+ Range header field parser.
5+
6+ ## Example:
7+
8+ ```js
9+ assert(-1 == parse(200, 'bytes=500-20'));
10+ assert(-2 == parse(200, 'bytes=malformed'));
11+ parse(200, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 199 }]));
12+ parse(1000, 'bytes=0-499').should.eql(arr('bytes', [{ start: 0, end: 499 }]));
13+ parse(1000, 'bytes=40-80').should.eql(arr('bytes', [{ start: 40, end: 80 }]));
14+ parse(1000, 'bytes=-500').should.eql(arr('bytes', [{ start: 500, end: 999 }]));
15+ parse(1000, 'bytes=-400').should.eql(arr('bytes', [{ start: 600, end: 999 }]));
16+ parse(1000, 'bytes=500-').should.eql(arr('bytes', [{ start: 500, end: 999 }]));
17+ parse(1000, 'bytes=400-').should.eql(arr('bytes', [{ start: 400, end: 999 }]));
18+ parse(1000, 'bytes=0-0').should.eql(arr('bytes', [{ start: 0, end: 0 }]));
19+ parse(1000, 'bytes=-1').should.eql(arr('bytes', [{ start: 999, end: 999 }]));
20+ parse(1000, 'items=0-5').should.eql(arr('items', [{ start: 0, end: 5 }]));
21+ parse(1000, 'bytes=40-80,-1').should.eql(arr('bytes', [{ start: 40, end: 80 }, { start: 999, end: 999 }]));
22+ ```
23+
24+ ## Installation
25+
26+ ```
27+ $ npm install range-parser
28+ ```
29+
30+ ## License
31+
32+ (The MIT License)
33+
34+ Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
35+
36+ Permission is hereby granted, free of charge, to any person obtaining
37+ a copy of this software and associated documentation files (the
38+ 'Software'), to deal in the Software without restriction, including
39+ without limitation the rights to use, copy, modify, merge, publish,
40+ distribute, sublicense, and/or sell copies of the Software, and to
41+ permit persons to whom the Software is furnished to do so, subject to
42+ the following conditions:
43+
44+ The above copyright notice and this permission notice shall be
45+ included in all copies or substantial portions of the Software.
46+
47+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
48+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
49+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
50+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
51+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
52+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
53+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0 commit comments