Merged in m3u-packages (pull request #332)

mjpeg-player: made node.js packages compatible for es6 import/exports

Approved-by: Saxon Milton
Approved-by: Scott Barnard
This commit is contained in:
Trek Hopton 2020-01-24 08:44:25 +00:00
commit 1b7e817266
2 changed files with 140 additions and 159 deletions

View File

@ -10,7 +10,7 @@ var has = Object.prototype.hasOwnProperty
* @constructor * @constructor
* @private * @private
*/ */
function Events() {} function Events() { }
// //
// We try to not inherit from `Object.prototype`. In some engines creating an // We try to not inherit from `Object.prototype`. In some engines creating an
@ -185,7 +185,7 @@ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
} }
for (i = 1, args = new Array(len -1); i < len; i++) { for (i = 1, args = new Array(len - 1); i < len; i++) {
args[i - 1] = arguments[i]; args[i - 1] = arguments[i];
} }
@ -203,7 +203,7 @@ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
default: default:
if (!args) for (j = 1, args = new Array(len -1); j < len; j++) { if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
args[j - 1] = arguments[j]; args[j - 1] = arguments[j];
} }
@ -328,9 +328,4 @@ EventEmitter.prefixed = prefix;
// //
EventEmitter.EventEmitter = EventEmitter; EventEmitter.EventEmitter = EventEmitter;
// export default EventEmitter;
// Expose the module.
//
if ('undefined' !== typeof module) {
module.exports = EventEmitter;
}

View File

@ -1,22 +1,18 @@
// see https://tools.ietf.org/html/rfc1808 // see https://tools.ietf.org/html/rfc1808
/* jshint ignore:start */ var URL_REGEX = /^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/;
(function(root) { var FIRST_SEGMENT_REGEX = /^([^\/?#]*)(.*)$/;
/* jshint ignore:end */ var SLASH_DOT_REGEX = /(?:\/|^)\.(?=\/)/g;
var SLASH_DOT_DOT_REGEX = /(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g;
var URL_REGEX = /^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/; var URLToolkit = { // jshint ignore:line
var FIRST_SEGMENT_REGEX = /^([^\/?#]*)(.*)$/;
var SLASH_DOT_REGEX = /(?:\/|^)\.(?=\/)/g;
var SLASH_DOT_DOT_REGEX = /(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g;
var URLToolkit = { // jshint ignore:line
// If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or // // If opts.alwaysNormalize is true then the path will always be normalized even when it starts with / or //
// E.g // E.g
// With opts.alwaysNormalize = false (default, spec compliant) // With opts.alwaysNormalize = false (default, spec compliant)
// http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g // http://a.com/b/cd + /e/f/../g => http://a.com/e/f/../g
// With opts.alwaysNormalize = true (not spec compliant) // With opts.alwaysNormalize = true (not spec compliant)
// http://a.com/b/cd + /e/f/../g => http://a.com/e/g // http://a.com/b/cd + /e/f/../g => http://a.com/e/g
buildAbsoluteURL: function(baseURL, relativeURL, opts) { buildAbsoluteURL: function (baseURL, relativeURL, opts) {
opts = opts || {}; opts = opts || {};
// remove any remaining space and CRLF // remove any remaining space and CRLF
baseURL = baseURL.trim(); baseURL = baseURL.trim();
@ -112,7 +108,7 @@
} }
return URLToolkit.buildURLFromParts(builtParts); return URLToolkit.buildURLFromParts(builtParts);
}, },
parseURL: function(url) { parseURL: function (url) {
var parts = URL_REGEX.exec(url); var parts = URL_REGEX.exec(url);
if (!parts) { if (!parts) {
return null; return null;
@ -126,7 +122,7 @@
fragment: parts[6] || '' fragment: parts[6] || ''
}; };
}, },
normalizePath: function(path) { normalizePath: function (path) {
// The following operations are // The following operations are
// then applied, in order, to the new path: // then applied, in order, to the new path:
// 6a) All occurrences of "./", where "." is a complete path // 6a) All occurrences of "./", where "." is a complete path
@ -142,22 +138,12 @@
// 6d) If the path ends with "<segment>/..", where <segment> is a // 6d) If the path ends with "<segment>/..", where <segment> is a
// complete path segment not equal to "..", that // complete path segment not equal to "..", that
// "<segment>/.." is removed. // "<segment>/.." is removed.
while (path.length !== (path = path.replace(SLASH_DOT_DOT_REGEX, '')).length) {} // jshint ignore:line while (path.length !== (path = path.replace(SLASH_DOT_DOT_REGEX, '')).length) { } // jshint ignore:line
return path.split('').reverse().join(''); return path.split('').reverse().join('');
}, },
buildURLFromParts: function(parts) { buildURLFromParts: function (parts) {
return parts.scheme + parts.netLoc + parts.path + parts.params + parts.query + parts.fragment; return parts.scheme + parts.netLoc + parts.path + parts.params + parts.query + parts.fragment;
} }
}; };
/* jshint ignore:start */ export default URLToolkit;
if(typeof exports === 'object' && typeof module === 'object')
module.exports = URLToolkit;
else if(typeof define === 'function' && define.amd)
define([], function() { return URLToolkit; });
else if(typeof exports === 'object')
exports["URLToolkit"] = URLToolkit;
else
root["URLToolkit"] = URLToolkit;
})(this);
/* jshint ignore:end */