mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
# add dist
This commit is contained in:
63
ng2-components/ng2-alfresco-documentslist/dist/node_modules/range-parser/index.js
generated
vendored
Normal file
63
ng2-components/ng2-alfresco-documentslist/dist/node_modules/range-parser/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/*!
|
||||
* range-parser
|
||||
* Copyright(c) 2012-2014 TJ Holowaychuk
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = rangeParser;
|
||||
|
||||
/**
|
||||
* Parse "Range" header `str` relative to the given file `size`.
|
||||
*
|
||||
* @param {Number} size
|
||||
* @param {String} str
|
||||
* @return {Array}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function rangeParser(size, str) {
|
||||
var valid = true;
|
||||
var i = str.indexOf('=');
|
||||
|
||||
if (-1 == i) return -2;
|
||||
|
||||
var arr = str.slice(i + 1).split(',').map(function(range){
|
||||
var range = range.split('-')
|
||||
, start = parseInt(range[0], 10)
|
||||
, end = parseInt(range[1], 10);
|
||||
|
||||
// -nnn
|
||||
if (isNaN(start)) {
|
||||
start = size - end;
|
||||
end = size - 1;
|
||||
// nnn-
|
||||
} else if (isNaN(end)) {
|
||||
end = size - 1;
|
||||
}
|
||||
|
||||
// limit last-byte-pos to current length
|
||||
if (end > size - 1) end = size - 1;
|
||||
|
||||
// invalid
|
||||
if (isNaN(start)
|
||||
|| isNaN(end)
|
||||
|| start > end
|
||||
|| start < 0) valid = false;
|
||||
|
||||
return {
|
||||
start: start,
|
||||
end: end
|
||||
};
|
||||
});
|
||||
|
||||
arr.type = str.slice(0, i);
|
||||
|
||||
return valid ? arr : -1;
|
||||
}
|
Reference in New Issue
Block a user