|
0 |
/******/ (function(modules) { // webpackBootstrap
|
|
1 |
/******/ // The module cache
|
|
2 |
/******/ var installedModules = {};
|
|
3 |
|
|
4 |
/******/ // The require function
|
|
5 |
/******/ function __webpack_require__(moduleId) {
|
|
6 |
|
|
7 |
/******/ // Check if module is in cache
|
|
8 |
/******/ if(installedModules[moduleId])
|
|
9 |
/******/ return installedModules[moduleId].exports;
|
|
10 |
|
|
11 |
/******/ // Create a new module (and put it into the cache)
|
|
12 |
/******/ var module = installedModules[moduleId] = {
|
|
13 |
/******/ exports: {},
|
|
14 |
/******/ id: moduleId,
|
|
15 |
/******/ loaded: false
|
|
16 |
/******/ };
|
|
17 |
|
|
18 |
/******/ // Execute the module function
|
|
19 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
20 |
|
|
21 |
/******/ // Flag the module as loaded
|
|
22 |
/******/ module.loaded = true;
|
|
23 |
|
|
24 |
/******/ // Return the exports of the module
|
|
25 |
/******/ return module.exports;
|
|
26 |
/******/ }
|
|
27 |
|
|
28 |
|
|
29 |
/******/ // expose the modules object (__webpack_modules__)
|
|
30 |
/******/ __webpack_require__.m = modules;
|
|
31 |
|
|
32 |
/******/ // expose the module cache
|
|
33 |
/******/ __webpack_require__.c = installedModules;
|
|
34 |
|
|
35 |
/******/ // __webpack_public_path__
|
|
36 |
/******/ __webpack_require__.p = "";
|
|
37 |
|
|
38 |
/******/ // Load entry module and return exports
|
|
39 |
/******/ return __webpack_require__(0);
|
|
40 |
/******/ })
|
|
41 |
/************************************************************************/
|
|
42 |
/******/ ([
|
|
43 |
/* 0 */
|
|
44 |
/***/ function(module, exports, __webpack_require__) {
|
|
45 |
|
|
46 |
window.EventSourcePolyfill = __webpack_require__(1);
|
|
47 |
window.EventSource = window.EventSource || window.EventSourcePolyfill
|
|
48 |
|
|
49 |
|
|
50 |
/***/ },
|
|
51 |
/* 1 */
|
|
52 |
/***/ function(module, exports, __webpack_require__) {
|
|
53 |
|
|
54 |
/* WEBPACK VAR INJECTION */(function(process) {var original = __webpack_require__(3)
|
|
55 |
, parse = __webpack_require__(8).parse
|
|
56 |
, events = __webpack_require__(14)
|
|
57 |
, https = __webpack_require__(15)
|
|
58 |
, http = __webpack_require__(16)
|
|
59 |
, util = __webpack_require__(39);
|
|
60 |
|
|
61 |
function isPlainObject(obj) {
|
|
62 |
return Object.getPrototypeOf(obj) === Object.prototype;
|
|
63 |
}
|
|
64 |
|
|
65 |
/**
|
|
66 |
* Creates a new EventSource object
|
|
67 |
*
|
|
68 |
* @param {String} url the URL to which to connect
|
|
69 |
* @param {Object} eventSourceInitDict extra init params. See README for details.
|
|
70 |
* @api public
|
|
71 |
**/
|
|
72 |
function EventSource(url, eventSourceInitDict) {
|
|
73 |
var readyState = EventSource.CONNECTING;
|
|
74 |
Object.defineProperty(this, 'readyState', {
|
|
75 |
get: function () {
|
|
76 |
return readyState;
|
|
77 |
}
|
|
78 |
});
|
|
79 |
|
|
80 |
Object.defineProperty(this, 'url', {
|
|
81 |
get: function () {
|
|
82 |
return url;
|
|
83 |
}
|
|
84 |
});
|
|
85 |
|
|
86 |
var self = this;
|
|
87 |
self.reconnectInterval = 1000;
|
|
88 |
var connectPending = false;
|
|
89 |
|
|
90 |
function onConnectionClosed() {
|
|
91 |
if (connectPending || readyState === EventSource.CLOSED) return;
|
|
92 |
connectPending = true;
|
|
93 |
readyState = EventSource.CONNECTING;
|
|
94 |
_emit('error', new Event('error'));
|
|
95 |
|
|
96 |
// The url may have been changed by a temporary
|
|
97 |
// redirect. If that's the case, revert it now.
|
|
98 |
if (reconnectUrl) {
|
|
99 |
url = reconnectUrl;
|
|
100 |
reconnectUrl = null;
|
|
101 |
}
|
|
102 |
setTimeout(function () {
|
|
103 |
if (readyState !== EventSource.CONNECTING) {
|
|
104 |
return;
|
|
105 |
}
|
|
106 |
connect();
|
|
107 |
}, self.reconnectInterval);
|
|
108 |
}
|
|
109 |
|
|
110 |
var req;
|
|
111 |
var lastEventId = '';
|
|
112 |
if (eventSourceInitDict && eventSourceInitDict.headers && isPlainObject(eventSourceInitDict.headers) && eventSourceInitDict.headers['Last-Event-ID']) {
|
|
113 |
lastEventId = eventSourceInitDict.headers['Last-Event-ID'];
|
|
114 |
delete eventSourceInitDict.headers['Last-Event-ID'];
|
|
115 |
}
|
|
116 |
|
|
117 |
var discardTrailingNewline = false
|
|
118 |
, data = ''
|
|
119 |
, eventName = '';
|
|
120 |
|
|
121 |
var reconnectUrl = null;
|
|
122 |
|
|
123 |
function connect() {
|
|
124 |
connectPending = false;
|
|
125 |
|
|
126 |
var options = parse(url);
|
|
127 |
var isSecure = options.protocol == 'https:';
|
|
128 |
options.headers = { 'Cache-Control': 'no-cache', 'Accept': 'text/event-stream' };
|
|
129 |
if (lastEventId) options.headers['Last-Event-ID'] = lastEventId;
|
|
130 |
if (eventSourceInitDict && eventSourceInitDict.headers && isPlainObject(eventSourceInitDict.headers)) {
|
|
131 |
for (var i in eventSourceInitDict.headers) {
|
|
132 |
var header = eventSourceInitDict.headers[i];
|
|
133 |
if (header) {
|
|
134 |
options.headers[i] = header;
|
|
135 |
}
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
options.rejectUnauthorized = !(eventSourceInitDict && eventSourceInitDict.rejectUnauthorized == false);
|
|
140 |
|
|
141 |
req = (isSecure ? https : http).request(options, function (res) {
|
|
142 |
// Handle HTTP redirects
|
|
143 |
if (res.statusCode == 301 || res.statusCode == 307) {
|
|
144 |
if (!res.headers.location) {
|
|
145 |
// Server sent redirect response without Location header.
|
|
146 |
_emit('error', new Event('error', {status: res.statusCode}));
|
|
147 |
return;
|
|
148 |
}
|
|
149 |
if (res.statusCode == 307) reconnectUrl = url;
|
|
150 |
url = res.headers.location;
|
|
151 |
process.nextTick(connect);
|
|
152 |
return;
|
|
153 |
}
|
|
154 |
|
|
155 |
if (res.statusCode !== 200) {
|
|
156 |
_emit('error', new Event('error', {status: res.statusCode}));
|
|
157 |
return self.close();
|
|
158 |
}
|
|
159 |
|
|
160 |
readyState = EventSource.OPEN;
|
|
161 |
res.on('close', onConnectionClosed);
|
|
162 |
res.on('end', onConnectionClosed);
|
|
163 |
_emit('open', new Event('open'));
|
|
164 |
|
|
165 |
// text/event-stream parser adapted from webkit's
|
|
166 |
// Source/WebCore/page/EventSource.cpp
|
|
167 |
var buf = '';
|
|
168 |
res.on('data', function (chunk) {
|
|
169 |
buf += chunk;
|
|
170 |
|
|
171 |
var pos = 0
|
|
172 |
, length = buf.length;
|
|
173 |
while (pos < length) {
|
|
174 |
if (discardTrailingNewline) {
|
|
175 |
if (buf[pos] === '\n') {
|
|
176 |
++pos;
|
|
177 |
}
|
|
178 |
discardTrailingNewline = false;
|
|
179 |
}
|
|
180 |
|
|
181 |
var lineLength = -1
|
|
182 |
, fieldLength = -1
|
|
183 |
, c;
|
|
184 |
|
|
185 |
for (var i = pos; lineLength < 0 && i < length; ++i) {
|
|
186 |
c = buf[i];
|
|
187 |
if (c === ':') {
|
|
188 |
if (fieldLength < 0) {
|
|
189 |
fieldLength = i - pos;
|
|
190 |
}
|
|
191 |
} else if (c === '\r') {
|
|
192 |
discardTrailingNewline = true;
|
|
193 |
lineLength = i - pos;
|
|
194 |
} else if (c === '\n') {
|
|
195 |
lineLength = i - pos;
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
if (lineLength < 0) {
|
|
200 |
break;
|
|
201 |
}
|
|
202 |
|
|
203 |
parseEventStreamLine(buf, pos, fieldLength, lineLength);
|
|
204 |
|
|
205 |
pos += lineLength + 1;
|
|
206 |
}
|
|
207 |
|
|
208 |
if (pos === length) {
|
|
209 |
buf = '';
|
|
210 |
} else if (pos > 0) {
|
|
211 |
buf = buf.slice(pos);
|
|
212 |
}
|
|
213 |
});
|
|
214 |
});
|
|
215 |
|
|
216 |
req.on('error', onConnectionClosed);
|
|
217 |
if (req.setNoDelay) req.setNoDelay(true);
|
|
218 |
req.end();
|
|
219 |
}
|
|
220 |
|
|
221 |
connect();
|
|
222 |
|
|
223 |
function _emit() {
|
|
224 |
if (self.listeners(arguments[0]).length > 0) {
|
|
225 |
self.emit.apply(self, arguments);
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
this.close = function () {
|
|
230 |
if (readyState == EventSource.CLOSED) return;
|
|
231 |
readyState = EventSource.CLOSED;
|
|
232 |
if (req.abort) req.abort();
|
|
233 |
};
|
|
234 |
|
|
235 |
function parseEventStreamLine(buf, pos, fieldLength, lineLength) {
|
|
236 |
if (lineLength === 0) {
|
|
237 |
if (data.length > 0) {
|
|
238 |
var type = eventName || 'message';
|
|
239 |
_emit(type, new MessageEvent(type, {
|
|
240 |
data: data.slice(0, -1), // remove trailing newline
|
|
241 |
lastEventId: lastEventId,
|
|
242 |
origin: original(url)
|
|
243 |
}));
|
|
244 |
data = '';
|
|
245 |
}
|
|
246 |
eventName = void 0;
|
|
247 |
} else if (fieldLength > 0) {
|
|
248 |
var noValue = fieldLength < 0
|
|
249 |
, step = 0
|
|
250 |
, field = buf.slice(pos, pos + (noValue ? lineLength : fieldLength));
|
|
251 |
|
|
252 |
if (noValue) {
|
|
253 |
step = lineLength;
|
|
254 |
} else if (buf[pos + fieldLength + 1] !== ' ') {
|
|
255 |
step = fieldLength + 1;
|
|
256 |
} else {
|
|
257 |
step = fieldLength + 2;
|
|
258 |
}
|
|
259 |
pos += step;
|
|
260 |
var valueLength = lineLength - step
|
|
261 |
, value = buf.slice(pos, pos + valueLength);
|
|
262 |
|
|
263 |
if (field === 'data') {
|
|
264 |
data += value + '\n';
|
|
265 |
} else if (field === 'event') {
|
|
266 |
eventName = value;
|
|
267 |
} else if (field === 'id') {
|
|
268 |
lastEventId = value;
|
|
269 |
} else if (field === 'retry') {
|
|
270 |
var retry = parseInt(value, 10);
|
|
271 |
if (!Number.isNaN(retry)) {
|
|
272 |
self.reconnectInterval = retry;
|
|
273 |
}
|
|
274 |
}
|
|
275 |
}
|
|
276 |
}
|
|
277 |
}
|
|
278 |
|
|
279 |
module.exports = EventSource;
|
|
280 |
|
|
281 |
util.inherits(EventSource, events.EventEmitter);
|
|
282 |
EventSource.prototype.constructor = EventSource; // make stacktraces readable
|
|
283 |
|
|
284 |
['open', 'error', 'message'].forEach(function (method) {
|
|
285 |
Object.defineProperty(EventSource.prototype, 'on' + method, {
|
|
286 |
/**
|
|
287 |
* Returns the current listener
|
|
288 |
*
|
|
289 |
* @return {Mixed} the set function or undefined
|
|
290 |
* @api private
|
|
291 |
*/
|
|
292 |
get: function get() {
|
|
293 |
var listener = this.listeners(method)[0];
|
|
294 |
return listener ? (listener._listener ? listener._listener : listener) : undefined;
|
|
295 |
},
|
|
296 |
|
|
297 |
/**
|
|
298 |
* Start listening for events
|
|
299 |
*
|
|
300 |
* @param {Function} listener the listener
|
|
301 |
* @return {Mixed} the set function or undefined
|
|
302 |
* @api private
|
|
303 |
*/
|
|
304 |
set: function set(listener) {
|
|
305 |
this.removeAllListeners(method);
|
|
306 |
this.addEventListener(method, listener);
|
|
307 |
}
|
|
308 |
});
|
|
309 |
});
|
|
310 |
|
|
311 |
/**
|
|
312 |
* Ready states
|
|
313 |
*/
|
|
314 |
Object.defineProperty(EventSource, 'CONNECTING', { enumerable: true, value: 0});
|
|
315 |
Object.defineProperty(EventSource, 'OPEN', { enumerable: true, value: 1});
|
|
316 |
Object.defineProperty(EventSource, 'CLOSED', { enumerable: true, value: 2});
|
|
317 |
|
|
318 |
/**
|
|
319 |
* Emulates the W3C Browser based WebSocket interface using addEventListener.
|
|
320 |
*
|
|
321 |
* @param {String} method Listen for an event
|
|
322 |
* @param {Function} listener callback
|
|
323 |
* @see https://developer.mozilla.org/en/DOM/element.addEventListener
|
|
324 |
* @see http://dev.w3.org/html5/websockets/#the-websocket-interface
|
|
325 |
* @api public
|
|
326 |
*/
|
|
327 |
EventSource.prototype.addEventListener = function addEventListener(method, listener) {
|
|
328 |
if (typeof listener === 'function') {
|
|
329 |
// store a reference so we can return the original function again
|
|
330 |
listener._listener = listener;
|
|
331 |
this.on(method, listener);
|
|
332 |
}
|
|
333 |
};
|
|
334 |
|
|
335 |
/**
|
|
336 |
* W3C Event
|
|
337 |
*
|
|
338 |
* @see http://www.w3.org/TR/DOM-Level-3-Events/#interface-Event
|
|
339 |
* @api private
|
|
340 |
*/
|
|
341 |
function Event(type, optionalProperties) {
|
|
342 |
Object.defineProperty(this, 'type', { writable: false, value: type, enumerable: true });
|
|
343 |
if (optionalProperties) {
|
|
344 |
for (var f in optionalProperties) {
|
|
345 |
if (optionalProperties.hasOwnProperty(f)) {
|
|
346 |
Object.defineProperty(this, f, { writable: false, value: optionalProperties[f], enumerable: true });
|
|
347 |
}
|
|
348 |
}
|
|
349 |
}
|
|
350 |
}
|
|
351 |
|
|
352 |
/**
|
|
353 |
* W3C MessageEvent
|
|
354 |
*
|
|
355 |
* @see http://www.w3.org/TR/webmessaging/#event-definitions
|
|
356 |
* @api private
|
|
357 |
*/
|
|
358 |
function MessageEvent(type, eventInitDict) {
|
|
359 |
Object.defineProperty(this, 'type', { writable: false, value: type, enumerable: true });
|
|
360 |
for (var f in eventInitDict) {
|
|
361 |
if (eventInitDict.hasOwnProperty(f)) {
|
|
362 |
Object.defineProperty(this, f, { writable: false, value: eventInitDict[f], enumerable: true });
|
|
363 |
}
|
|
364 |
}
|
|
365 |
}
|
|
366 |
|
|
367 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
|
|
368 |
|
|
369 |
/***/ },
|
|
370 |
/* 2 */
|
|
371 |
/***/ function(module, exports) {
|
|
372 |
|
|
373 |
// shim for using process in browser
|
|
374 |
|
|
375 |
var process = module.exports = {};
|
|
376 |
var queue = [];
|
|
377 |
var draining = false;
|
|
378 |
var currentQueue;
|
|
379 |
var queueIndex = -1;
|
|
380 |
|
|
381 |
function cleanUpNextTick() {
|
|
382 |
draining = false;
|
|
383 |
if (currentQueue.length) {
|
|
384 |
queue = currentQueue.concat(queue);
|
|
385 |
} else {
|
|
386 |
queueIndex = -1;
|
|
387 |
}
|
|
388 |
if (queue.length) {
|
|
389 |
drainQueue();
|
|
390 |
}
|
|
391 |
}
|
|
392 |
|
|
393 |
function drainQueue() {
|
|
394 |
if (draining) {
|
|
395 |
return;
|
|
396 |
}
|
|
397 |
var timeout = setTimeout(cleanUpNextTick);
|
|
398 |
draining = true;
|
|
399 |
|
|
400 |
var len = queue.length;
|
|
401 |
while(len) {
|
|
402 |
currentQueue = queue;
|
|
403 |
queue = [];
|
|
404 |
while (++queueIndex < len) {
|
|
405 |
if (currentQueue) {
|
|
406 |
currentQueue[queueIndex].run();
|
|
407 |
}
|
|
408 |
}
|
|
409 |
queueIndex = -1;
|
|
410 |
len = queue.length;
|
|
411 |
}
|
|
412 |
currentQueue = null;
|
|
413 |
draining = false;
|
|
414 |
clearTimeout(timeout);
|
|
415 |
}
|
|
416 |
|
|
417 |
process.nextTick = function (fun) {
|
|
418 |
var args = new Array(arguments.length - 1);
|
|
419 |
if (arguments.length > 1) {
|
|
420 |
for (var i = 1; i < arguments.length; i++) {
|
|
421 |
args[i - 1] = arguments[i];
|
|
422 |
}
|
|
423 |
}
|
|
424 |
queue.push(new Item(fun, args));
|
|
425 |
if (queue.length === 1 && !draining) {
|
|
426 |
setTimeout(drainQueue, 0);
|
|
427 |
}
|
|
428 |
};
|
|
429 |
|
|
430 |
// v8 likes predictible objects
|
|
431 |
function Item(fun, array) {
|
|
432 |
this.fun = fun;
|
|
433 |
this.array = array;
|
|
434 |
}
|
|
435 |
Item.prototype.run = function () {
|
|
436 |
this.fun.apply(null, this.array);
|
|
437 |
};
|
|
438 |
process.title = 'browser';
|
|
439 |
process.browser = true;
|
|
440 |
process.env = {};
|
|
441 |
process.argv = [];
|
|
442 |
process.version = ''; // empty string to avoid regexp issues
|
|
443 |
process.versions = {};
|
|
444 |
|
|
445 |
function noop() {}
|
|
446 |
|
|
447 |
process.on = noop;
|
|
448 |
process.addListener = noop;
|
|
449 |
process.once = noop;
|
|
450 |
process.off = noop;
|
|
451 |
process.removeListener = noop;
|
|
452 |
process.removeAllListeners = noop;
|
|
453 |
process.emit = noop;
|
|
454 |
|
|
455 |
process.binding = function (name) {
|
|
456 |
throw new Error('process.binding is not supported');
|
|
457 |
};
|
|
458 |
|
|
459 |
process.cwd = function () { return '/' };
|
|
460 |
process.chdir = function (dir) {
|
|
461 |
throw new Error('process.chdir is not supported');
|
|
462 |
};
|
|
463 |
process.umask = function() { return 0; };
|
|
464 |
|
|
465 |
|
|
466 |
/***/ },
|
|
467 |
/* 3 */
|
|
468 |
/***/ function(module, exports, __webpack_require__) {
|
|
469 |
|
|
470 |
'use strict';
|
|
471 |
|
|
472 |
var parse = __webpack_require__(4);
|
|
473 |
|
|
474 |
/**
|
|
475 |
* Transform an URL to a valid origin value.
|
|
476 |
*
|
|
477 |
* @param {String|Object} url URL to transform to it's origin.
|
|
478 |
* @returns {String} The origin.
|
|
479 |
* @api public
|
|
480 |
*/
|
|
481 |
function origin(url) {
|
|
482 |
if ('string' === typeof url) url = parse(url);
|
|
483 |
|
|
484 |
//
|
|
485 |
// 6.2. ASCII Serialization of an Origin
|
|
486 |
// http://tools.ietf.org/html/rfc6454#section-6.2
|
|
487 |
//
|
|
488 |
if (!url.protocol || !url.hostname) return 'null';
|
|
489 |
|
|
490 |
//
|
|
491 |
// 4. Origin of a URI
|
|
492 |
// http://tools.ietf.org/html/rfc6454#section-4
|
|
493 |
//
|
|
494 |
// States that url.scheme, host should be converted to lower case. This also
|
|
495 |
// makes it easier to match origins as everything is just lower case.
|
|
496 |
//
|
|
497 |
return (url.protocol +'//'+ url.host).toLowerCase();
|
|
498 |
}
|
|
499 |
|
|
500 |
/**
|
|
501 |
* Check if the origins are the same.
|
|
502 |
*
|
|
503 |
* @param {String} a URL or origin of a.
|
|
504 |
* @param {String} b URL or origin of b.
|
|
505 |
* @returns {Boolean}
|
|
506 |
* @api public
|
|
507 |
*/
|
|
508 |
origin.same = function same(a, b) {
|
|
509 |
return origin(a) === origin(b);
|
|
510 |
};
|
|
511 |
|
|
512 |
//
|
|
513 |
// Expose the origin
|
|
514 |
//
|
|
515 |
module.exports = origin;
|
|
516 |
|
|
517 |
|
|
518 |
/***/ },
|
|
519 |
/* 4 */
|
|
520 |
/***/ function(module, exports, __webpack_require__) {
|
|
521 |
|
|
522 |
'use strict';
|
|
523 |
|
|
524 |
var required = __webpack_require__(5)
|
|
525 |
, lolcation = __webpack_require__(6)
|
|
526 |
, qs = __webpack_require__(7)
|
|
527 |
, relativere = /^\/(?!\/)/;
|
|
528 |
|
|
529 |
/**
|
|
530 |
* These are the parse instructions for the URL parsers, it informs the parser
|
|
531 |
* about:
|
|
532 |
*
|
|
533 |
* 0. The char it Needs to parse, if it's a string it should be done using
|
|
534 |
* indexOf, RegExp using exec and NaN means set as current value.
|
|
535 |
* 1. The property we should set when parsing this value.
|
|
536 |
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
|
537 |
* the value of extra chars that should be split off.
|
|
538 |
* 3. Inherit from location if non existing in the parser.
|
|
539 |
* 4. `toLowerCase` the resulting value.
|
|
540 |
*/
|
|
541 |
var instructions = [
|
|
542 |
['#', 'hash'], // Extract from the back.
|
|
543 |
['?', 'query'], // Extract from the back.
|
|
544 |
['//', 'protocol', 2, 1, 1], // Extract from the front.
|
|
545 |
['/', 'pathname'], // Extract from the back.
|
|
546 |
['@', 'auth', 1], // Extract from the front.
|
|
547 |
[NaN, 'host', undefined, 1, 1], // Set left over value.
|
|
548 |
[/\:(\d+)$/, 'port'], // RegExp the back.
|
|
549 |
[NaN, 'hostname', undefined, 1, 1] // Set left over.
|
|
550 |
];
|
|
551 |
|
|
552 |
/**
|
|
553 |
* The actual URL instance. Instead of returning an object we've opted-in to
|
|
554 |
* create an actual constructor as it's much more memory efficient and
|
|
555 |
* faster and it pleases my CDO.
|
|
556 |
*
|
|
557 |
* @constructor
|
|
558 |
* @param {String} address URL we want to parse.
|
|
559 |
* @param {Boolean|function} parser Parser for the query string.
|
|
560 |
* @param {Object} location Location defaults for relative paths.
|
|
561 |
* @api public
|
|
562 |
*/
|
|
563 |
function URL(address, location, parser) {
|
|
564 |
if (!(this instanceof URL)) {
|
|
565 |
return new URL(address, location, parser);
|
|
566 |
}
|
|
567 |
|
|
568 |
var relative = relativere.test(address)
|
|
569 |
, parse, instruction, index, key
|
|
570 |
, type = typeof location
|
|
571 |
, url = this
|
|
572 |
, i = 0;
|
|
573 |
|
|
574 |
//
|
|
575 |
// The following if statements allows this module two have compatibility with
|
|
576 |
// 2 different API:
|
|
577 |
//
|
|
578 |
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
|
|
579 |
// where the boolean indicates that the query string should also be parsed.
|
|
580 |
//
|
|
581 |
// 2. The `URL` interface of the browser which accepts a URL, object as
|
|
582 |
// arguments. The supplied object will be used as default values / fall-back
|
|
583 |
// for relative paths.
|
|
584 |
//
|
|
585 |
if ('object' !== type && 'string' !== type) {
|
|
586 |
parser = location;
|
|
587 |
location = null;
|
|
588 |
}
|
|
589 |
|
|
590 |
if (parser && 'function' !== typeof parser) {
|
|
591 |
parser = qs.parse;
|
|
592 |
}
|
|
593 |
|
|
594 |
location = lolcation(location);
|
|
595 |
|
|
596 |
for (; i < instructions.length; i++) {
|
|
597 |
instruction = instructions[i];
|
|
598 |
parse = instruction[0];
|
|
599 |
key = instruction[1];
|
|
600 |
|
|
601 |
if (parse !== parse) {
|
|
602 |
url[key] = address;
|
|
603 |
} else if ('string' === typeof parse) {
|
|
604 |
if (~(index = address.indexOf(parse))) {
|
|
605 |
if ('number' === typeof instruction[2]) {
|
|
606 |
url[key] = address.slice(0, index);
|
|
607 |
address = address.slice(index + instruction[2]);
|
|
608 |
} else {
|
|
609 |
url[key] = address.slice(index);
|
|
610 |
address = address.slice(0, index);
|
|
611 |
}
|
|
612 |
}
|
|
613 |
} else if (index = parse.exec(address)) {
|
|
614 |
url[key] = index[1];
|
|
615 |
address = address.slice(0, address.length - index[0].length);
|
|
616 |
}
|
|
617 |
|
|
618 |
url[key] = url[key] || (instruction[3] || ('port' === key && relative) ? location[key] || '' : '');
|
|
619 |
|
|
620 |
//
|
|
621 |
// Hostname, host and protocol should be lowercased so they can be used to
|
|
622 |
// create a proper `origin`.
|
|
623 |
//
|
|
624 |
if (instruction[4]) {
|
|
625 |
url[key] = url[key].toLowerCase();
|
|
626 |
}
|
|
627 |
}
|
|
628 |
|
|
629 |
//
|
|
630 |
// Also parse the supplied query string in to an object. If we're supplied
|
|
631 |
// with a custom parser as function use that instead of the default build-in
|
|
632 |
// parser.
|
|
633 |
//
|
|
634 |
if (parser) url.query = parser(url.query);
|
|
635 |
|
|
636 |
//
|
|
637 |
// We should not add port numbers if they are already the default port number
|
|
638 |
// for a given protocol. As the host also contains the port number we're going
|
|
639 |
// override it with the hostname which contains no port number.
|
|
640 |
//
|
|
641 |
if (!required(url.port, url.protocol)) {
|
|
642 |
url.host = url.hostname;
|
|
643 |
url.port = '';
|
|
644 |
}
|
|
645 |
|
|
646 |
//
|
|
647 |
// Parse down the `auth` for the username and password.
|
|
648 |
//
|
|
649 |
url.username = url.password = '';
|
|
650 |
if (url.auth) {
|
|
651 |
instruction = url.auth.split(':');
|
|
652 |
url.username = instruction[0] || '';
|
|
653 |
url.password = instruction[1] || '';
|
|
654 |
}
|
|
655 |
|
|
656 |
//
|
|
657 |
// The href is just the compiled result.
|
|
658 |
//
|
|
659 |
url.href = url.toString();
|
|
660 |
}
|
|
661 |
|
|
662 |
/**
|
|
663 |
* This is convenience method for changing properties in the URL instance to
|
|
664 |
* insure that they all propagate correctly.
|
|
665 |
*
|
|
666 |
* @param {String} prop Property we need to adjust.
|
|
667 |
* @param {Mixed} value The newly assigned value.
|
|
668 |
* @returns {URL}
|
|
669 |
* @api public
|
|
670 |
*/
|
|
671 |
URL.prototype.set = function set(part, value, fn) {
|
|
672 |
var url = this;
|
|
673 |
|
|
674 |
if ('query' === part) {
|
|
675 |
if ('string' === typeof value && value.length) {
|
|
676 |
value = (fn || qs.parse)(value);
|
|
677 |
}
|
|
678 |
|
|
679 |
url[part] = value;
|
|
680 |
} else if ('port' === part) {
|
|
681 |
url[part] = value;
|
|
682 |
|
|
683 |
if (!required(value, url.protocol)) {
|
|
684 |
url.host = url.hostname;
|
|
685 |
url[part] = '';
|
|
686 |
} else if (value) {
|
|
687 |
url.host = url.hostname +':'+ value;
|
|
688 |
}
|
|
689 |
} else if ('hostname' === part) {
|
|
690 |
url[part] = value;
|
|
691 |
|
|
692 |
if (url.port) value += ':'+ url.port;
|
|
693 |
url.host = value;
|
|
694 |
} else if ('host' === part) {
|
|
695 |
url[part] = value;
|
|
696 |
|
|
697 |
if (/\:\d+/.test(value)) {
|
|
698 |
value = value.split(':');
|
|
699 |
url.hostname = value[0];
|
|
700 |
url.port = value[1];
|
|
701 |
}
|
|
702 |
} else {
|
|
703 |
url[part] = value;
|
|
704 |
}
|
|
705 |
|
|
706 |
url.href = url.toString();
|
|
707 |
return url;
|
|
708 |
};
|
|
709 |
|
|
710 |
/**
|
|
711 |
* Transform the properties back in to a valid and full URL string.
|
|
712 |
*
|
|
713 |
* @param {Function} stringify Optional query stringify function.
|
|
714 |
* @returns {String}
|
|
715 |
* @api public
|
|
716 |
*/
|
|
717 |
URL.prototype.toString = function toString(stringify) {
|
|
718 |
if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
|
|
719 |
|
|
720 |
var query
|
|
721 |
, url = this
|
|
722 |
, result = url.protocol +'//';
|
|
723 |
|
|
724 |
if (url.username) {
|
|
725 |
result += url.username;
|
|
726 |
if (url.password) result += ':'+ url.password;
|
|
727 |
result += '@';
|
|
728 |
}
|
|
729 |
|
|
730 |
result += url.hostname;
|
|
731 |
if (url.port) result += ':'+ url.port;
|
|
732 |
|
|
733 |
result += url.pathname;
|
|
734 |
|
|
735 |
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
|
|
736 |
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
|
|
737 |
|
|
738 |
if (url.hash) result += url.hash;
|
|
739 |
|
|
740 |
return result;
|
|
741 |
};
|
|
742 |
|
|
743 |
//
|
|
744 |
// Expose the URL parser and some additional properties that might be useful for
|
|
745 |
// others.
|
|
746 |
//
|
|
747 |
URL.qs = qs;
|
|
748 |
URL.location = lolcation;
|
|
749 |
module.exports = URL;
|
|
750 |
|
|
751 |
|
|
752 |
/***/ },
|
|
753 |
/* 5 */
|
|
754 |
/***/ function(module, exports) {
|
|
755 |
|
|
756 |
'use strict';
|
|
757 |
|
|
758 |
/**
|
|
759 |
* Check if we're required to add a port number.
|
|
760 |
*
|
|
761 |
* @see https://url.spec.whatwg.org/#default-port
|
|
762 |
* @param {Number|String} port Port number we need to check
|
|
763 |
* @param {String} protocol Protocol we need to check against.
|
|
764 |
* @returns {Boolean} Is it a default port for the given protocol
|
|
765 |
* @api private
|
|
766 |
*/
|
|
767 |
module.exports = function required(port, protocol) {
|
|
768 |
protocol = protocol.split(':')[0];
|
|
769 |
port = +port;
|
|
770 |
|
|
771 |
if (!port) return false;
|
|
772 |
|
|
773 |
switch (protocol) {
|
|
774 |
case 'http':
|
|
775 |
case 'ws':
|
|
776 |
return port !== 80;
|
|
777 |
|
|
778 |
case 'https':
|
|
779 |
case 'wss':
|
|
780 |
return port !== 443;
|
|
781 |
|
|
782 |
case 'ftp':
|
|
783 |
return port !== 21;
|
|
784 |
|
|
785 |
case 'gopher':
|
|
786 |
return port !== 70;
|
|
787 |
|
|
788 |
case 'file':
|
|
789 |
return false;
|
|
790 |
}
|
|
791 |
|
|
792 |
return port !== 0;
|
|
793 |
};
|
|
794 |
|
|
795 |
|
|
796 |
/***/ },
|
|
797 |
/* 6 */
|
|
798 |
/***/ function(module, exports, __webpack_require__) {
|
|
799 |
|
|
800 |
/* WEBPACK VAR INJECTION */(function(global) {'use strict';
|
|
801 |
|
|
802 |
/**
|
|
803 |
* These properties should not be copied or inherited from. This is only needed
|
|
804 |
* for all non blob URL's as the a blob URL does not include a hash, only the
|
|
805 |
* origin.
|
|
806 |
*
|
|
807 |
* @type {Object}
|
|
808 |
* @private
|
|
809 |
*/
|
|
810 |
var ignore = { hash: 1, query: 1 }
|
|
811 |
, URL;
|
|
812 |
|
|
813 |
/**
|
|
814 |
* The location object differs when your code is loaded through a normal page,
|
|
815 |
* Worker or through a worker using a blob. And with the blobble begins the
|
|
816 |
* trouble as the location object will contain the URL of the blob, not the
|
|
817 |
* location of the page where our code is loaded in. The actual origin is
|
|
818 |
* encoded in the `pathname` so we can thankfully generate a good "default"
|
|
819 |
* location from it so we can generate proper relative URL's again.
|
|
820 |
*
|
|
821 |
* @param {Object} loc Optional default location object.
|
|
822 |
* @returns {Object} lolcation object.
|
|
823 |
* @api public
|
|
824 |
*/
|
|
825 |
module.exports = function lolcation(loc) {
|
|
826 |
loc = loc || global.location || {};
|
|
827 |
URL = URL || __webpack_require__(4);
|
|
828 |
|
|
829 |
var finaldestination = {}
|
|
830 |
, type = typeof loc
|
|
831 |
, key;
|
|
832 |
|
|
833 |
if ('blob:' === loc.protocol) {
|
|
834 |
finaldestination = new URL(unescape(loc.pathname), {});
|
|
835 |
} else if ('string' === type) {
|
|
836 |
finaldestination = new URL(loc, {});
|
|
837 |
for (key in ignore) delete finaldestination[key];
|
|
838 |
} else if ('object' === type) for (key in loc) {
|
|
839 |
if (key in ignore) continue;
|
|
840 |
finaldestination[key] = loc[key];
|
|
841 |
}
|
|
842 |
|
|
843 |
return finaldestination;
|
|
844 |
};
|
|
845 |
|
|
846 |
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
|
847 |
|
|
848 |
/***/ },
|
|
849 |
/* 7 */
|
|
850 |
/***/ function(module, exports) {
|
|
851 |
|
|
852 |
'use strict';
|
|
853 |
|
|
854 |
var has = Object.prototype.hasOwnProperty;
|
|
855 |
|
|
856 |
/**
|
|
857 |
* Simple query string parser.
|
|
858 |
*
|
|
859 |
* @param {String} query The query string that needs to be parsed.
|
|
860 |
* @returns {Object}
|
|
861 |
* @api public
|
|
862 |
*/
|
|
863 |
function querystring(query) {
|
|
864 |
var parser = /([^=?&]+)=([^&]*)/g
|
|
865 |
, result = {}
|
|
866 |
, part;
|
|
867 |
|
|
868 |
//
|
|
869 |
// Little nifty parsing hack, leverage the fact that RegExp.exec increments
|
|
870 |
// the lastIndex property so we can continue executing this loop until we've
|
|
871 |
// parsed all results.
|
|
872 |
//
|
|
873 |
for (;
|
|
874 |
part = parser.exec(query);
|
|
875 |
result[decodeURIComponent(part[1])] = decodeURIComponent(part[2])
|
|
876 |
);
|
|
877 |
|
|
878 |
return result;
|
|
879 |
}
|
|
880 |
|
|
881 |
/**
|
|
882 |
* Transform a query string to an object.
|
|
883 |
*
|
|
884 |
* @param {Object} obj Object that should be transformed.
|
|
885 |
* @param {String} prefix Optional prefix.
|
|
886 |
* @returns {String}
|
|
887 |
* @api public
|
|
888 |
*/
|
|
889 |
function querystringify(obj, prefix) {
|
|
890 |
prefix = prefix || '';
|
|
891 |
|
|
892 |
var pairs = [];
|
|
893 |
|
|
894 |
//
|
|
895 |
// Optionally prefix with a '?' if needed
|
|
896 |
//
|
|
897 |
if ('string' !== typeof prefix) prefix = '?';
|
|
898 |
|
|
899 |
for (var key in obj) {
|
|
900 |
if (has.call(obj, key)) {
|
|
901 |
pairs.push(encodeURIComponent(key) +'='+ encodeURIComponent(obj[key]));
|
|
902 |
}
|
|
903 |
}
|
|
904 |
|
|
905 |
return pairs.length ? prefix + pairs.join('&') : '';
|
|
906 |
}
|
|
907 |
|
|
908 |
//
|
|
909 |
// Expose the module.
|
|
910 |
//
|
|
911 |
exports.stringify = querystringify;
|
|
912 |
exports.parse = querystring;
|
|
913 |
|
|
914 |
|
|
915 |
/***/ },
|
|
916 |
/* 8 */
|
|
917 |
/***/ function(module, exports, __webpack_require__) {
|
|
918 |
|
|
919 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
920 |
//
|
|
921 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
922 |
// copy of this software and associated documentation files (the
|
|
923 |
// "Software"), to deal in the Software without restriction, including
|
|
924 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
925 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
926 |
// persons to whom the Software is furnished to do so, subject to the
|
|
927 |
// following conditions:
|
|
928 |
//
|
|
929 |
// The above copyright notice and this permission notice shall be included
|
|
930 |
// in all copies or substantial portions of the Software.
|
|
931 |
//
|
|
932 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
933 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
934 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
935 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
936 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
937 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
938 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
939 |
|
|
940 |
var punycode = __webpack_require__(9);
|
|
941 |
|
|
942 |
exports.parse = urlParse;
|
|
943 |
exports.resolve = urlResolve;
|
|
944 |
exports.resolveObject = urlResolveObject;
|
|
945 |
exports.format = urlFormat;
|
|
946 |
|
|
947 |
exports.Url = Url;
|
|
948 |
|
|
949 |
function Url() {
|
|
950 |
this.protocol = null;
|
|
951 |
this.slashes = null;
|
|
952 |
this.auth = null;
|
|
953 |
this.host = null;
|
|
954 |
this.port = null;
|
|
955 |
this.hostname = null;
|
|
956 |
this.hash = null;
|
|
957 |
this.search = null;
|
|
958 |
this.query = null;
|
|
959 |
this.pathname = null;
|
|
960 |
this.path = null;
|
|
961 |
this.href = null;
|
|
962 |
}
|
|
963 |
|
|
964 |
// Reference: RFC 3986, RFC 1808, RFC 2396
|
|
965 |
|
|
966 |
// define these here so at least they only have to be
|
|
967 |
// compiled once on the first module load.
|
|
968 |
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
|
969 |
portPattern = /:[0-9]*$/,
|
|
970 |
|
|
971 |
// RFC 2396: characters reserved for delimiting URLs.
|
|
972 |
// We actually just auto-escape these.
|
|
973 |
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
|
974 |
|
|
975 |
// RFC 2396: characters not allowed for various reasons.
|
|
976 |
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
|
977 |
|
|
978 |
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
|
979 |
autoEscape = ['\''].concat(unwise),
|
|
980 |
// Characters that are never ever allowed in a hostname.
|
|
981 |
// Note that any invalid chars are also handled, but these
|
|
982 |
// are the ones that are *expected* to be seen, so we fast-path
|
|
983 |
// them.
|
|
984 |
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
|
|
985 |
hostEndingChars = ['/', '?', '#'],
|
|
986 |
hostnameMaxLen = 255,
|
|
987 |
hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/,
|
|
988 |
hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/,
|
|
989 |
// protocols that can allow "unsafe" and "unwise" chars.
|
|
990 |
unsafeProtocol = {
|
|
991 |
'javascript': true,
|
|
992 |
'javascript:': true
|
|
993 |
},
|
|
994 |
// protocols that never have a hostname.
|
|
995 |
hostlessProtocol = {
|
|
996 |
'javascript': true,
|
|
997 |
'javascript:': true
|
|
998 |
},
|
|
999 |
// protocols that always contain a // bit.
|
|
1000 |
slashedProtocol = {
|
|
1001 |
'http': true,
|
|
1002 |
'https': true,
|
|
1003 |
'ftp': true,
|
|
1004 |
'gopher': true,
|
|
1005 |
'file': true,
|
|
1006 |
'http:': true,
|
|
1007 |
'https:': true,
|
|
1008 |
'ftp:': true,
|
|
1009 |
'gopher:': true,
|
|
1010 |
'file:': true
|
|
1011 |
},
|
|
1012 |
querystring = __webpack_require__(11);
|
|
1013 |
|
|
1014 |
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
|
1015 |
if (url && isObject(url) && url instanceof Url) return url;
|
|
1016 |
|
|
1017 |
var u = new Url;
|
|
1018 |
u.parse(url, parseQueryString, slashesDenoteHost);
|
|
1019 |
return u;
|
|
1020 |
}
|
|
1021 |
|
|
1022 |
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
|
1023 |
if (!isString(url)) {
|
|
1024 |
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
var rest = url;
|
|
1028 |
|
|
1029 |
// trim before proceeding.
|
|
1030 |
// This is to support parse stuff like " http://foo.com \n"
|
|
1031 |
rest = rest.trim();
|
|
1032 |
|
|
1033 |
var proto = protocolPattern.exec(rest);
|
|
1034 |
if (proto) {
|
|
1035 |
proto = proto[0];
|
|
1036 |
var lowerProto = proto.toLowerCase();
|
|
1037 |
this.protocol = lowerProto;
|
|
1038 |
rest = rest.substr(proto.length);
|
|
1039 |
}
|
|
1040 |
|
|
1041 |
// figure out if it's got a host
|
|
1042 |
// user@server is *always* interpreted as a hostname, and url
|
|
1043 |
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
|
1044 |
// how the browser resolves relative URLs.
|
|
1045 |
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
1046 |
var slashes = rest.substr(0, 2) === '//';
|
|
1047 |
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
1048 |
rest = rest.substr(2);
|
|
1049 |
this.slashes = true;
|
|
1050 |
}
|
|
1051 |
}
|
|
1052 |
|
|
1053 |
if (!hostlessProtocol[proto] &&
|
|
1054 |
(slashes || (proto && !slashedProtocol[proto]))) {
|
|
1055 |
|
|
1056 |
// there's a hostname.
|
|
1057 |
// the first instance of /, ?, ;, or # ends the host.
|
|
1058 |
//
|
|
1059 |
// If there is an @ in the hostname, then non-host chars *are* allowed
|
|
1060 |
// to the left of the last @ sign, unless some host-ending character
|
|
1061 |
// comes *before* the @-sign.
|
|
1062 |
// URLs are obnoxious.
|
|
1063 |
//
|
|
1064 |
// ex:
|
|
1065 |
// http://a@b@c/ => user:a@b host:c
|
|
1066 |
// http://a@b?@c => user:a host:c path:/?@c
|
|
1067 |
|
|
1068 |
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
|
1069 |
// Review our test case against browsers more comprehensively.
|
|
1070 |
|
|
1071 |
// find the first instance of any hostEndingChars
|
|
1072 |
var hostEnd = -1;
|
|
1073 |
for (var i = 0; i < hostEndingChars.length; i++) {
|
|
1074 |
var hec = rest.indexOf(hostEndingChars[i]);
|
|
1075 |
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
1076 |
hostEnd = hec;
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
// at this point, either we have an explicit point where the
|
|
1080 |
// auth portion cannot go past, or the last @ char is the decider.
|
|
1081 |
var auth, atSign;
|
|
1082 |
if (hostEnd === -1) {
|
|
1083 |
// atSign can be anywhere.
|
|
1084 |
atSign = rest.lastIndexOf('@');
|
|
1085 |
} else {
|
|
1086 |
// atSign must be in auth portion.
|
|
1087 |
// http://a@b/c@d => host:b auth:a path:/c@d
|
|
1088 |
atSign = rest.lastIndexOf('@', hostEnd);
|
|
1089 |
}
|
|
1090 |
|
|
1091 |
// Now we have a portion which is definitely the auth.
|
|
1092 |
// Pull that off.
|
|
1093 |
if (atSign !== -1) {
|
|
1094 |
auth = rest.slice(0, atSign);
|
|
1095 |
rest = rest.slice(atSign + 1);
|
|
1096 |
this.auth = decodeURIComponent(auth);
|
|
1097 |
}
|
|
1098 |
|
|
1099 |
// the host is the remaining to the left of the first non-host char
|
|
1100 |
hostEnd = -1;
|
|
1101 |
for (var i = 0; i < nonHostChars.length; i++) {
|
|
1102 |
var hec = rest.indexOf(nonHostChars[i]);
|
|
1103 |
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
1104 |
hostEnd = hec;
|
|
1105 |
}
|
|
1106 |
// if we still have not hit it, then the entire thing is a host.
|
|
1107 |
if (hostEnd === -1)
|
|
1108 |
hostEnd = rest.length;
|
|
1109 |
|
|
1110 |
this.host = rest.slice(0, hostEnd);
|
|
1111 |
rest = rest.slice(hostEnd);
|
|
1112 |
|
|
1113 |
// pull out port.
|
|
1114 |
this.parseHost();
|
|
1115 |
|
|
1116 |
// we've indicated that there is a hostname,
|
|
1117 |
// so even if it's empty, it has to be present.
|
|
1118 |
this.hostname = this.hostname || '';
|
|
1119 |
|
|
1120 |
// if hostname begins with [ and ends with ]
|
|
1121 |
// assume that it's an IPv6 address.
|
|
1122 |
var ipv6Hostname = this.hostname[0] === '[' &&
|
|
1123 |
this.hostname[this.hostname.length - 1] === ']';
|
|
1124 |
|
|
1125 |
// validate a little.
|
|
1126 |
if (!ipv6Hostname) {
|
|
1127 |
var hostparts = this.hostname.split(/\./);
|
|
1128 |
for (var i = 0, l = hostparts.length; i < l; i++) {
|
|
1129 |
var part = hostparts[i];
|
|
1130 |
if (!part) continue;
|
|
1131 |
if (!part.match(hostnamePartPattern)) {
|
|
1132 |
var newpart = '';
|
|
1133 |
for (var j = 0, k = part.length; j < k; j++) {
|
|
1134 |
if (part.charCodeAt(j) > 127) {
|
|
1135 |
// we replace non-ASCII char with a temporary placeholder
|
|
1136 |
// we need this to make sure size of hostname is not
|
|
1137 |
// broken by replacing non-ASCII by nothing
|
|
1138 |
newpart += 'x';
|
|
1139 |
} else {
|
|
1140 |
newpart += part[j];
|
|
1141 |
}
|
|
1142 |
}
|
|
1143 |
// we test again with ASCII char only
|
|
1144 |
if (!newpart.match(hostnamePartPattern)) {
|
|
1145 |
var validParts = hostparts.slice(0, i);
|
|
1146 |
var notHost = hostparts.slice(i + 1);
|
|
1147 |
var bit = part.match(hostnamePartStart);
|
|
1148 |
if (bit) {
|
|
1149 |
validParts.push(bit[1]);
|
|
1150 |
notHost.unshift(bit[2]);
|
|
1151 |
}
|
|
1152 |
if (notHost.length) {
|
|
1153 |
rest = '/' + notHost.join('.') + rest;
|
|
1154 |
}
|
|
1155 |
this.hostname = validParts.join('.');
|
|
1156 |
break;
|
|
1157 |
}
|
|
1158 |
}
|
|
1159 |
}
|
|
1160 |
}
|
|
1161 |
|
|
1162 |
if (this.hostname.length > hostnameMaxLen) {
|
|
1163 |
this.hostname = '';
|
|
1164 |
} else {
|
|
1165 |
// hostnames are always lower case.
|
|
1166 |
this.hostname = this.hostname.toLowerCase();
|
|
1167 |
}
|
|
1168 |
|
|
1169 |
if (!ipv6Hostname) {
|
|
1170 |
// IDNA Support: Returns a puny coded representation of "domain".
|
|
1171 |
// It only converts the part of the domain name that
|
|
1172 |
// has non ASCII characters. I.e. it dosent matter if
|
|
1173 |
// you call it with a domain that already is in ASCII.
|
|
1174 |
var domainArray = this.hostname.split('.');
|
|
1175 |
var newOut = [];
|
|
1176 |
for (var i = 0; i < domainArray.length; ++i) {
|
|
1177 |
var s = domainArray[i];
|
|
1178 |
newOut.push(s.match(/[^A-Za-z0-9_-]/) ?
|
|
1179 |
'xn--' + punycode.encode(s) : s);
|
|
1180 |
}
|
|
1181 |
this.hostname = newOut.join('.');
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
var p = this.port ? ':' + this.port : '';
|
|
1185 |
var h = this.hostname || '';
|
|
1186 |
this.host = h + p;
|
|
1187 |
this.href += this.host;
|
|
1188 |
|
|
1189 |
// strip [ and ] from the hostname
|
|
1190 |
// the host field still retains them, though
|
|
1191 |
if (ipv6Hostname) {
|
|
1192 |
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
|
1193 |
if (rest[0] !== '/') {
|
|
1194 |
rest = '/' + rest;
|
|
1195 |
}
|
|
1196 |
}
|
|
1197 |
}
|
|
1198 |
|
|
1199 |
// now rest is set to the post-host stuff.
|
|
1200 |
// chop off any delim chars.
|
|
1201 |
if (!unsafeProtocol[lowerProto]) {
|
|
1202 |
|
|
1203 |
// First, make 100% sure that any "autoEscape" chars get
|
|
1204 |
// escaped, even if encodeURIComponent doesn't think they
|
|
1205 |
// need to be.
|
|
1206 |
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
|
1207 |
var ae = autoEscape[i];
|
|
1208 |
var esc = encodeURIComponent(ae);
|
|
1209 |
if (esc === ae) {
|
|
1210 |
esc = escape(ae);
|
|
1211 |
}
|
|
1212 |
rest = rest.split(ae).join(esc);
|
|
1213 |
}
|
|
1214 |
}
|
|
1215 |
|
|
1216 |
|
|
1217 |
// chop off from the tail first.
|
|
1218 |
var hash = rest.indexOf('#');
|
|
1219 |
if (hash !== -1) {
|
|
1220 |
// got a fragment string.
|
|
1221 |
this.hash = rest.substr(hash);
|
|
1222 |
rest = rest.slice(0, hash);
|
|
1223 |
}
|
|
1224 |
var qm = rest.indexOf('?');
|
|
1225 |
if (qm !== -1) {
|
|
1226 |
this.search = rest.substr(qm);
|
|
1227 |
this.query = rest.substr(qm + 1);
|
|
1228 |
if (parseQueryString) {
|
|
1229 |
this.query = querystring.parse(this.query);
|
|
1230 |
}
|
|
1231 |
rest = rest.slice(0, qm);
|
|
1232 |
} else if (parseQueryString) {
|
|
1233 |
// no query string, but parseQueryString still requested
|
|
1234 |
this.search = '';
|
|
1235 |
this.query = {};
|
|
1236 |
}
|
|
1237 |
if (rest) this.pathname = rest;
|
|
1238 |
if (slashedProtocol[lowerProto] &&
|
|
1239 |
this.hostname && !this.pathname) {
|
|
1240 |
this.pathname = '/';
|
|
1241 |
}
|
|
1242 |
|
|
1243 |
//to support http.request
|
|
1244 |
if (this.pathname || this.search) {
|
|
1245 |
var p = this.pathname || '';
|
|
1246 |
var s = this.search || '';
|
|
1247 |
this.path = p + s;
|
|
1248 |
}
|
|
1249 |
|
|
1250 |
// finally, reconstruct the href based on what has been validated.
|
|
1251 |
this.href = this.format();
|
|
1252 |
return this;
|
|
1253 |
};
|
|
1254 |
|
|
1255 |
// format a parsed object into a url string
|
|
1256 |
function urlFormat(obj) {
|
|
1257 |
// ensure it's an object, and not a string url.
|
|
1258 |
// If it's an obj, this is a no-op.
|
|
1259 |
// this way, you can call url_format() on strings
|
|
1260 |
// to clean up potentially wonky urls.
|
|
1261 |
if (isString(obj)) obj = urlParse(obj);
|
|
1262 |
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
|
|
1263 |
return obj.format();
|
|
1264 |
}
|
|
1265 |
|
|
1266 |
Url.prototype.format = function() {
|
|
1267 |
var auth = this.auth || '';
|
|
1268 |
if (auth) {
|
|
1269 |
auth = encodeURIComponent(auth);
|
|
1270 |
auth = auth.replace(/%3A/i, ':');
|
|
1271 |
auth += '@';
|
|
1272 |
}
|
|
1273 |
|
|
1274 |
var protocol = this.protocol || '',
|
|
1275 |
pathname = this.pathname || '',
|
|
1276 |
hash = this.hash || '',
|
|
1277 |
host = false,
|
|
1278 |
query = '';
|
|
1279 |
|
|
1280 |
if (this.host) {
|
|
1281 |
host = auth + this.host;
|
|
1282 |
} else if (this.hostname) {
|
|
1283 |
host = auth + (this.hostname.indexOf(':') === -1 ?
|
|
1284 |
this.hostname :
|
|
1285 |
'[' + this.hostname + ']');
|
|
1286 |
if (this.port) {
|
|
1287 |
host += ':' + this.port;
|
|
1288 |
}
|
|
1289 |
}
|
|
1290 |
|
|
1291 |
if (this.query &&
|
|
1292 |
isObject(this.query) &&
|
|
1293 |
Object.keys(this.query).length) {
|
|
1294 |
query = querystring.stringify(this.query);
|
|
1295 |
}
|
|
1296 |
|
|
1297 |
var search = this.search || (query && ('?' + query)) || '';
|
|
1298 |
|
|
1299 |
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
|
1300 |
|
|
1301 |
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
|
1302 |
// unless they had them to begin with.
|
|
1303 |
if (this.slashes ||
|
|
1304 |
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
|
1305 |
host = '//' + (host || '');
|
|
1306 |
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
|
1307 |
} else if (!host) {
|
|
1308 |
host = '';
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
|
1312 |
if (search && search.charAt(0) !== '?') search = '?' + search;
|
|
1313 |
|
|
1314 |
pathname = pathname.replace(/[?#]/g, function(match) {
|
|
1315 |
return encodeURIComponent(match);
|
|
1316 |
});
|
|
1317 |
search = search.replace('#', '%23');
|
|
1318 |
|
|
1319 |
return protocol + host + pathname + search + hash;
|
|
1320 |
};
|
|
1321 |
|
|
1322 |
function urlResolve(source, relative) {
|
|
1323 |
return urlParse(source, false, true).resolve(relative);
|
|
1324 |
}
|
|
1325 |
|
|
1326 |
Url.prototype.resolve = function(relative) {
|
|
1327 |
return this.resolveObject(urlParse(relative, false, true)).format();
|
|
1328 |
};
|
|
1329 |
|
|
1330 |
function urlResolveObject(source, relative) {
|
|
1331 |
if (!source) return relative;
|
|
1332 |
return urlParse(source, false, true).resolveObject(relative);
|
|
1333 |
}
|
|
1334 |
|
|
1335 |
Url.prototype.resolveObject = function(relative) {
|
|
1336 |
if (isString(relative)) {
|
|
1337 |
var rel = new Url();
|
|
1338 |
rel.parse(relative, false, true);
|
|
1339 |
relative = rel;
|
|
1340 |
}
|
|
1341 |
|
|
1342 |
var result = new Url();
|
|
1343 |
Object.keys(this).forEach(function(k) {
|
|
1344 |
result[k] = this[k];
|
|
1345 |
}, this);
|
|
1346 |
|
|
1347 |
// hash is always overridden, no matter what.
|
|
1348 |
// even href="" will remove it.
|
|
1349 |
result.hash = relative.hash;
|
|
1350 |
|
|
1351 |
// if the relative url is empty, then there's nothing left to do here.
|
|
1352 |
if (relative.href === '') {
|
|
1353 |
result.href = result.format();
|
|
1354 |
return result;
|
|
1355 |
}
|
|
1356 |
|
|
1357 |
// hrefs like //foo/bar always cut to the protocol.
|
|
1358 |
if (relative.slashes && !relative.protocol) {
|
|
1359 |
// take everything except the protocol from relative
|
|
1360 |
Object.keys(relative).forEach(function(k) {
|
|
1361 |
if (k !== 'protocol')
|
|
1362 |
result[k] = relative[k];
|
|
1363 |
});
|
|
1364 |
|
|
1365 |
//urlParse appends trailing / to urls like http://www.example.com
|
|
1366 |
if (slashedProtocol[result.protocol] &&
|
|
1367 |
result.hostname && !result.pathname) {
|
|
1368 |
result.path = result.pathname = '/';
|
|
1369 |
}
|
|
1370 |
|
|
1371 |
result.href = result.format();
|
|
1372 |
return result;
|
|
1373 |
}
|
|
1374 |
|
|
1375 |
if (relative.protocol && relative.protocol !== result.protocol) {
|
|
1376 |
// if it's a known url protocol, then changing
|
|
1377 |
// the protocol does weird things
|
|
1378 |
// first, if it's not file:, then we MUST have a host,
|
|
1379 |
// and if there was a path
|
|
1380 |
// to begin with, then we MUST have a path.
|
|
1381 |
// if it is file:, then the host is dropped,
|
|
1382 |
// because that's known to be hostless.
|
|
1383 |
// anything else is assumed to be absolute.
|
|
1384 |
if (!slashedProtocol[relative.protocol]) {
|
|
1385 |
Object.keys(relative).forEach(function(k) {
|
|
1386 |
result[k] = relative[k];
|
|
1387 |
});
|
|
1388 |
result.href = result.format();
|
|
1389 |
return result;
|
|
1390 |
}
|
|
1391 |
|
|
1392 |
result.protocol = relative.protocol;
|
|
1393 |
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
|
1394 |
var relPath = (relative.pathname || '').split('/');
|
|
1395 |
while (relPath.length && !(relative.host = relPath.shift()));
|
|
1396 |
if (!relative.host) relative.host = '';
|
|
1397 |
if (!relative.hostname) relative.hostname = '';
|
|
1398 |
if (relPath[0] !== '') relPath.unshift('');
|
|
1399 |
if (relPath.length < 2) relPath.unshift('');
|
|
1400 |
result.pathname = relPath.join('/');
|
|
1401 |
} else {
|
|
1402 |
result.pathname = relative.pathname;
|
|
1403 |
}
|
|
1404 |
result.search = relative.search;
|
|
1405 |
result.query = relative.query;
|
|
1406 |
result.host = relative.host || '';
|
|
1407 |
result.auth = relative.auth;
|
|
1408 |
result.hostname = relative.hostname || relative.host;
|
|
1409 |
result.port = relative.port;
|
|
1410 |
// to support http.request
|
|
1411 |
if (result.pathname || result.search) {
|
|
1412 |
var p = result.pathname || '';
|
|
1413 |
var s = result.search || '';
|
|
1414 |
result.path = p + s;
|
|
1415 |
}
|
|
1416 |
result.slashes = result.slashes || relative.slashes;
|
|
1417 |
result.href = result.format();
|
|
1418 |
return result;
|
|
1419 |
}
|
|
1420 |
|
|
1421 |
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
|
|
1422 |
isRelAbs = (
|
|
1423 |
relative.host ||
|
|
1424 |
relative.pathname && relative.pathname.charAt(0) === '/'
|
|
1425 |
),
|
|
1426 |
mustEndAbs = (isRelAbs || isSourceAbs ||
|
|
1427 |
(result.host && relative.pathname)),
|
|
1428 |
removeAllDots = mustEndAbs,
|
|
1429 |
srcPath = result.pathname && result.pathname.split('/') || [],
|
|
1430 |
relPath = relative.pathname && relative.pathname.split('/') || [],
|
|
1431 |
psychotic = result.protocol && !slashedProtocol[result.protocol];
|
|
1432 |
|
|
1433 |
// if the url is a non-slashed url, then relative
|
|
1434 |
// links like ../.. should be able
|
|
1435 |
// to crawl up to the hostname, as well. This is strange.
|
|
1436 |
// result.protocol has already been set by now.
|
|
1437 |
// Later on, put the first path part into the host field.
|
|
1438 |
if (psychotic) {
|
|
1439 |
result.hostname = '';
|
|
1440 |
result.port = null;
|
|
1441 |
if (result.host) {
|
|
1442 |
if (srcPath[0] === '') srcPath[0] = result.host;
|
|
1443 |
else srcPath.unshift(result.host);
|
|
1444 |
}
|
|
1445 |
result.host = '';
|
|
1446 |
if (relative.protocol) {
|
|
1447 |
relative.hostname = null;
|
|
1448 |
relative.port = null;
|
|
1449 |
if (relative.host) {
|
|
1450 |
if (relPath[0] === '') relPath[0] = relative.host;
|
|
1451 |
else relPath.unshift(relative.host);
|
|
1452 |
}
|
|
1453 |
relative.host = null;
|
|
1454 |
}
|
|
1455 |
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
|
1456 |
}
|
|
1457 |
|
|
1458 |
if (isRelAbs) {
|
|
1459 |
// it's absolute.
|
|
1460 |
result.host = (relative.host || relative.host === '') ?
|
|
1461 |
relative.host : result.host;
|
|
1462 |
result.hostname = (relative.hostname || relative.hostname === '') ?
|
|
1463 |
relative.hostname : result.hostname;
|
|
1464 |
result.search = relative.search;
|
|
1465 |
result.query = relative.query;
|
|
1466 |
srcPath = relPath;
|
|
1467 |
// fall through to the dot-handling below.
|
|
1468 |
} else if (relPath.length) {
|
|
1469 |
// it's relative
|
|
1470 |
// throw away the existing file, and take the new path instead.
|
|
1471 |
if (!srcPath) srcPath = [];
|
|
1472 |
srcPath.pop();
|
|
1473 |
srcPath = srcPath.concat(relPath);
|
|
1474 |
result.search = relative.search;
|
|
1475 |
result.query = relative.query;
|
|
1476 |
} else if (!isNullOrUndefined(relative.search)) {
|
|
1477 |
// just pull out the search.
|
|
1478 |
// like href='?foo'.
|
|
1479 |
// Put this after the other two cases because it simplifies the booleans
|
|
1480 |
if (psychotic) {
|
|
1481 |
result.hostname = result.host = srcPath.shift();
|
|
1482 |
//occationaly the auth can get stuck only in host
|
|
1483 |
//this especialy happens in cases like
|
|
1484 |
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
1485 |
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
|
1486 |
result.host.split('@') : false;
|
|
1487 |
if (authInHost) {
|
|
1488 |
result.auth = authInHost.shift();
|
|
1489 |
result.host = result.hostname = authInHost.shift();
|
|
1490 |
}
|
|
1491 |
}
|
|
1492 |
result.search = relative.search;
|
|
1493 |
result.query = relative.query;
|
|
1494 |
//to support http.request
|
|
1495 |
if (!isNull(result.pathname) || !isNull(result.search)) {
|
|
1496 |
result.path = (result.pathname ? result.pathname : '') +
|
|
1497 |
(result.search ? result.search : '');
|
|
1498 |
}
|
|
1499 |
result.href = result.format();
|
|
1500 |
return result;
|
|
1501 |
}
|
|
1502 |
|
|
1503 |
if (!srcPath.length) {
|
|
1504 |
// no path at all. easy.
|
|
1505 |
// we've already handled the other stuff above.
|
|
1506 |
result.pathname = null;
|
|
1507 |
//to support http.request
|
|
1508 |
if (result.search) {
|
|
1509 |
result.path = '/' + result.search;
|
|
1510 |
} else {
|
|
1511 |
result.path = null;
|
|
1512 |
}
|
|
1513 |
result.href = result.format();
|
|
1514 |
return result;
|
|
1515 |
}
|
|
1516 |
|
|
1517 |
// if a url ENDs in . or .., then it must get a trailing slash.
|
|
1518 |
// however, if it ends in anything else non-slashy,
|
|
1519 |
// then it must NOT get a trailing slash.
|
|
1520 |
var last = srcPath.slice(-1)[0];
|
|
1521 |
var hasTrailingSlash = (
|
|
1522 |
(result.host || relative.host) && (last === '.' || last === '..') ||
|
|
1523 |
last === '');
|
|
1524 |
|
|
1525 |
// strip single dots, resolve double dots to parent dir
|
|
1526 |
// if the path tries to go above the root, `up` ends up > 0
|
|
1527 |
var up = 0;
|
|
1528 |
for (var i = srcPath.length; i >= 0; i--) {
|
|
1529 |
last = srcPath[i];
|
|
1530 |
if (last == '.') {
|
|
1531 |
srcPath.splice(i, 1);
|
|
1532 |
} else if (last === '..') {
|
|
1533 |
srcPath.splice(i, 1);
|
|
1534 |
up++;
|
|
1535 |
} else if (up) {
|
|
1536 |
srcPath.splice(i, 1);
|
|
1537 |
up--;
|
|
1538 |
}
|
|
1539 |
}
|
|
1540 |
|
|
1541 |
// if the path is allowed to go above the root, restore leading ..s
|
|
1542 |
if (!mustEndAbs && !removeAllDots) {
|
|
1543 |
for (; up--; up) {
|
|
1544 |
srcPath.unshift('..');
|
|
1545 |
}
|
|
1546 |
}
|
|
1547 |
|
|
1548 |
if (mustEndAbs && srcPath[0] !== '' &&
|
|
1549 |
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
|
1550 |
srcPath.unshift('');
|
|
1551 |
}
|
|
1552 |
|
|
1553 |
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
|
1554 |
srcPath.push('');
|
|
1555 |
}
|
|
1556 |
|
|
1557 |
var isAbsolute = srcPath[0] === '' ||
|
|
1558 |
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
|
1559 |
|
|
1560 |
// put the host back
|
|
1561 |
if (psychotic) {
|
|
1562 |
result.hostname = result.host = isAbsolute ? '' :
|
|
1563 |
srcPath.length ? srcPath.shift() : '';
|
|
1564 |
//occationaly the auth can get stuck only in host
|
|
1565 |
//this especialy happens in cases like
|
|
1566 |
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
1567 |
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
|
1568 |
result.host.split('@') : false;
|
|
1569 |
if (authInHost) {
|
|
1570 |
result.auth = authInHost.shift();
|
|
1571 |
result.host = result.hostname = authInHost.shift();
|
|
1572 |
}
|
|
1573 |
}
|
|
1574 |
|
|
1575 |
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
|
|
1576 |
|
|
1577 |
if (mustEndAbs && !isAbsolute) {
|
|
1578 |
srcPath.unshift('');
|
|
1579 |
}
|
|
1580 |
|
|
1581 |
if (!srcPath.length) {
|
|
1582 |
result.pathname = null;
|
|
1583 |
result.path = null;
|
|
1584 |
} else {
|
|
1585 |
result.pathname = srcPath.join('/');
|
|
1586 |
}
|
|
1587 |
|
|
1588 |
//to support request.http
|
|
1589 |
if (!isNull(result.pathname) || !isNull(result.search)) {
|
|
1590 |
result.path = (result.pathname ? result.pathname : '') +
|
|
1591 |
(result.search ? result.search : '');
|
|
1592 |
}
|
|
1593 |
result.auth = relative.auth || result.auth;
|
|
1594 |
result.slashes = result.slashes || relative.slashes;
|
|
1595 |
result.href = result.format();
|
|
1596 |
return result;
|
|
1597 |
};
|
|
1598 |
|
|
1599 |
Url.prototype.parseHost = function() {
|
|
1600 |
var host = this.host;
|
|
1601 |
var port = portPattern.exec(host);
|
|
1602 |
if (port) {
|
|
1603 |
port = port[0];
|
|
1604 |
if (port !== ':') {
|
|
1605 |
this.port = port.substr(1);
|
|
1606 |
}
|
|
1607 |
host = host.substr(0, host.length - port.length);
|
|
1608 |
}
|
|
1609 |
if (host) this.hostname = host;
|
|
1610 |
};
|
|
1611 |
|
|
1612 |
function isString(arg) {
|
|
1613 |
return typeof arg === "string";
|
|
1614 |
}
|
|
1615 |
|
|
1616 |
function isObject(arg) {
|
|
1617 |
return typeof arg === 'object' && arg !== null;
|
|
1618 |
}
|
|
1619 |
|
|
1620 |
function isNull(arg) {
|
|
1621 |
return arg === null;
|
|
1622 |
}
|
|
1623 |
function isNullOrUndefined(arg) {
|
|
1624 |
return arg == null;
|
|
1625 |
}
|
|
1626 |
|
|
1627 |
|
|
1628 |
/***/ },
|
|
1629 |
/* 9 */
|
|
1630 |
/***/ function(module, exports, __webpack_require__) {
|
|
1631 |
|
|
1632 |
var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module, global) {/*! https://mths.be/punycode v1.3.2 by @mathias */
|
|
1633 |
;(function(root) {
|
|
1634 |
|
|
1635 |
/** Detect free variables */
|
|
1636 |
var freeExports = typeof exports == 'object' && exports &&
|
|
1637 |
!exports.nodeType && exports;
|
|
1638 |
var freeModule = typeof module == 'object' && module &&
|
|
1639 |
!module.nodeType && module;
|
|
1640 |
var freeGlobal = typeof global == 'object' && global;
|
|
1641 |
if (
|
|
1642 |
freeGlobal.global === freeGlobal ||
|
|
1643 |
freeGlobal.window === freeGlobal ||
|
|
1644 |
freeGlobal.self === freeGlobal
|
|
1645 |
) {
|
|
1646 |
root = freeGlobal;
|
|
1647 |
}
|
|
1648 |
|
|
1649 |
/**
|
|
1650 |
* The `punycode` object.
|
|
1651 |
* @name punycode
|
|
1652 |
* @type Object
|
|
1653 |
*/
|
|
1654 |
var punycode,
|
|
1655 |
|
|
1656 |
/** Highest positive signed 32-bit float value */
|
|
1657 |
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
|
1658 |
|
|
1659 |
/** Bootstring parameters */
|
|
1660 |
base = 36,
|
|
1661 |
tMin = 1,
|
|
1662 |
tMax = 26,
|
|
1663 |
skew = 38,
|
|
1664 |
damp = 700,
|
|
1665 |
initialBias = 72,
|
|
1666 |
initialN = 128, // 0x80
|
|
1667 |
delimiter = '-', // '\x2D'
|
|
1668 |
|
|
1669 |
/** Regular expressions */
|
|
1670 |
regexPunycode = /^xn--/,
|
|
1671 |
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
|
|
1672 |
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
|
|
1673 |
|
|
1674 |
/** Error messages */
|
|
1675 |
errors = {
|
|
1676 |
'overflow': 'Overflow: input needs wider integers to process',
|
|
1677 |
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
1678 |
'invalid-input': 'Invalid input'
|
|
1679 |
},
|
|
1680 |
|
|
1681 |
/** Convenience shortcuts */
|
|
1682 |
baseMinusTMin = base - tMin,
|
|
1683 |
floor = Math.floor,
|
|
1684 |
stringFromCharCode = String.fromCharCode,
|
|
1685 |
|
|
1686 |
/** Temporary variable */
|
|
1687 |
key;
|
|
1688 |
|
|
1689 |
/*--------------------------------------------------------------------------*/
|
|
1690 |
|
|
1691 |
/**
|
|
1692 |
* A generic error utility function.
|
|
1693 |
* @private
|
|
1694 |
* @param {String} type The error type.
|
|
1695 |
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
|
1696 |
*/
|
|
1697 |
function error(type) {
|
|
1698 |
throw RangeError(errors[type]);
|
|
1699 |
}
|
|
1700 |
|
|
1701 |
/**
|
|
1702 |
* A generic `Array#map` utility function.
|
|
1703 |
* @private
|
|
1704 |
* @param {Array} array The array to iterate over.
|
|
1705 |
* @param {Function} callback The function that gets called for every array
|
|
1706 |
* item.
|
|
1707 |
* @returns {Array} A new array of values returned by the callback function.
|
|
1708 |
*/
|
|
1709 |
function map(array, fn) {
|
|
1710 |
var length = array.length;
|
|
1711 |
var result = [];
|
|
1712 |
while (length--) {
|
|
1713 |
result[length] = fn(array[length]);
|
|
1714 |
}
|
|
1715 |
return result;
|
|
1716 |
}
|
|
1717 |
|
|
1718 |
/**
|
|
1719 |
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
|
1720 |
* addresses.
|
|
1721 |
* @private
|
|
1722 |
* @param {String} domain The domain name or email address.
|
|
1723 |
* @param {Function} callback The function that gets called for every
|
|
1724 |
* character.
|
|
1725 |
* @returns {Array} A new string of characters returned by the callback
|
|
1726 |
* function.
|
|
1727 |
*/
|
|
1728 |
function mapDomain(string, fn) {
|
|
1729 |
var parts = string.split('@');
|
|
1730 |
var result = '';
|
|
1731 |
if (parts.length > 1) {
|
|
1732 |
// In email addresses, only the domain name should be punycoded. Leave
|
|
1733 |
// the local part (i.e. everything up to `@`) intact.
|
|
1734 |
result = parts[0] + '@';
|
|
1735 |
string = parts[1];
|
|
1736 |
}
|
|
1737 |
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
|
1738 |
string = string.replace(regexSeparators, '\x2E');
|
|
1739 |
var labels = string.split('.');
|
|
1740 |
var encoded = map(labels, fn).join('.');
|
|
1741 |
return result + encoded;
|
|
1742 |
}
|
|
1743 |
|
|
1744 |
/**
|
|
1745 |
* Creates an array containing the numeric code points of each Unicode
|
|
1746 |
* character in the string. While JavaScript uses UCS-2 internally,
|
|
1747 |
* this function will convert a pair of surrogate halves (each of which
|
|
1748 |
* UCS-2 exposes as separate characters) into a single code point,
|
|
1749 |
* matching UTF-16.
|
|
1750 |
* @see `punycode.ucs2.encode`
|
|
1751 |
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
1752 |
* @memberOf punycode.ucs2
|
|
1753 |
* @name decode
|
|
1754 |
* @param {String} string The Unicode input string (UCS-2).
|
|
1755 |
* @returns {Array} The new array of code points.
|
|
1756 |
*/
|
|
1757 |
function ucs2decode(string) {
|
|
1758 |
var output = [],
|
|
1759 |
counter = 0,
|
|
1760 |
length = string.length,
|
|
1761 |
value,
|
|
1762 |
extra;
|
|
1763 |
while (counter < length) {
|
|
1764 |
value = string.charCodeAt(counter++);
|
|
1765 |
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
1766 |
// high surrogate, and there is a next character
|
|
1767 |
extra = string.charCodeAt(counter++);
|
|
1768 |
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
|
1769 |
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
1770 |
} else {
|
|
1771 |
// unmatched surrogate; only append this code unit, in case the next
|
|
1772 |
// code unit is the high surrogate of a surrogate pair
|
|
1773 |
output.push(value);
|
|
1774 |
counter--;
|
|
1775 |
}
|
|
1776 |
} else {
|
|
1777 |
output.push(value);
|
|
1778 |
}
|
|
1779 |
}
|
|
1780 |
return output;
|
|
1781 |
}
|
|
1782 |
|
|
1783 |
/**
|
|
1784 |
* Creates a string based on an array of numeric code points.
|
|
1785 |
* @see `punycode.ucs2.decode`
|
|
1786 |
* @memberOf punycode.ucs2
|
|
1787 |
* @name encode
|
|
1788 |
* @param {Array} codePoints The array of numeric code points.
|
|
1789 |
* @returns {String} The new Unicode string (UCS-2).
|
|
1790 |
*/
|
|
1791 |
function ucs2encode(array) {
|
|
1792 |
return map(array, function(value) {
|
|
1793 |
var output = '';
|
|
1794 |
if (value > 0xFFFF) {
|
|
1795 |
value -= 0x10000;
|
|
1796 |
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
|
1797 |
value = 0xDC00 | value & 0x3FF;
|
|
1798 |
}
|
|
1799 |
output += stringFromCharCode(value);
|
|
1800 |
return output;
|
|
1801 |
}).join('');
|
|
1802 |
}
|
|
1803 |
|
|
1804 |
/**
|
|
1805 |
* Converts a basic code point into a digit/integer.
|
|
1806 |
* @see `digitToBasic()`
|
|
1807 |
* @private
|
|
1808 |
* @param {Number} codePoint The basic numeric code point value.
|
|
1809 |
* @returns {Number} The numeric value of a basic code point (for use in
|
|
1810 |
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
1811 |
* the code point does not represent a value.
|
|
1812 |
*/
|
|
1813 |
function basicToDigit(codePoint) {
|
|
1814 |
if (codePoint - 48 < 10) {
|
|
1815 |
return codePoint - 22;
|
|
1816 |
}
|
|
1817 |
if (codePoint - 65 < 26) {
|
|
1818 |
return codePoint - 65;
|
|
1819 |
}
|
|
1820 |
if (codePoint - 97 < 26) {
|
|
1821 |
return codePoint - 97;
|
|
1822 |
}
|
|
1823 |
return base;
|
|
1824 |
}
|
|
1825 |
|
|
1826 |
/**
|
|
1827 |
* Converts a digit/integer into a basic code point.
|
|
1828 |
* @see `basicToDigit()`
|
|
1829 |
* @private
|
|
1830 |
* @param {Number} digit The numeric value of a basic code point.
|
|
1831 |
* @returns {Number} The basic code point whose value (when used for
|
|
1832 |
* representing integers) is `digit`, which needs to be in the range
|
|
1833 |
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
1834 |
* used; else, the lowercase form is used. The behavior is undefined
|
|
1835 |
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
1836 |
*/
|
|
1837 |
function digitToBasic(digit, flag) {
|
|
1838 |
// 0..25 map to ASCII a..z or A..Z
|
|
1839 |
// 26..35 map to ASCII 0..9
|
|
1840 |
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
1841 |
}
|
|
1842 |
|
|
1843 |
/**
|
|
1844 |
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
1845 |
* http://tools.ietf.org/html/rfc3492#section-3.4
|
|
1846 |
* @private
|
|
1847 |
*/
|
|
1848 |
function adapt(delta, numPoints, firstTime) {
|
|
1849 |
var k = 0;
|
|
1850 |
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
1851 |
delta += floor(delta / numPoints);
|
|
1852 |
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
1853 |
delta = floor(delta / baseMinusTMin);
|
|
1854 |
}
|
|
1855 |
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
1856 |
}
|
|
1857 |
|
|
1858 |
/**
|
|
1859 |
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
|
1860 |
* symbols.
|
|
1861 |
* @memberOf punycode
|
|
1862 |
* @param {String} input The Punycode string of ASCII-only symbols.
|
|
1863 |
* @returns {String} The resulting string of Unicode symbols.
|
|
1864 |
*/
|
|
1865 |
function decode(input) {
|
|
1866 |
// Don't use UCS-2
|
|
1867 |
var output = [],
|
|
1868 |
inputLength = input.length,
|
|
1869 |
out,
|
|
1870 |
i = 0,
|
|
1871 |
n = initialN,
|
|
1872 |
bias = initialBias,
|
|
1873 |
basic,
|
|
1874 |
j,
|
|
1875 |
index,
|
|
1876 |
oldi,
|
|
1877 |
w,
|
|
1878 |
k,
|
|
1879 |
digit,
|
|
1880 |
t,
|
|
1881 |
/** Cached calculation results */
|
|
1882 |
baseMinusT;
|
|
1883 |
|
|
1884 |
// Handle the basic code points: let `basic` be the number of input code
|
|
1885 |
// points before the last delimiter, or `0` if there is none, then copy
|
|
1886 |
// the first basic code points to the output.
|
|
1887 |
|
|
1888 |
basic = input.lastIndexOf(delimiter);
|
|
1889 |
if (basic < 0) {
|
|
1890 |
basic = 0;
|
|
1891 |
}
|
|
1892 |
|
|
1893 |
for (j = 0; j < basic; ++j) {
|
|
1894 |
// if it's not a basic code point
|
|
1895 |
if (input.charCodeAt(j) >= 0x80) {
|
|
1896 |
error('not-basic');
|
|
1897 |
}
|
|
1898 |
output.push(input.charCodeAt(j));
|
|
1899 |
}
|
|
1900 |
|
|
1901 |
// Main decoding loop: start just after the last delimiter if any basic code
|
|
1902 |
// points were copied; start at the beginning otherwise.
|
|
1903 |
|
|
1904 |
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
|
1905 |
|
|
1906 |
// `index` is the index of the next character to be consumed.
|
|
1907 |
// Decode a generalized variable-length integer into `delta`,
|
|
1908 |
// which gets added to `i`. The overflow checking is easier
|
|
1909 |
// if we increase `i` as we go, then subtract off its starting
|
|
1910 |
// value at the end to obtain `delta`.
|
|
1911 |
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
|
1912 |
|
|
1913 |
if (index >= inputLength) {
|
|
1914 |
error('invalid-input');
|
|
1915 |
}
|
|
1916 |
|
|
1917 |
digit = basicToDigit(input.charCodeAt(index++));
|
|
1918 |
|
|
1919 |
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
1920 |
error('overflow');
|
|
1921 |
}
|
|
1922 |
|
|
1923 |
i += digit * w;
|
|
1924 |
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
1925 |
|
|
1926 |
if (digit < t) {
|
|
1927 |
break;
|
|
1928 |
}
|
|
1929 |
|
|
1930 |
baseMinusT = base - t;
|
|
1931 |
if (w > floor(maxInt / baseMinusT)) {
|
|
1932 |
error('overflow');
|
|
1933 |
}
|
|
1934 |
|
|
1935 |
w *= baseMinusT;
|
|
1936 |
|
|
1937 |
}
|
|
1938 |
|
|
1939 |
out = output.length + 1;
|
|
1940 |
bias = adapt(i - oldi, out, oldi == 0);
|
|
1941 |
|
|
1942 |
// `i` was supposed to wrap around from `out` to `0`,
|
|
1943 |
// incrementing `n` each time, so we'll fix that now:
|
|
1944 |
if (floor(i / out) > maxInt - n) {
|
|
1945 |
error('overflow');
|
|
1946 |
}
|
|
1947 |
|
|
1948 |
n += floor(i / out);
|
|
1949 |
i %= out;
|
|
1950 |
|
|
1951 |
// Insert `n` at position `i` of the output
|
|
1952 |
output.splice(i++, 0, n);
|
|
1953 |
|
|
1954 |
}
|
|
1955 |
|
|
1956 |
return ucs2encode(output);
|
|
1957 |
}
|
|
1958 |
|
|
1959 |
/**
|
|
1960 |
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
|
1961 |
* Punycode string of ASCII-only symbols.
|
|
1962 |
* @memberOf punycode
|
|
1963 |
* @param {String} input The string of Unicode symbols.
|
|
1964 |
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
|
1965 |
*/
|
|
1966 |
function encode(input) {
|
|
1967 |
var n,
|
|
1968 |
delta,
|
|
1969 |
handledCPCount,
|
|
1970 |
basicLength,
|
|
1971 |
bias,
|
|
1972 |
j,
|
|
1973 |
m,
|
|
1974 |
q,
|
|
1975 |
k,
|
|
1976 |
t,
|
|
1977 |
currentValue,
|
|
1978 |
output = [],
|
|
1979 |
/** `inputLength` will hold the number of code points in `input`. */
|
|
1980 |
inputLength,
|
|
1981 |
/** Cached calculation results */
|
|
1982 |
handledCPCountPlusOne,
|
|
1983 |
baseMinusT,
|
|
1984 |
qMinusT;
|
|
1985 |
|
|
1986 |
// Convert the input in UCS-2 to Unicode
|
|
1987 |
input = ucs2decode(input);
|
|
1988 |
|
|
1989 |
// Cache the length
|
|
1990 |
inputLength = input.length;
|
|
1991 |
|
|
1992 |
// Initialize the state
|
|
1993 |
n = initialN;
|
|
1994 |
delta = 0;
|
|
1995 |
bias = initialBias;
|
|
1996 |
|
|
1997 |
// Handle the basic code points
|
|
1998 |
for (j = 0; j < inputLength; ++j) {
|
|
1999 |
currentValue = input[j];
|
|
2000 |
if (currentValue < 0x80) {
|
|
2001 |
output.push(stringFromCharCode(currentValue));
|
|
2002 |
}
|
|
2003 |
}
|
|
2004 |
|
|
2005 |
handledCPCount = basicLength = output.length;
|
|
2006 |
|
|
2007 |
// `handledCPCount` is the number of code points that have been handled;
|
|
2008 |
// `basicLength` is the number of basic code points.
|
|
2009 |
|
|
2010 |
// Finish the basic string - if it is not empty - with a delimiter
|
|
2011 |
if (basicLength) {
|
|
2012 |
output.push(delimiter);
|
|
2013 |
}
|
|
2014 |
|
|
2015 |
// Main encoding loop:
|
|
2016 |
while (handledCPCount < inputLength) {
|
|
2017 |
|
|
2018 |
// All non-basic code points < n have been handled already. Find the next
|
|
2019 |
// larger one:
|
|
2020 |
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
|
2021 |
currentValue = input[j];
|
|
2022 |
if (currentValue >= n && currentValue < m) {
|
|
2023 |
m = currentValue;
|
|
2024 |
}
|
|
2025 |
}
|
|
2026 |
|
|
2027 |
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
2028 |
// but guard against overflow
|
|
2029 |
handledCPCountPlusOne = handledCPCount + 1;
|
|
2030 |
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
2031 |
error('overflow');
|
|
2032 |
}
|
|
2033 |
|
|
2034 |
delta += (m - n) * handledCPCountPlusOne;
|
|
2035 |
n = m;
|
|
2036 |
|
|
2037 |
for (j = 0; j < inputLength; ++j) {
|
|
2038 |
currentValue = input[j];
|
|
2039 |
|
|
2040 |
if (currentValue < n && ++delta > maxInt) {
|
|
2041 |
error('overflow');
|
|
2042 |
}
|
|
2043 |
|
|
2044 |
if (currentValue == n) {
|
|
2045 |
// Represent delta as a generalized variable-length integer
|
|
2046 |
for (q = delta, k = base; /* no condition */; k += base) {
|
|
2047 |
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
2048 |
if (q < t) {
|
|
2049 |
break;
|
|
2050 |
}
|
|
2051 |
qMinusT = q - t;
|
|
2052 |
baseMinusT = base - t;
|
|
2053 |
output.push(
|
|
2054 |
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
2055 |
);
|
|
2056 |
q = floor(qMinusT / baseMinusT);
|
|
2057 |
}
|
|
2058 |
|
|
2059 |
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
2060 |
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
2061 |
delta = 0;
|
|
2062 |
++handledCPCount;
|
|
2063 |
}
|
|
2064 |
}
|
|
2065 |
|
|
2066 |
++delta;
|
|
2067 |
++n;
|
|
2068 |
|
|
2069 |
}
|
|
2070 |
return output.join('');
|
|
2071 |
}
|
|
2072 |
|
|
2073 |
/**
|
|
2074 |
* Converts a Punycode string representing a domain name or an email address
|
|
2075 |
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
|
2076 |
* it doesn't matter if you call it on a string that has already been
|
|
2077 |
* converted to Unicode.
|
|
2078 |
* @memberOf punycode
|
|
2079 |
* @param {String} input The Punycoded domain name or email address to
|
|
2080 |
* convert to Unicode.
|
|
2081 |
* @returns {String} The Unicode representation of the given Punycode
|
|
2082 |
* string.
|
|
2083 |
*/
|
|
2084 |
function toUnicode(input) {
|
|
2085 |
return mapDomain(input, function(string) {
|
|
2086 |
return regexPunycode.test(string)
|
|
2087 |
? decode(string.slice(4).toLowerCase())
|
|
2088 |
: string;
|
|
2089 |
});
|
|
2090 |
}
|
|
2091 |
|
|
2092 |
/**
|
|
2093 |
* Converts a Unicode string representing a domain name or an email address to
|
|
2094 |
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
|
2095 |
* i.e. it doesn't matter if you call it with a domain that's already in
|
|
2096 |
* ASCII.
|
|
2097 |
* @memberOf punycode
|
|
2098 |
* @param {String} input The domain name or email address to convert, as a
|
|
2099 |
* Unicode string.
|
|
2100 |
* @returns {String} The Punycode representation of the given domain name or
|
|
2101 |
* email address.
|
|
2102 |
*/
|
|
2103 |
function toASCII(input) {
|
|
2104 |
return mapDomain(input, function(string) {
|
|
2105 |
return regexNonASCII.test(string)
|
|
2106 |
? 'xn--' + encode(string)
|
|
2107 |
: string;
|
|
2108 |
});
|
|
2109 |
}
|
|
2110 |
|
|
2111 |
/*--------------------------------------------------------------------------*/
|
|
2112 |
|
|
2113 |
/** Define the public API */
|
|
2114 |
punycode = {
|
|
2115 |
/**
|
|
2116 |
* A string representing the current Punycode.js version number.
|
|
2117 |
* @memberOf punycode
|
|
2118 |
* @type String
|
|
2119 |
*/
|
|
2120 |
'version': '1.3.2',
|
|
2121 |
/**
|
|
2122 |
* An object of methods to convert from JavaScript's internal character
|
|
2123 |
* representation (UCS-2) to Unicode code points, and back.
|
|
2124 |
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
2125 |
* @memberOf punycode
|
|
2126 |
* @type Object
|
|
2127 |
*/
|
|
2128 |
'ucs2': {
|
|
2129 |
'decode': ucs2decode,
|
|
2130 |
'encode': ucs2encode
|
|
2131 |
},
|
|
2132 |
'decode': decode,
|
|
2133 |
'encode': encode,
|
|
2134 |
'toASCII': toASCII,
|
|
2135 |
'toUnicode': toUnicode
|
|
2136 |
};
|
|
2137 |
|
|
2138 |
/** Expose `punycode` */
|
|
2139 |
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
2140 |
// like the following:
|
|
2141 |
if (
|
|
2142 |
true
|
|
2143 |
) {
|
|
2144 |
!(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
|
|
2145 |
return punycode;
|
|
2146 |
}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
2147 |
} else if (freeExports && freeModule) {
|
|
2148 |
if (module.exports == freeExports) { // in Node.js or RingoJS v0.8.0+
|
|
2149 |
freeModule.exports = punycode;
|
|
2150 |
} else { // in Narwhal or RingoJS v0.7.0-
|
|
2151 |
for (key in punycode) {
|
|
2152 |
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
2153 |
}
|
|
2154 |
}
|
|
2155 |
} else { // in Rhino or a web browser
|
|
2156 |
root.punycode = punycode;
|
|
2157 |
}
|
|
2158 |
|
|
2159 |
}(this));
|
|
2160 |
|
|
2161 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)(module), (function() { return this; }())))
|
|
2162 |
|
|
2163 |
/***/ },
|
|
2164 |
/* 10 */
|
|
2165 |
/***/ function(module, exports) {
|
|
2166 |
|
|
2167 |
module.exports = function(module) {
|
|
2168 |
if(!module.webpackPolyfill) {
|
|
2169 |
module.deprecate = function() {};
|
|
2170 |
module.paths = [];
|
|
2171 |
// module.parent = undefined by default
|
|
2172 |
module.children = [];
|
|
2173 |
module.webpackPolyfill = 1;
|
|
2174 |
}
|
|
2175 |
return module;
|
|
2176 |
}
|
|
2177 |
|
|
2178 |
|
|
2179 |
/***/ },
|
|
2180 |
/* 11 */
|
|
2181 |
/***/ function(module, exports, __webpack_require__) {
|
|
2182 |
|
|
2183 |
'use strict';
|
|
2184 |
|
|
2185 |
exports.decode = exports.parse = __webpack_require__(12);
|
|
2186 |
exports.encode = exports.stringify = __webpack_require__(13);
|
|
2187 |
|
|
2188 |
|
|
2189 |
/***/ },
|
|
2190 |
/* 12 */
|
|
2191 |
/***/ function(module, exports) {
|
|
2192 |
|
|
2193 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
2194 |
//
|
|
2195 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
2196 |
// copy of this software and associated documentation files (the
|
|
2197 |
// "Software"), to deal in the Software without restriction, including
|
|
2198 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
2199 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
2200 |
// persons to whom the Software is furnished to do so, subject to the
|
|
2201 |
// following conditions:
|
|
2202 |
//
|
|
2203 |
// The above copyright notice and this permission notice shall be included
|
|
2204 |
// in all copies or substantial portions of the Software.
|
|
2205 |
//
|
|
2206 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
2207 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2208 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
2209 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
2210 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2211 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2212 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2213 |
|
|
2214 |
'use strict';
|
|
2215 |
|
|
2216 |
// If obj.hasOwnProperty has been overridden, then calling
|
|
2217 |
// obj.hasOwnProperty(prop) will break.
|
|
2218 |
// See: https://github.com/joyent/node/issues/1707
|
|
2219 |
function hasOwnProperty(obj, prop) {
|
|
2220 |
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
2221 |
}
|
|
2222 |
|
|
2223 |
module.exports = function(qs, sep, eq, options) {
|
|
2224 |
sep = sep || '&';
|
|
2225 |
eq = eq || '=';
|
|
2226 |
var obj = {};
|
|
2227 |
|
|
2228 |
if (typeof qs !== 'string' || qs.length === 0) {
|
|
2229 |
return obj;
|
|
2230 |
}
|
|
2231 |
|
|
2232 |
var regexp = /\+/g;
|
|
2233 |
qs = qs.split(sep);
|
|
2234 |
|
|
2235 |
var maxKeys = 1000;
|
|
2236 |
if (options && typeof options.maxKeys === 'number') {
|
|
2237 |
maxKeys = options.maxKeys;
|
|
2238 |
}
|
|
2239 |
|
|
2240 |
var len = qs.length;
|
|
2241 |
// maxKeys <= 0 means that we should not limit keys count
|
|
2242 |
if (maxKeys > 0 && len > maxKeys) {
|
|
2243 |
len = maxKeys;
|
|
2244 |
}
|
|
2245 |
|
|
2246 |
for (var i = 0; i < len; ++i) {
|
|
2247 |
var x = qs[i].replace(regexp, '%20'),
|
|
2248 |
idx = x.indexOf(eq),
|
|
2249 |
kstr, vstr, k, v;
|
|
2250 |
|
|
2251 |
if (idx >= 0) {
|
|
2252 |
kstr = x.substr(0, idx);
|
|
2253 |
vstr = x.substr(idx + 1);
|
|
2254 |
} else {
|
|
2255 |
kstr = x;
|
|
2256 |
vstr = '';
|
|
2257 |
}
|
|
2258 |
|
|
2259 |
k = decodeURIComponent(kstr);
|
|
2260 |
v = decodeURIComponent(vstr);
|
|
2261 |
|
|
2262 |
if (!hasOwnProperty(obj, k)) {
|
|
2263 |
obj[k] = v;
|
|
2264 |
} else if (Array.isArray(obj[k])) {
|
|
2265 |
obj[k].push(v);
|
|
2266 |
} else {
|
|
2267 |
obj[k] = [obj[k], v];
|
|
2268 |
}
|
|
2269 |
}
|
|
2270 |
|
|
2271 |
return obj;
|
|
2272 |
};
|
|
2273 |
|
|
2274 |
|
|
2275 |
/***/ },
|
|
2276 |
/* 13 */
|
|
2277 |
/***/ function(module, exports) {
|
|
2278 |
|
|
2279 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
2280 |
//
|
|
2281 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
2282 |
// copy of this software and associated documentation files (the
|
|
2283 |
// "Software"), to deal in the Software without restriction, including
|
|
2284 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
2285 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
2286 |
// persons to whom the Software is furnished to do so, subject to the
|
|
2287 |
// following conditions:
|
|
2288 |
//
|
|
2289 |
// The above copyright notice and this permission notice shall be included
|
|
2290 |
// in all copies or substantial portions of the Software.
|
|
2291 |
//
|
|
2292 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
2293 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2294 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
2295 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
2296 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2297 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2298 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2299 |
|
|
2300 |
'use strict';
|
|
2301 |
|
|
2302 |
var stringifyPrimitive = function(v) {
|
|
2303 |
switch (typeof v) {
|
|
2304 |
case 'string':
|
|
2305 |
return v;
|
|
2306 |
|
|
2307 |
case 'boolean':
|
|
2308 |
return v ? 'true' : 'false';
|
|
2309 |
|
|
2310 |
case 'number':
|
|
2311 |
return isFinite(v) ? v : '';
|
|
2312 |
|
|
2313 |
default:
|
|
2314 |
return '';
|
|
2315 |
}
|
|
2316 |
};
|
|
2317 |
|
|
2318 |
module.exports = function(obj, sep, eq, name) {
|
|
2319 |
sep = sep || '&';
|
|
2320 |
eq = eq || '=';
|
|
2321 |
if (obj === null) {
|
|
2322 |
obj = undefined;
|
|
2323 |
}
|
|
2324 |
|
|
2325 |
if (typeof obj === 'object') {
|
|
2326 |
return Object.keys(obj).map(function(k) {
|
|
2327 |
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
|
2328 |
if (Array.isArray(obj[k])) {
|
|
2329 |
return obj[k].map(function(v) {
|
|
2330 |
return ks + encodeURIComponent(stringifyPrimitive(v));
|
|
2331 |
}).join(sep);
|
|
2332 |
} else {
|
|
2333 |
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
|
2334 |
}
|
|
2335 |
}).join(sep);
|
|
2336 |
|
|
2337 |
}
|
|
2338 |
|
|
2339 |
if (!name) return '';
|
|
2340 |
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
|
2341 |
encodeURIComponent(stringifyPrimitive(obj));
|
|
2342 |
};
|
|
2343 |
|
|
2344 |
|
|
2345 |
/***/ },
|
|
2346 |
/* 14 */
|
|
2347 |
/***/ function(module, exports) {
|
|
2348 |
|
|
2349 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
2350 |
//
|
|
2351 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
2352 |
// copy of this software and associated documentation files (the
|
|
2353 |
// "Software"), to deal in the Software without restriction, including
|
|
2354 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
2355 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
2356 |
// persons to whom the Software is furnished to do so, subject to the
|
|
2357 |
// following conditions:
|
|
2358 |
//
|
|
2359 |
// The above copyright notice and this permission notice shall be included
|
|
2360 |
// in all copies or substantial portions of the Software.
|
|
2361 |
//
|
|
2362 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
2363 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
2364 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
2365 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
2366 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
2367 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
2368 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2369 |
|
|
2370 |
function EventEmitter() {
|
|
2371 |
this._events = this._events || {};
|
|
2372 |
this._maxListeners = this._maxListeners || undefined;
|
|
2373 |
}
|
|
2374 |
module.exports = EventEmitter;
|
|
2375 |
|
|
2376 |
// Backwards-compat with node 0.10.x
|
|
2377 |
EventEmitter.EventEmitter = EventEmitter;
|
|
2378 |
|
|
2379 |
EventEmitter.prototype._events = undefined;
|
|
2380 |
EventEmitter.prototype._maxListeners = undefined;
|
|
2381 |
|
|
2382 |
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
2383 |
// added to it. This is a useful default which helps finding memory leaks.
|
|
2384 |
EventEmitter.defaultMaxListeners = 10;
|
|
2385 |
|
|
2386 |
// Obviously not all Emitters should be limited to 10. This function allows
|
|
2387 |
// that to be increased. Set to zero for unlimited.
|
|
2388 |
EventEmitter.prototype.setMaxListeners = function(n) {
|
|
2389 |
if (!isNumber(n) || n < 0 || isNaN(n))
|
|
2390 |
throw TypeError('n must be a positive number');
|
|
2391 |
this._maxListeners = n;
|
|
2392 |
return this;
|
|
2393 |
};
|
|
2394 |
|
|
2395 |
EventEmitter.prototype.emit = function(type) {
|
|
2396 |
var er, handler, len, args, i, listeners;
|
|
2397 |
|
|
2398 |
if (!this._events)
|
|
2399 |
this._events = {};
|
|
2400 |
|
|
2401 |
// If there is no 'error' event listener then throw.
|
|
2402 |
if (type === 'error') {
|
|
2403 |
if (!this._events.error ||
|
|
2404 |
(isObject(this._events.error) && !this._events.error.length)) {
|
|
2405 |
er = arguments[1];
|
|
2406 |
if (er instanceof Error) {
|
|
2407 |
throw er; // Unhandled 'error' event
|
|
2408 |
}
|
|
2409 |
throw TypeError('Uncaught, unspecified "error" event.');
|
|
2410 |
}
|
|
2411 |
}
|
|
2412 |
|
|
2413 |
handler = this._events[type];
|
|
2414 |
|
|
2415 |
if (isUndefined(handler))
|
|
2416 |
return false;
|
|
2417 |
|
|
2418 |
if (isFunction(handler)) {
|
|
2419 |
switch (arguments.length) {
|
|
2420 |
// fast cases
|
|
2421 |
case 1:
|
|
2422 |
handler.call(this);
|
|
2423 |
break;
|
|
2424 |
case 2:
|
|
2425 |
handler.call(this, arguments[1]);
|
|
2426 |
break;
|
|
2427 |
case 3:
|
|
2428 |
handler.call(this, arguments[1], arguments[2]);
|
|
2429 |
break;
|
|
2430 |
// slower
|
|
2431 |
default:
|
|
2432 |
args = Array.prototype.slice.call(arguments, 1);
|
|
2433 |
handler.apply(this, args);
|
|
2434 |
}
|
|
2435 |
} else if (isObject(handler)) {
|
|
2436 |
args = Array.prototype.slice.call(arguments, 1);
|
|
2437 |
listeners = handler.slice();
|
|
2438 |
len = listeners.length;
|
|
2439 |
for (i = 0; i < len; i++)
|
|
2440 |
listeners[i].apply(this, args);
|
|
2441 |
}
|
|
2442 |
|
|
2443 |
return true;
|
|
2444 |
};
|
|
2445 |
|
|
2446 |
EventEmitter.prototype.addListener = function(type, listener) {
|
|
2447 |
var m;
|
|
2448 |
|
|
2449 |
if (!isFunction(listener))
|
|
2450 |
throw TypeError('listener must be a function');
|
|
2451 |
|
|
2452 |
if (!this._events)
|
|
2453 |
this._events = {};
|
|
2454 |
|
|
2455 |
// To avoid recursion in the case that type === "newListener"! Before
|
|
2456 |
// adding it to the listeners, first emit "newListener".
|
|
2457 |
if (this._events.newListener)
|
|
2458 |
this.emit('newListener', type,
|
|
2459 |
isFunction(listener.listener) ?
|
|
2460 |
listener.listener : listener);
|
|
2461 |
|
|
2462 |
if (!this._events[type])
|
|
2463 |
// Optimize the case of one listener. Don't need the extra array object.
|
|
2464 |
this._events[type] = listener;
|
|
2465 |
else if (isObject(this._events[type]))
|
|
2466 |
// If we've already got an array, just append.
|
|
2467 |
this._events[type].push(listener);
|
|
2468 |
else
|
|
2469 |
// Adding the second element, need to change to array.
|
|
2470 |
this._events[type] = [this._events[type], listener];
|
|
2471 |
|
|
2472 |
// Check for listener leak
|
|
2473 |
if (isObject(this._events[type]) && !this._events[type].warned) {
|
|
2474 |
if (!isUndefined(this._maxListeners)) {
|
|
2475 |
m = this._maxListeners;
|
|
2476 |
} else {
|
|
2477 |
m = EventEmitter.defaultMaxListeners;
|
|
2478 |
}
|
|
2479 |
|
|
2480 |
if (m && m > 0 && this._events[type].length > m) {
|
|
2481 |
this._events[type].warned = true;
|
|
2482 |
console.error('(node) warning: possible EventEmitter memory ' +
|
|
2483 |
'leak detected. %d listeners added. ' +
|
|
2484 |
'Use emitter.setMaxListeners() to increase limit.',
|
|
2485 |
this._events[type].length);
|
|
2486 |
if (typeof console.trace === 'function') {
|
|
2487 |
// not supported in IE 10
|
|
2488 |
console.trace();
|
|
2489 |
}
|
|
2490 |
}
|
|
2491 |
}
|
|
2492 |
|
|
2493 |
return this;
|
|
2494 |
};
|
|
2495 |
|
|
2496 |
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
2497 |
|
|
2498 |
EventEmitter.prototype.once = function(type, listener) {
|
|
2499 |
if (!isFunction(listener))
|
|
2500 |
throw TypeError('listener must be a function');
|
|
2501 |
|
|
2502 |
var fired = false;
|
|
2503 |
|
|
2504 |
function g() {
|
|
2505 |
this.removeListener(type, g);
|
|
2506 |
|
|
2507 |
if (!fired) {
|
|
2508 |
fired = true;
|
|
2509 |
listener.apply(this, arguments);
|
|
2510 |
}
|
|
2511 |
}
|
|
2512 |
|
|
2513 |
g.listener = listener;
|
|
2514 |
this.on(type, g);
|
|
2515 |
|
|
2516 |
return this;
|
|
2517 |
};
|
|
2518 |
|
|
2519 |
// emits a 'removeListener' event iff the listener was removed
|
|
2520 |
EventEmitter.prototype.removeListener = function(type, listener) {
|
|
2521 |
var list, position, length, i;
|
|
2522 |
|
|
2523 |
if (!isFunction(listener))
|
|
2524 |
throw TypeError('listener must be a function');
|
|
2525 |
|
|
2526 |
if (!this._events || !this._events[type])
|
|
2527 |
return this;
|
|
2528 |
|
|
2529 |
list = this._events[type];
|
|
2530 |
length = list.length;
|
|
2531 |
position = -1;
|
|
2532 |
|
|
2533 |
if (list === listener ||
|
|
2534 |
(isFunction(list.listener) && list.listener === listener)) {
|
|
2535 |
delete this._events[type];
|
|
2536 |
if (this._events.removeListener)
|
|
2537 |
this.emit('removeListener', type, listener);
|
|
2538 |
|
|
2539 |
} else if (isObject(list)) {
|
|
2540 |
for (i = length; i-- > 0;) {
|
|
2541 |
if (list[i] === listener ||
|
|
2542 |
(list[i].listener && list[i].listener === listener)) {
|
|
2543 |
position = i;
|
|
2544 |
break;
|
|
2545 |
}
|
|
2546 |
}
|
|
2547 |
|
|
2548 |
if (position < 0)
|
|
2549 |
return this;
|
|
2550 |
|
|
2551 |
if (list.length === 1) {
|
|
2552 |
list.length = 0;
|
|
2553 |
delete this._events[type];
|
|
2554 |
} else {
|
|
2555 |
list.splice(position, 1);
|
|
2556 |
}
|
|
2557 |
|
|
2558 |
if (this._events.removeListener)
|
|
2559 |
this.emit('removeListener', type, listener);
|
|
2560 |
}
|
|
2561 |
|
|
2562 |
return this;
|
|
2563 |
};
|
|
2564 |
|
|
2565 |
EventEmitter.prototype.removeAllListeners = function(type) {
|
|
2566 |
var key, listeners;
|
|
2567 |
|
|
2568 |
if (!this._events)
|
|
2569 |
return this;
|
|
2570 |
|
|
2571 |
// not listening for removeListener, no need to emit
|
|
2572 |
if (!this._events.removeListener) {
|
|
2573 |
if (arguments.length === 0)
|
|
2574 |
this._events = {};
|
|
2575 |
else if (this._events[type])
|
|
2576 |
delete this._events[type];
|
|
2577 |
return this;
|
|
2578 |
}
|
|
2579 |
|
|
2580 |
// emit removeListener for all listeners on all events
|
|
2581 |
if (arguments.length === 0) {
|
|
2582 |
for (key in this._events) {
|
|
2583 |
if (key === 'removeListener') continue;
|
|
2584 |
this.removeAllListeners(key);
|
|
2585 |
}
|
|
2586 |
this.removeAllListeners('removeListener');
|
|
2587 |
this._events = {};
|
|
2588 |
return this;
|
|
2589 |
}
|
|
2590 |
|
|
2591 |
listeners = this._events[type];
|
|
2592 |
|
|
2593 |
if (isFunction(listeners)) {
|
|
2594 |
this.removeListener(type, listeners);
|
|
2595 |
} else if (listeners) {
|
|
2596 |
// LIFO order
|
|
2597 |
while (listeners.length)
|
|
2598 |
this.removeListener(type, listeners[listeners.length - 1]);
|
|
2599 |
}
|
|
2600 |
delete this._events[type];
|
|
2601 |
|
|
2602 |
return this;
|
|
2603 |
};
|
|
2604 |
|
|
2605 |
EventEmitter.prototype.listeners = function(type) {
|
|
2606 |
var ret;
|
|
2607 |
if (!this._events || !this._events[type])
|
|
2608 |
ret = [];
|
|
2609 |
else if (isFunction(this._events[type]))
|
|
2610 |
ret = [this._events[type]];
|
|
2611 |
else
|
|
2612 |
ret = this._events[type].slice();
|
|
2613 |
return ret;
|
|
2614 |
};
|
|
2615 |
|
|
2616 |
EventEmitter.prototype.listenerCount = function(type) {
|
|
2617 |
if (this._events) {
|
|
2618 |
var evlistener = this._events[type];
|
|
2619 |
|
|
2620 |
if (isFunction(evlistener))
|
|
2621 |
return 1;
|
|
2622 |
else if (evlistener)
|
|
2623 |
return evlistener.length;
|
|
2624 |
}
|
|
2625 |
return 0;
|
|
2626 |
};
|
|
2627 |
|
|
2628 |
EventEmitter.listenerCount = function(emitter, type) {
|
|
2629 |
return emitter.listenerCount(type);
|
|
2630 |
};
|
|
2631 |
|
|
2632 |
function isFunction(arg) {
|
|
2633 |
return typeof arg === 'function';
|
|
2634 |
}
|
|
2635 |
|
|
2636 |
function isNumber(arg) {
|
|
2637 |
return typeof arg === 'number';
|
|
2638 |
}
|
|
2639 |
|
|
2640 |
function isObject(arg) {
|
|
2641 |
return typeof arg === 'object' && arg !== null;
|
|
2642 |
}
|
|
2643 |
|
|
2644 |
function isUndefined(arg) {
|
|
2645 |
return arg === void 0;
|
|
2646 |
}
|
|
2647 |
|
|
2648 |
|
|
2649 |
/***/ },
|
|
2650 |
/* 15 */
|
|
2651 |
/***/ function(module, exports, __webpack_require__) {
|
|
2652 |
|
|
2653 |
var http = __webpack_require__(16);
|
|
2654 |
|
|
2655 |
var https = module.exports;
|
|
2656 |
|
|
2657 |
for (var key in http) {
|
|
2658 |
if (http.hasOwnProperty(key)) https[key] = http[key];
|
|
2659 |
};
|
|
2660 |
|
|
2661 |
https.request = function (params, cb) {
|
|
2662 |
if (!params) params = {};
|
|
2663 |
params.scheme = 'https';
|
|
2664 |
return http.request.call(this, params, cb);
|
|
2665 |
}
|
|
2666 |
|
|
2667 |
|
|
2668 |
/***/ },
|
|
2669 |
/* 16 */
|
|
2670 |
/***/ function(module, exports, __webpack_require__) {
|
|
2671 |
|
|
2672 |
var http = module.exports;
|
|
2673 |
var EventEmitter = __webpack_require__(14).EventEmitter;
|
|
2674 |
var Request = __webpack_require__(17);
|
|
2675 |
var url = __webpack_require__(8)
|
|
2676 |
|
|
2677 |
http.request = function (params, cb) {
|
|
2678 |
if (typeof params === 'string') {
|
|
2679 |
params = url.parse(params)
|
|
2680 |
}
|
|
2681 |
if (!params) params = {};
|
|
2682 |
if (!params.host && !params.port) {
|
|
2683 |
params.port = parseInt(window.location.port, 10);
|
|
2684 |
}
|
|
2685 |
if (!params.host && params.hostname) {
|
|
2686 |
params.host = params.hostname;
|
|
2687 |
}
|
|
2688 |
|
|
2689 |
if (!params.protocol) {
|
|
2690 |
if (params.scheme) {
|
|
2691 |
params.protocol = params.scheme + ':';
|
|
2692 |
} else {
|
|
2693 |
params.protocol = window.location.protocol;
|
|
2694 |
}
|
|
2695 |
}
|
|
2696 |
|
|
2697 |
if (!params.host) {
|
|
2698 |
params.host = window.location.hostname || window.location.host;
|
|
2699 |
}
|
|
2700 |
if (/:/.test(params.host)) {
|
|
2701 |
if (!params.port) {
|
|
2702 |
params.port = params.host.split(':')[1];
|
|
2703 |
}
|
|
2704 |
params.host = params.host.split(':')[0];
|
|
2705 |
}
|
|
2706 |
if (!params.port) params.port = params.protocol == 'https:' ? 443 : 80;
|
|
2707 |
|
|
2708 |
var req = new Request(new xhrHttp, params);
|
|
2709 |
if (cb) req.on('response', cb);
|
|
2710 |
return req;
|
|
2711 |
};
|
|
2712 |
|
|
2713 |
http.get = function (params, cb) {
|
|
2714 |
params.method = 'GET';
|
|
2715 |
var req = http.request(params, cb);
|
|
2716 |
req.end();
|
|
2717 |
return req;
|
|
2718 |
};
|
|
2719 |
|
|
2720 |
http.Agent = function () {};
|
|
2721 |
http.Agent.defaultMaxSockets = 4;
|
|
2722 |
|
|
2723 |
var xhrHttp = (function () {
|
|
2724 |
if (typeof window === 'undefined') {
|
|
2725 |
throw new Error('no window object present');
|
|
2726 |
}
|
|
2727 |
else if (window.XMLHttpRequest) {
|
|
2728 |
return window.XMLHttpRequest;
|
|
2729 |
}
|
|
2730 |
else if (window.ActiveXObject) {
|
|
2731 |
var axs = [
|
|
2732 |
'Msxml2.XMLHTTP.6.0',
|
|
2733 |
'Msxml2.XMLHTTP.3.0',
|
|
2734 |
'Microsoft.XMLHTTP'
|
|
2735 |
];
|
|
2736 |
for (var i = 0; i < axs.length; i++) {
|
|
2737 |
try {
|
|
2738 |
var ax = new(window.ActiveXObject)(axs[i]);
|
|
2739 |
return function () {
|
|
2740 |
if (ax) {
|
|
2741 |
var ax_ = ax;
|
|
2742 |
ax = null;
|
|
2743 |
return ax_;
|
|
2744 |
}
|
|
2745 |
else {
|
|
2746 |
return new(window.ActiveXObject)(axs[i]);
|
|
2747 |
}
|
|
2748 |
};
|
|
2749 |
}
|
|
2750 |
catch (e) {}
|
|
2751 |
}
|
|
2752 |
throw new Error('ajax not supported in this browser')
|
|
2753 |
}
|
|
2754 |
else {
|
|
2755 |
throw new Error('ajax not supported in this browser');
|
|
2756 |
}
|
|
2757 |
})();
|
|
2758 |
|
|
2759 |
http.STATUS_CODES = {
|
|
2760 |
100 : 'Continue',
|
|
2761 |
101 : 'Switching Protocols',
|
|
2762 |
102 : 'Processing', // RFC 2518, obsoleted by RFC 4918
|
|
2763 |
200 : 'OK',
|
|
2764 |
201 : 'Created',
|
|
2765 |
202 : 'Accepted',
|
|
2766 |
203 : 'Non-Authoritative Information',
|
|
2767 |
204 : 'No Content',
|
|
2768 |
205 : 'Reset Content',
|
|
2769 |
206 : 'Partial Content',
|
|
2770 |
207 : 'Multi-Status', // RFC 4918
|
|
2771 |
300 : 'Multiple Choices',
|
|
2772 |
301 : 'Moved Permanently',
|
|
2773 |
302 : 'Moved Temporarily',
|
|
2774 |
303 : 'See Other',
|
|
2775 |
304 : 'Not Modified',
|
|
2776 |
305 : 'Use Proxy',
|
|
2777 |
307 : 'Temporary Redirect',
|
|
2778 |
400 : 'Bad Request',
|
|
2779 |
401 : 'Unauthorized',
|
|
2780 |
402 : 'Payment Required',
|
|
2781 |
403 : 'Forbidden',
|
|
2782 |
404 : 'Not Found',
|
|
2783 |
405 : 'Method Not Allowed',
|
|
2784 |
406 : 'Not Acceptable',
|
|
2785 |
407 : 'Proxy Authentication Required',
|
|
2786 |
408 : 'Request Time-out',
|
|
2787 |
409 : 'Conflict',
|
|
2788 |
410 : 'Gone',
|
|
2789 |
411 : 'Length Required',
|
|
2790 |
412 : 'Precondition Failed',
|
|
2791 |
413 : 'Request Entity Too Large',
|
|
2792 |
414 : 'Request-URI Too Large',
|
|
2793 |
415 : 'Unsupported Media Type',
|
|
2794 |
416 : 'Requested Range Not Satisfiable',
|
|
2795 |
417 : 'Expectation Failed',
|
|
2796 |
418 : 'I\'m a teapot', // RFC 2324
|
|
2797 |
422 : 'Unprocessable Entity', // RFC 4918
|
|
2798 |
423 : 'Locked', // RFC 4918
|
|
2799 |
424 : 'Failed Dependency', // RFC 4918
|
|
2800 |
425 : 'Unordered Collection', // RFC 4918
|
|
2801 |
426 : 'Upgrade Required', // RFC 2817
|
|
2802 |
428 : 'Precondition Required', // RFC 6585
|
|
2803 |
429 : 'Too Many Requests', // RFC 6585
|
|
2804 |
431 : 'Request Header Fields Too Large',// RFC 6585
|
|
2805 |
500 : 'Internal Server Error',
|
|
2806 |
501 : 'Not Implemented',
|
|
2807 |
502 : 'Bad Gateway',
|
|
2808 |
503 : 'Service Unavailable',
|
|
2809 |
504 : 'Gateway Time-out',
|
|
2810 |
505 : 'HTTP Version Not Supported',
|
|
2811 |
506 : 'Variant Also Negotiates', // RFC 2295
|
|
2812 |
507 : 'Insufficient Storage', // RFC 4918
|
|
2813 |
509 : 'Bandwidth Limit Exceeded',
|
|
2814 |
510 : 'Not Extended', // RFC 2774
|
|
2815 |
511 : 'Network Authentication Required' // RFC 6585
|
|
2816 |
};
|
|
2817 |
|
|
2818 |
/***/ },
|
|
2819 |
/* 17 */
|
|
2820 |
/***/ function(module, exports, __webpack_require__) {
|
|
2821 |
|
|
2822 |
var Stream = __webpack_require__(18);
|
|
2823 |
var Response = __webpack_require__(38);
|
|
2824 |
var Base64 = __webpack_require__(41);
|
|
2825 |
var inherits = __webpack_require__(19);
|
|
2826 |
|
|
2827 |
var Request = module.exports = function (xhr, params) {
|
|
2828 |
var self = this;
|
|
2829 |
self.writable = true;
|
|
2830 |
self.xhr = xhr;
|
|
2831 |
self.body = [];
|
|
2832 |
|
|
2833 |
self.uri = (params.protocol || 'http:') + '//'
|
|
2834 |
+ params.host
|
|
2835 |
+ (params.port ? ':' + params.port : '')
|
|
2836 |
+ (params.path || '/')
|
|
2837 |
;
|
|
2838 |
|
|
2839 |
if (typeof params.withCredentials === 'undefined') {
|
|
2840 |
params.withCredentials = true;
|
|
2841 |
}
|
|
2842 |
|
|
2843 |
try { xhr.withCredentials = params.withCredentials }
|
|
2844 |
catch (e) {}
|
|
2845 |
|
|
2846 |
if (params.responseType) try { xhr.responseType = params.responseType }
|
|
2847 |
catch (e) {}
|
|
2848 |
|
|
2849 |
xhr.open(
|
|
2850 |
params.method || 'GET',
|
|
2851 |
self.uri,
|
|
2852 |
true
|
|
2853 |
);
|
|
2854 |
|
|
2855 |
xhr.onerror = function(event) {
|
|
2856 |
self.emit('error', new Error('Network error'));
|
|
2857 |
};
|
|
2858 |
|
|
2859 |
self._headers = {};
|
|
2860 |
|
|
2861 |
if (params.headers) {
|
|
2862 |
var keys = objectKeys(params.headers);
|
|
2863 |
for (var i = 0; i < keys.length; i++) {
|
|
2864 |
var key = keys[i];
|
|
2865 |
if (!self.isSafeRequestHeader(key)) continue;
|
|
2866 |
var value = params.headers[key];
|
|
2867 |
self.setHeader(key, value);
|
|
2868 |
}
|
|
2869 |
}
|
|
2870 |
|
|
2871 |
if (params.auth) {
|
|
2872 |
//basic auth
|
|
2873 |
this.setHeader('Authorization', 'Basic ' + Base64.btoa(params.auth));
|
|
2874 |
}
|
|
2875 |
|
|
2876 |
var res = new Response;
|
|
2877 |
res.on('close', function () {
|
|
2878 |
self.emit('close');
|
|
2879 |
});
|
|
2880 |
|
|
2881 |
res.on('ready', function () {
|
|
2882 |
self.emit('response', res);
|
|
2883 |
});
|
|
2884 |
|
|
2885 |
res.on('error', function (err) {
|
|
2886 |
self.emit('error', err);
|
|
2887 |
});
|
|
2888 |
|
|
2889 |
xhr.onreadystatechange = function () {
|
|
2890 |
// Fix for IE9 bug
|
|
2891 |
// SCRIPT575: Could not complete the operation due to error c00c023f
|
|
2892 |
// It happens when a request is aborted, calling the success callback anyway with readyState === 4
|
|
2893 |
if (xhr.__aborted) return;
|
|
2894 |
res.handle(xhr);
|
|
2895 |
};
|
|
2896 |
};
|
|
2897 |
|
|
2898 |
inherits(Request, Stream);
|
|
2899 |
|
|
2900 |
Request.prototype.setHeader = function (key, value) {
|
|
2901 |
this._headers[key.toLowerCase()] = value
|
|
2902 |
};
|
|
2903 |
|
|
2904 |
Request.prototype.getHeader = function (key) {
|
|
2905 |
return this._headers[key.toLowerCase()]
|
|
2906 |
};
|
|
2907 |
|
|
2908 |
Request.prototype.removeHeader = function (key) {
|
|
2909 |
delete this._headers[key.toLowerCase()]
|
|
2910 |
};
|
|
2911 |
|
|
2912 |
Request.prototype.write = function (s) {
|
|
2913 |
this.body.push(s);
|
|
2914 |
};
|
|
2915 |
|
|
2916 |
Request.prototype.destroy = function (s) {
|
|
2917 |
this.xhr.__aborted = true;
|
|
2918 |
this.xhr.abort();
|
|
2919 |
this.emit('close');
|
|
2920 |
};
|
|
2921 |
|
|
2922 |
Request.prototype.end = function (s) {
|
|
2923 |
if (s !== undefined) this.body.push(s);
|
|
2924 |
|
|
2925 |
var keys = objectKeys(this._headers);
|
|
2926 |
for (var i = 0; i < keys.length; i++) {
|
|
2927 |
var key = keys[i];
|
|
2928 |
var value = this._headers[key];
|
|
2929 |
if (isArray(value)) {
|
|
2930 |
for (var j = 0; j < value.length; j++) {
|
|
2931 |
this.xhr.setRequestHeader(key, value[j]);
|
|
2932 |
}
|
|
2933 |
}
|
|
2934 |
else this.xhr.setRequestHeader(key, value)
|
|
2935 |
}
|
|
2936 |
|
|
2937 |
if (this.body.length === 0) {
|
|
2938 |
this.xhr.send('');
|
|
2939 |
}
|
|
2940 |
else if (typeof this.body[0] === 'string') {
|
|
2941 |
this.xhr.send(this.body.join(''));
|
|
2942 |
}
|
|
2943 |
else if (isArray(this.body[0])) {
|
|
2944 |
var body = [];
|
|
2945 |
for (var i = 0; i < this.body.length; i++) {
|
|
2946 |
body.push.apply(body, this.body[i]);
|
|
2947 |
}
|
|
2948 |
this.xhr.send(body);
|
|
2949 |
}
|
|
2950 |
else if (/Array/.test(Object.prototype.toString.call(this.body[0]))) {
|
|
2951 |
var len = 0;
|
|
2952 |
for (var i = 0; i < this.body.length; i++) {
|
|
2953 |
len += this.body[i].length;
|
|
2954 |
}
|
|
2955 |
var body = new(this.body[0].constructor)(len);
|
|
2956 |
var k = 0;
|
|
2957 |
|
|
2958 |
for (var i = 0; i < this.body.length; i++) {
|
|
2959 |
var b = this.body[i];
|
|
2960 |
for (var j = 0; j < b.length; j++) {
|
|
2961 |
body[k++] = b[j];
|
|
2962 |
}
|
|
2963 |
}
|
|
2964 |
this.xhr.send(body);
|
|
2965 |
}
|
|
2966 |
else if (isXHR2Compatible(this.body[0])) {
|
|
2967 |
this.xhr.send(this.body[0]);
|
|
2968 |
}
|
|
2969 |
else {
|
|
2970 |
var body = '';
|
|
2971 |
for (var i = 0; i < this.body.length; i++) {
|
|
2972 |
body += this.body[i].toString();
|
|
2973 |
}
|
|
2974 |
this.xhr.send(body);
|
|
2975 |
}
|
|
2976 |
};
|
|
2977 |
|
|
2978 |
// Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html
|
|
2979 |
Request.unsafeHeaders = [
|
|
2980 |
"accept-charset",
|
|
2981 |
"accept-encoding",
|
|
2982 |
"access-control-request-headers",
|
|
2983 |
"access-control-request-method",
|
|
2984 |
"connection",
|
|
2985 |
"content-length",
|
|
2986 |
"cookie",
|
|
2987 |
"cookie2",
|
|
2988 |
"content-transfer-encoding",
|
|
2989 |
"date",
|
|
2990 |
"expect",
|
|
2991 |
"host",
|
|
2992 |
"keep-alive",
|
|
2993 |
"origin",
|
|
2994 |
"referer",
|
|
2995 |
"te",
|
|
2996 |
"trailer",
|
|
2997 |
"transfer-encoding",
|
|
2998 |
"upgrade",
|
|
2999 |
"user-agent",
|
|
3000 |
"via"
|
|
3001 |
];
|
|
3002 |
|
|
3003 |
Request.prototype.isSafeRequestHeader = function (headerName) {
|
|
3004 |
if (!headerName) return false;
|
|
3005 |
return indexOf(Request.unsafeHeaders, headerName.toLowerCase()) === -1;
|
|
3006 |
};
|
|
3007 |
|
|
3008 |
var objectKeys = Object.keys || function (obj) {
|
|
3009 |
var keys = [];
|
|
3010 |
for (var key in obj) keys.push(key);
|
|
3011 |
return keys;
|
|
3012 |
};
|
|
3013 |
|
|
3014 |
var isArray = Array.isArray || function (xs) {
|
|
3015 |
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
3016 |
};
|
|
3017 |
|
|
3018 |
var indexOf = function (xs, x) {
|
|
3019 |
if (xs.indexOf) return xs.indexOf(x);
|
|
3020 |
for (var i = 0; i < xs.length; i++) {
|
|
3021 |
if (xs[i] === x) return i;
|
|
3022 |
}
|
|
3023 |
return -1;
|
|
3024 |
};
|
|
3025 |
|
|
3026 |
var isXHR2Compatible = function (obj) {
|
|
3027 |
if (typeof Blob !== 'undefined' && obj instanceof Blob) return true;
|
|
3028 |
if (typeof ArrayBuffer !== 'undefined' && obj instanceof ArrayBuffer) return true;
|
|
3029 |
if (typeof FormData !== 'undefined' && obj instanceof FormData) return true;
|
|
3030 |
};
|
|
3031 |
|
|
3032 |
|
|
3033 |
/***/ },
|
|
3034 |
/* 18 */
|
|
3035 |
/***/ function(module, exports, __webpack_require__) {
|
|
3036 |
|
|
3037 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
3038 |
//
|
|
3039 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
3040 |
// copy of this software and associated documentation files (the
|
|
3041 |
// "Software"), to deal in the Software without restriction, including
|
|
3042 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
3043 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
3044 |
// persons to whom the Software is furnished to do so, subject to the
|
|
3045 |
// following conditions:
|
|
3046 |
//
|
|
3047 |
// The above copyright notice and this permission notice shall be included
|
|
3048 |
// in all copies or substantial portions of the Software.
|
|
3049 |
//
|
|
3050 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
3051 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
3052 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
3053 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
3054 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
3055 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
3056 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3057 |
|
|
3058 |
module.exports = Stream;
|
|
3059 |
|
|
3060 |
var EE = __webpack_require__(14).EventEmitter;
|
|
3061 |
var inherits = __webpack_require__(19);
|
|
3062 |
|
|
3063 |
inherits(Stream, EE);
|
|
3064 |
Stream.Readable = __webpack_require__(20);
|
|
3065 |
Stream.Writable = __webpack_require__(34);
|
|
3066 |
Stream.Duplex = __webpack_require__(35);
|
|
3067 |
Stream.Transform = __webpack_require__(36);
|
|
3068 |
Stream.PassThrough = __webpack_require__(37);
|
|
3069 |
|
|
3070 |
// Backwards-compat with node 0.4.x
|
|
3071 |
Stream.Stream = Stream;
|
|
3072 |
|
|
3073 |
|
|
3074 |
|
|
3075 |
// old-style streams. Note that the pipe method (the only relevant
|
|
3076 |
// part of this class) is overridden in the Readable class.
|
|
3077 |
|
|
3078 |
function Stream() {
|
|
3079 |
EE.call(this);
|
|
3080 |
}
|
|
3081 |
|
|
3082 |
Stream.prototype.pipe = function(dest, options) {
|
|
3083 |
var source = this;
|
|
3084 |
|
|
3085 |
function ondata(chunk) {
|
|
3086 |
if (dest.writable) {
|
|
3087 |
if (false === dest.write(chunk) && source.pause) {
|
|
3088 |
source.pause();
|
|
3089 |
}
|
|
3090 |
}
|
|
3091 |
}
|
|
3092 |
|
|
3093 |
source.on('data', ondata);
|
|
3094 |
|
|
3095 |
function ondrain() {
|
|
3096 |
if (source.readable && source.resume) {
|
|
3097 |
source.resume();
|
|
3098 |
}
|
|
3099 |
}
|
|
3100 |
|
|
3101 |
dest.on('drain', ondrain);
|
|
3102 |
|
|
3103 |
// If the 'end' option is not supplied, dest.end() will be called when
|
|
3104 |
// source gets the 'end' or 'close' events. Only dest.end() once.
|
|
3105 |
if (!dest._isStdio && (!options || options.end !== false)) {
|
|
3106 |
source.on('end', onend);
|
|
3107 |
source.on('close', onclose);
|
|
3108 |
}
|
|
3109 |
|
|
3110 |
var didOnEnd = false;
|
|
3111 |
function onend() {
|
|
3112 |
if (didOnEnd) return;
|
|
3113 |
didOnEnd = true;
|
|
3114 |
|
|
3115 |
dest.end();
|
|
3116 |
}
|
|
3117 |
|
|
3118 |
|
|
3119 |
function onclose() {
|
|
3120 |
if (didOnEnd) return;
|
|
3121 |
didOnEnd = true;
|
|
3122 |
|
|
3123 |
if (typeof dest.destroy === 'function') dest.destroy();
|
|
3124 |
}
|
|
3125 |
|
|
3126 |
// don't leave dangling pipes when there are errors.
|
|
3127 |
function onerror(er) {
|
|
3128 |
cleanup();
|
|
3129 |
if (EE.listenerCount(this, 'error') === 0) {
|
|
3130 |
throw er; // Unhandled stream error in pipe.
|
|
3131 |
}
|
|
3132 |
}
|
|
3133 |
|
|
3134 |
source.on('error', onerror);
|
|
3135 |
dest.on('error', onerror);
|
|
3136 |
|
|
3137 |
// remove all the event listeners that were added.
|
|
3138 |
function cleanup() {
|
|
3139 |
source.removeListener('data', ondata);
|
|
3140 |
dest.removeListener('drain', ondrain);
|
|
3141 |
|
|
3142 |
source.removeListener('end', onend);
|
|
3143 |
source.removeListener('close', onclose);
|
|
3144 |
|
|
3145 |
source.removeListener('error', onerror);
|
|
3146 |
dest.removeListener('error', onerror);
|
|
3147 |
|
|
3148 |
source.removeListener('end', cleanup);
|
|
3149 |
source.removeListener('close', cleanup);
|
|
3150 |
|
|
3151 |
dest.removeListener('close', cleanup);
|
|
3152 |
}
|
|
3153 |
|
|
3154 |
source.on('end', cleanup);
|
|
3155 |
source.on('close', cleanup);
|
|
3156 |
|
|
3157 |
dest.on('close', cleanup);
|
|
3158 |
|
|
3159 |
dest.emit('pipe', source);
|
|
3160 |
|
|
3161 |
// Allow for unix-like usage: A.pipe(B).pipe(C)
|
|
3162 |
return dest;
|
|
3163 |
};
|
|
3164 |
|
|
3165 |
|
|
3166 |
/***/ },
|
|
3167 |
/* 19 */
|
|
3168 |
/***/ function(module, exports) {
|
|
3169 |
|
|
3170 |
if (typeof Object.create === 'function') {
|
|
3171 |
// implementation from standard node.js 'util' module
|
|
3172 |
module.exports = function inherits(ctor, superCtor) {
|
|
3173 |
ctor.super_ = superCtor
|
|
3174 |
ctor.prototype = Object.create(superCtor.prototype, {
|
|
3175 |
constructor: {
|
|
3176 |
value: ctor,
|
|
3177 |
enumerable: false,
|
|
3178 |
writable: true,
|
|
3179 |
configurable: true
|
|
3180 |
}
|
|
3181 |
});
|
|
3182 |
};
|
|
3183 |
} else {
|
|
3184 |
// old school shim for old browsers
|
|
3185 |
module.exports = function inherits(ctor, superCtor) {
|
|
3186 |
ctor.super_ = superCtor
|
|
3187 |
var TempCtor = function () {}
|
|
3188 |
TempCtor.prototype = superCtor.prototype
|
|
3189 |
ctor.prototype = new TempCtor()
|
|
3190 |
ctor.prototype.constructor = ctor
|
|
3191 |
}
|
|
3192 |
}
|
|
3193 |
|
|
3194 |
|
|
3195 |
/***/ },
|
|
3196 |
/* 20 */
|
|
3197 |
/***/ function(module, exports, __webpack_require__) {
|
|
3198 |
|
|
3199 |
exports = module.exports = __webpack_require__(21);
|
|
3200 |
exports.Stream = __webpack_require__(18);
|
|
3201 |
exports.Readable = exports;
|
|
3202 |
exports.Writable = __webpack_require__(30);
|
|
3203 |
exports.Duplex = __webpack_require__(29);
|
|
3204 |
exports.Transform = __webpack_require__(32);
|
|
3205 |
exports.PassThrough = __webpack_require__(33);
|
|
3206 |
|
|
3207 |
|
|
3208 |
/***/ },
|
|
3209 |
/* 21 */
|
|
3210 |
/***/ function(module, exports, __webpack_require__) {
|
|
3211 |
|
|
3212 |
/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
|
|
3213 |
//
|
|
3214 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
3215 |
// copy of this software and associated documentation files (the
|
|
3216 |
// "Software"), to deal in the Software without restriction, including
|
|
3217 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
3218 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
3219 |
// persons to whom the Software is furnished to do so, subject to the
|
|
3220 |
// following conditions:
|
|
3221 |
//
|
|
3222 |
// The above copyright notice and this permission notice shall be included
|
|
3223 |
// in all copies or substantial portions of the Software.
|
|
3224 |
//
|
|
3225 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
3226 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
3227 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
3228 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
3229 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
3230 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
3231 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3232 |
|
|
3233 |
module.exports = Readable;
|
|
3234 |
|
|
3235 |
/*<replacement>*/
|
|
3236 |
var isArray = __webpack_require__(22);
|
|
3237 |
/*</replacement>*/
|
|
3238 |
|
|
3239 |
|
|
3240 |
/*<replacement>*/
|
|
3241 |
var Buffer = __webpack_require__(23).Buffer;
|
|
3242 |
/*</replacement>*/
|
|
3243 |
|
|
3244 |
Readable.ReadableState = ReadableState;
|
|
3245 |
|
|
3246 |
var EE = __webpack_require__(14).EventEmitter;
|
|
3247 |
|
|
3248 |
/*<replacement>*/
|
|
3249 |
if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
|
|
3250 |
return emitter.listeners(type).length;
|
|
3251 |
};
|
|
3252 |
/*</replacement>*/
|
|
3253 |
|
|
3254 |
var Stream = __webpack_require__(18);
|
|
3255 |
|
|
3256 |
/*<replacement>*/
|
|
3257 |
var util = __webpack_require__(27);
|
|
3258 |
util.inherits = __webpack_require__(19);
|
|
3259 |
/*</replacement>*/
|
|
3260 |
|
|
3261 |
var StringDecoder;
|
|
3262 |
|
|
3263 |
|
|
3264 |
/*<replacement>*/
|
|
3265 |
var debug = __webpack_require__(28);
|
|
3266 |
if (debug && debug.debuglog) {
|
|
3267 |
debug = debug.debuglog('stream');
|
|
3268 |
} else {
|
|
3269 |
debug = function () {};
|
|
3270 |
}
|
|
3271 |
/*</replacement>*/
|
|
3272 |
|
|
3273 |
|
|
3274 |
util.inherits(Readable, Stream);
|
|
3275 |
|
|
3276 |
function ReadableState(options, stream) {
|
|
3277 |
var Duplex = __webpack_require__(29);
|
|
3278 |
|
|
3279 |
options = options || {};
|
|
3280 |
|
|
3281 |
// the point at which it stops calling _read() to fill the buffer
|
|
3282 |
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
|
3283 |
var hwm = options.highWaterMark;
|
|
3284 |
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
|
3285 |
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
|
3286 |
|
|
3287 |
// cast to ints.
|
|
3288 |
this.highWaterMark = ~~this.highWaterMark;
|
|
3289 |
|
|
3290 |
this.buffer = [];
|
|
3291 |
this.length = 0;
|
|
3292 |
this.pipes = null;
|
|
3293 |
this.pipesCount = 0;
|
|
3294 |
this.flowing = null;
|
|
3295 |
this.ended = false;
|
|
3296 |
this.endEmitted = false;
|
|
3297 |
this.reading = false;
|
|
3298 |
|
|
3299 |
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
3300 |
// or on a later tick. We set this to true at first, because any
|
|
3301 |
// actions that shouldn't happen until "later" should generally also
|
|
3302 |
// not happen before the first write call.
|
|
3303 |
this.sync = true;
|
|
3304 |
|
|
3305 |
// whenever we return null, then we set a flag to say
|
|
3306 |
// that we're awaiting a 'readable' event emission.
|
|
3307 |
this.needReadable = false;
|
|
3308 |
this.emittedReadable = false;
|
|
3309 |
this.readableListening = false;
|
|
3310 |
|
|
3311 |
|
|
3312 |
// object stream flag. Used to make read(n) ignore n and to
|
|
3313 |
// make all the buffer merging and length checks go away
|
|
3314 |
this.objectMode = !!options.objectMode;
|
|
3315 |
|
|
3316 |
if (stream instanceof Duplex)
|
|
3317 |
this.objectMode = this.objectMode || !!options.readableObjectMode;
|
|
3318 |
|
|
3319 |
// Crypto is kind of old and crusty. Historically, its default string
|
|
3320 |
// encoding is 'binary' so we have to make this configurable.
|
|
3321 |
// Everything else in the universe uses 'utf8', though.
|
|
3322 |
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
3323 |
|
|
3324 |
// when piping, we only care about 'readable' events that happen
|
|
3325 |
// after read()ing all the bytes and not getting any pushback.
|
|
3326 |
this.ranOut = false;
|
|
3327 |
|
|
3328 |
// the number of writers that are awaiting a drain event in .pipe()s
|
|
3329 |
this.awaitDrain = 0;
|
|
3330 |
|
|
3331 |
// if true, a maybeReadMore has been scheduled
|
|
3332 |
this.readingMore = false;
|
|
3333 |
|
|
3334 |
this.decoder = null;
|
|
3335 |
this.encoding = null;
|
|
3336 |
if (options.encoding) {
|
|
3337 |
if (!StringDecoder)
|
|
3338 |
StringDecoder = __webpack_require__(31).StringDecoder;
|
|
3339 |
this.decoder = new StringDecoder(options.encoding);
|
|
3340 |
this.encoding = options.encoding;
|
|
3341 |
}
|
|
3342 |
}
|
|
3343 |
|
|
3344 |
function Readable(options) {
|
|
3345 |
var Duplex = __webpack_require__(29);
|
|
3346 |
|
|
3347 |
if (!(this instanceof Readable))
|
|
3348 |
return new Readable(options);
|
|
3349 |
|
|
3350 |
this._readableState = new ReadableState(options, this);
|
|
3351 |
|
|
3352 |
// legacy
|
|
3353 |
this.readable = true;
|
|
3354 |
|
|
3355 |
Stream.call(this);
|
|
3356 |
}
|
|
3357 |
|
|
3358 |
// Manually shove something into the read() buffer.
|
|
3359 |
// This returns true if the highWaterMark has not been hit yet,
|
|
3360 |
// similar to how Writable.write() returns true if you should
|
|
3361 |
// write() some more.
|
|
3362 |
Readable.prototype.push = function(chunk, encoding) {
|
|
3363 |
var state = this._readableState;
|
|
3364 |
|
|
3365 |
if (util.isString(chunk) && !state.objectMode) {
|
|
3366 |
encoding = encoding || state.defaultEncoding;
|
|
3367 |
if (encoding !== state.encoding) {
|
|
3368 |
chunk = new Buffer(chunk, encoding);
|
|
3369 |
encoding = '';
|
|
3370 |
}
|
|
3371 |
}
|
|
3372 |
|
|
3373 |
return readableAddChunk(this, state, chunk, encoding, false);
|
|
3374 |
};
|
|
3375 |
|
|
3376 |
// Unshift should *always* be something directly out of read()
|
|
3377 |
Readable.prototype.unshift = function(chunk) {
|
|
3378 |
var state = this._readableState;
|
|
3379 |
return readableAddChunk(this, state, chunk, '', true);
|
|
3380 |
};
|
|
3381 |
|
|
3382 |
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
|
3383 |
var er = chunkInvalid(state, chunk);
|
|
3384 |
if (er) {
|
|
3385 |
stream.emit('error', er);
|
|
3386 |
} else if (util.isNullOrUndefined(chunk)) {
|
|
3387 |
state.reading = false;
|
|
3388 |
if (!state.ended)
|
|
3389 |
onEofChunk(stream, state);
|
|
3390 |
} else if (state.objectMode || chunk && chunk.length > 0) {
|
|
3391 |
if (state.ended && !addToFront) {
|
|
3392 |
var e = new Error('stream.push() after EOF');
|
|
3393 |
stream.emit('error', e);
|
|
3394 |
} else if (state.endEmitted && addToFront) {
|
|
3395 |
var e = new Error('stream.unshift() after end event');
|
|
3396 |
stream.emit('error', e);
|
|
3397 |
} else {
|
|
3398 |
if (state.decoder && !addToFront && !encoding)
|
|
3399 |
chunk = state.decoder.write(chunk);
|
|
3400 |
|
|
3401 |
if (!addToFront)
|
|
3402 |
state.reading = false;
|
|
3403 |
|
|
3404 |
// if we want the data now, just emit it.
|
|
3405 |
if (state.flowing && state.length === 0 && !state.sync) {
|
|
3406 |
stream.emit('data', chunk);
|
|
3407 |
stream.read(0);
|
|
3408 |
} else {
|
|
3409 |
// update the buffer info.
|
|
3410 |
state.length += state.objectMode ? 1 : chunk.length;
|
|
3411 |
if (addToFront)
|
|
3412 |
state.buffer.unshift(chunk);
|
|
3413 |
else
|
|
3414 |
state.buffer.push(chunk);
|
|
3415 |
|
|
3416 |
if (state.needReadable)
|
|
3417 |
emitReadable(stream);
|
|
3418 |
}
|
|
3419 |
|
|
3420 |
maybeReadMore(stream, state);
|
|
3421 |
}
|
|
3422 |
} else if (!addToFront) {
|
|
3423 |
state.reading = false;
|
|
3424 |
}
|
|
3425 |
|
|
3426 |
return needMoreData(state);
|
|
3427 |
}
|
|
3428 |
|
|
3429 |
|
|
3430 |
|
|
3431 |
// if it's past the high water mark, we can push in some more.
|
|
3432 |
// Also, if we have no data yet, we can stand some
|
|
3433 |
// more bytes. This is to work around cases where hwm=0,
|
|
3434 |
// such as the repl. Also, if the push() triggered a
|
|
3435 |
// readable event, and the user called read(largeNumber) such that
|
|
3436 |
// needReadable was set, then we ought to push more, so that another
|
|
3437 |
// 'readable' event will be triggered.
|
|
3438 |
function needMoreData(state) {
|
|
3439 |
return !state.ended &&
|
|
3440 |
(state.needReadable ||
|
|
3441 |
state.length < state.highWaterMark ||
|
|
3442 |
state.length === 0);
|
|
3443 |
}
|
|
3444 |
|
|
3445 |
// backwards compatibility.
|
|
3446 |
Readable.prototype.setEncoding = function(enc) {
|
|
3447 |
if (!StringDecoder)
|
|
3448 |
StringDecoder = __webpack_require__(31).StringDecoder;
|
|
3449 |
this._readableState.decoder = new StringDecoder(enc);
|
|
3450 |
this._readableState.encoding = enc;
|
|
3451 |
return this;
|
|
3452 |
};
|
|
3453 |
|
|
3454 |
// Don't raise the hwm > 128MB
|
|
3455 |
var MAX_HWM = 0x800000;
|
|
3456 |
function roundUpToNextPowerOf2(n) {
|
|
3457 |
if (n >= MAX_HWM) {
|
|
3458 |
n = MAX_HWM;
|
|
3459 |
} else {
|
|
3460 |
// Get the next highest power of 2
|
|
3461 |
n--;
|
|
3462 |
for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
|
3463 |
n++;
|
|
3464 |
}
|
|
3465 |
return n;
|
|
3466 |
}
|
|
3467 |
|
|
3468 |
function howMuchToRead(n, state) {
|
|
3469 |
if (state.length === 0 && state.ended)
|
|
3470 |
return 0;
|
|
3471 |
|
|
3472 |
if (state.objectMode)
|
|
3473 |
return n === 0 ? 0 : 1;
|
|
3474 |
|
|
3475 |
if (isNaN(n) || util.isNull(n)) {
|
|
3476 |
// only flow one buffer at a time
|
|
3477 |
if (state.flowing && state.buffer.length)
|
|
3478 |
return state.buffer[0].length;
|
|
3479 |
else
|
|
3480 |
return state.length;
|
|
3481 |
}
|
|
3482 |
|
|
3483 |
if (n <= 0)
|
|
3484 |
return 0;
|
|
3485 |
|
|
3486 |
// If we're asking for more than the target buffer level,
|
|
3487 |
// then raise the water mark. Bump up to the next highest
|
|
3488 |
// power of 2, to prevent increasing it excessively in tiny
|
|
3489 |
// amounts.
|
|
3490 |
if (n > state.highWaterMark)
|
|
3491 |
state.highWaterMark = roundUpToNextPowerOf2(n);
|
|
3492 |
|
|
3493 |
// don't have that much. return null, unless we've ended.
|
|
3494 |
if (n > state.length) {
|
|
3495 |
if (!state.ended) {
|
|
3496 |
state.needReadable = true;
|
|
3497 |
return 0;
|
|
3498 |
} else
|
|
3499 |
return state.length;
|
|
3500 |
}
|
|
3501 |
|
|
3502 |
return n;
|
|
3503 |
}
|
|
3504 |
|
|
3505 |
// you can override either this method, or the async _read(n) below.
|
|
3506 |
Readable.prototype.read = function(n) {
|
|
3507 |
debug('read', n);
|
|
3508 |
var state = this._readableState;
|
|
3509 |
var nOrig = n;
|
|
3510 |
|
|
3511 |
if (!util.isNumber(n) || n > 0)
|
|
3512 |
state.emittedReadable = false;
|
|
3513 |
|
|
3514 |
// if we're doing read(0) to trigger a readable event, but we
|
|
3515 |
// already have a bunch of data in the buffer, then just trigger
|
|
3516 |
// the 'readable' event and move on.
|
|
3517 |
if (n === 0 &&
|
|
3518 |
state.needReadable &&
|
|
3519 |
(state.length >= state.highWaterMark || state.ended)) {
|
|
3520 |
debug('read: emitReadable', state.length, state.ended);
|
|
3521 |
if (state.length === 0 && state.ended)
|
|
3522 |
endReadable(this);
|
|
3523 |
else
|
|
3524 |
emitReadable(this);
|
|
3525 |
return null;
|
|
3526 |
}
|
|
3527 |
|
|
3528 |
n = howMuchToRead(n, state);
|
|
3529 |
|
|
3530 |
// if we've ended, and we're now clear, then finish it up.
|
|
3531 |
if (n === 0 && state.ended) {
|
|
3532 |
if (state.length === 0)
|
|
3533 |
endReadable(this);
|
|
3534 |
return null;
|
|
3535 |
}
|
|
3536 |
|
|
3537 |
// All the actual chunk generation logic needs to be
|
|
3538 |
// *below* the call to _read. The reason is that in certain
|
|
3539 |
// synthetic stream cases, such as passthrough streams, _read
|
|
3540 |
// may be a completely synchronous operation which may change
|
|
3541 |
// the state of the read buffer, providing enough data when
|
|
3542 |
// before there was *not* enough.
|
|
3543 |
//
|
|
3544 |
// So, the steps are:
|
|
3545 |
// 1. Figure out what the state of things will be after we do
|
|
3546 |
// a read from the buffer.
|
|
3547 |
//
|
|
3548 |
// 2. If that resulting state will trigger a _read, then call _read.
|
|
3549 |
// Note that this may be asynchronous, or synchronous. Yes, it is
|
|
3550 |
// deeply ugly to write APIs this way, but that still doesn't mean
|
|
3551 |
// that the Readable class should behave improperly, as streams are
|
|
3552 |
// designed to be sync/async agnostic.
|
|
3553 |
// Take note if the _read call is sync or async (ie, if the read call
|
|
3554 |
// has returned yet), so that we know whether or not it's safe to emit
|
|
3555 |
// 'readable' etc.
|
|
3556 |
//
|
|
3557 |
// 3. Actually pull the requested chunks out of the buffer and return.
|
|
3558 |
|
|
3559 |
// if we need a readable event, then we need to do some reading.
|
|
3560 |
var doRead = state.needReadable;
|
|
3561 |
debug('need readable', doRead);
|
|
3562 |
|
|
3563 |
// if we currently have less than the highWaterMark, then also read some
|
|
3564 |
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
|
3565 |
doRead = true;
|
|
3566 |
debug('length less than watermark', doRead);
|
|
3567 |
}
|
|
3568 |
|
|
3569 |
// however, if we've ended, then there's no point, and if we're already
|
|
3570 |
// reading, then it's unnecessary.
|
|
3571 |
if (state.ended || state.reading) {
|
|
3572 |
doRead = false;
|
|
3573 |
debug('reading or ended', doRead);
|
|
3574 |
}
|
|
3575 |
|
|
3576 |
if (doRead) {
|
|
3577 |
debug('do read');
|
|
3578 |
state.reading = true;
|
|
3579 |
state.sync = true;
|
|
3580 |
// if the length is currently zero, then we *need* a readable event.
|
|
3581 |
if (state.length === 0)
|
|
3582 |
state.needReadable = true;
|
|
3583 |
// call internal read method
|
|
3584 |
this._read(state.highWaterMark);
|
|
3585 |
state.sync = false;
|
|
3586 |
}
|
|
3587 |
|
|
3588 |
// If _read pushed data synchronously, then `reading` will be false,
|
|
3589 |
// and we need to re-evaluate how much data we can return to the user.
|
|
3590 |
if (doRead && !state.reading)
|
|
3591 |
n = howMuchToRead(nOrig, state);
|
|
3592 |
|
|
3593 |
var ret;
|
|
3594 |
if (n > 0)
|
|
3595 |
ret = fromList(n, state);
|
|
3596 |
else
|
|
3597 |
ret = null;
|
|
3598 |
|
|
3599 |
if (util.isNull(ret)) {
|
|
3600 |
state.needReadable = true;
|
|
3601 |
n = 0;
|
|
3602 |
}
|
|
3603 |
|
|
3604 |
state.length -= n;
|
|
3605 |
|
|
3606 |
// If we have nothing in the buffer, then we want to know
|
|
3607 |
// as soon as we *do* get something into the buffer.
|
|
3608 |
if (state.length === 0 && !state.ended)
|
|
3609 |
state.needReadable = true;
|
|
3610 |
|
|
3611 |
// If we tried to read() past the EOF, then emit end on the next tick.
|
|
3612 |
if (nOrig !== n && state.ended && state.length === 0)
|
|
3613 |
endReadable(this);
|
|
3614 |
|
|
3615 |
if (!util.isNull(ret))
|
|
3616 |
this.emit('data', ret);
|
|
3617 |
|
|
3618 |
return ret;
|
|
3619 |
};
|
|
3620 |
|
|
3621 |
function chunkInvalid(state, chunk) {
|
|
3622 |
var er = null;
|
|
3623 |
if (!util.isBuffer(chunk) &&
|
|
3624 |
!util.isString(chunk) &&
|
|
3625 |
!util.isNullOrUndefined(chunk) &&
|
|
3626 |
!state.objectMode) {
|
|
3627 |
er = new TypeError('Invalid non-string/buffer chunk');
|
|
3628 |
}
|
|
3629 |
return er;
|
|
3630 |
}
|
|
3631 |
|
|
3632 |
|
|
3633 |
function onEofChunk(stream, state) {
|
|
3634 |
if (state.decoder && !state.ended) {
|
|
3635 |
var chunk = state.decoder.end();
|
|
3636 |
if (chunk && chunk.length) {
|
|
3637 |
state.buffer.push(chunk);
|
|
3638 |
state.length += state.objectMode ? 1 : chunk.length;
|
|
3639 |
}
|
|
3640 |
}
|
|
3641 |
state.ended = true;
|
|
3642 |
|
|
3643 |
// emit 'readable' now to make sure it gets picked up.
|
|
3644 |
emitReadable(stream);
|
|
3645 |
}
|
|
3646 |
|
|
3647 |
// Don't emit readable right away in sync mode, because this can trigger
|
|
3648 |
// another read() call => stack overflow. This way, it might trigger
|
|
3649 |
// a nextTick recursion warning, but that's not so bad.
|
|
3650 |
function emitReadable(stream) {
|
|
3651 |
var state = stream._readableState;
|
|
3652 |
state.needReadable = false;
|
|
3653 |
if (!state.emittedReadable) {
|
|
3654 |
debug('emitReadable', state.flowing);
|
|
3655 |
state.emittedReadable = true;
|
|
3656 |
if (state.sync)
|
|
3657 |
process.nextTick(function() {
|
|
3658 |
emitReadable_(stream);
|
|
3659 |
});
|
|
3660 |
else
|
|
3661 |
emitReadable_(stream);
|
|
3662 |
}
|
|
3663 |
}
|
|
3664 |
|
|
3665 |
function emitReadable_(stream) {
|
|
3666 |
debug('emit readable');
|
|
3667 |
stream.emit('readable');
|
|
3668 |
flow(stream);
|
|
3669 |
}
|
|
3670 |
|
|
3671 |
|
|
3672 |
// at this point, the user has presumably seen the 'readable' event,
|
|
3673 |
// and called read() to consume some data. that may have triggered
|
|
3674 |
// in turn another _read(n) call, in which case reading = true if
|
|
3675 |
// it's in progress.
|
|
3676 |
// However, if we're not ended, or reading, and the length < hwm,
|
|
3677 |
// then go ahead and try to read some more preemptively.
|
|
3678 |
function maybeReadMore(stream, state) {
|
|
3679 |
if (!state.readingMore) {
|
|
3680 |
state.readingMore = true;
|
|
3681 |
process.nextTick(function() {
|
|
3682 |
maybeReadMore_(stream, state);
|
|
3683 |
});
|
|
3684 |
}
|
|
3685 |
}
|
|
3686 |
|
|
3687 |
function maybeReadMore_(stream, state) {
|
|
3688 |
var len = state.length;
|
|
3689 |
while (!state.reading && !state.flowing && !state.ended &&
|
|
3690 |
state.length < state.highWaterMark) {
|
|
3691 |
debug('maybeReadMore read 0');
|
|
3692 |
stream.read(0);
|
|
3693 |
if (len === state.length)
|
|
3694 |
// didn't get any data, stop spinning.
|
|
3695 |
break;
|
|
3696 |
else
|
|
3697 |
len = state.length;
|
|
3698 |
}
|
|
3699 |
state.readingMore = false;
|
|
3700 |
}
|
|
3701 |
|
|
3702 |
// abstract method. to be overridden in specific implementation classes.
|
|
3703 |
// call cb(er, data) where data is <= n in length.
|
|
3704 |
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
|
3705 |
// arbitrary, and perhaps not very meaningful.
|
|
3706 |
Readable.prototype._read = function(n) {
|
|
3707 |
this.emit('error', new Error('not implemented'));
|
|
3708 |
};
|
|
3709 |
|
|
3710 |
Readable.prototype.pipe = function(dest, pipeOpts) {
|
|
3711 |
var src = this;
|
|
3712 |
var state = this._readableState;
|
|
3713 |
|
|
3714 |
switch (state.pipesCount) {
|
|
3715 |
case 0:
|
|
3716 |
state.pipes = dest;
|
|
3717 |
break;
|
|
3718 |
case 1:
|
|
3719 |
state.pipes = [state.pipes, dest];
|
|
3720 |
break;
|
|
3721 |
default:
|
|
3722 |
state.pipes.push(dest);
|
|
3723 |
break;
|
|
3724 |
}
|
|
3725 |
state.pipesCount += 1;
|
|
3726 |
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
|
3727 |
|
|
3728 |
var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
|
3729 |
dest !== process.stdout &&
|
|
3730 |
dest !== process.stderr;
|
|
3731 |
|
|
3732 |
var endFn = doEnd ? onend : cleanup;
|
|
3733 |
if (state.endEmitted)
|
|
3734 |
process.nextTick(endFn);
|
|
3735 |
else
|
|
3736 |
src.once('end', endFn);
|
|
3737 |
|
|
3738 |
dest.on('unpipe', onunpipe);
|
|
3739 |
function onunpipe(readable) {
|
|
3740 |
debug('onunpipe');
|
|
3741 |
if (readable === src) {
|
|
3742 |
cleanup();
|
|
3743 |
}
|
|
3744 |
}
|
|
3745 |
|
|
3746 |
function onend() {
|
|
3747 |
debug('onend');
|
|
3748 |
dest.end();
|
|
3749 |
}
|
|
3750 |
|
|
3751 |
// when the dest drains, it reduces the awaitDrain counter
|
|
3752 |
// on the source. This would be more elegant with a .once()
|
|
3753 |
// handler in flow(), but adding and removing repeatedly is
|
|
3754 |
// too slow.
|
|
3755 |
var ondrain = pipeOnDrain(src);
|
|
3756 |
dest.on('drain', ondrain);
|
|
3757 |
|
|
3758 |
function cleanup() {
|
|
3759 |
debug('cleanup');
|
|
3760 |
// cleanup event handlers once the pipe is broken
|
|
3761 |
dest.removeListener('close', onclose);
|
|
3762 |
dest.removeListener('finish', onfinish);
|
|
3763 |
dest.removeListener('drain', ondrain);
|
|
3764 |
dest.removeListener('error', onerror);
|
|
3765 |
dest.removeListener('unpipe', onunpipe);
|
|
3766 |
src.removeListener('end', onend);
|
|
3767 |
src.removeListener('end', cleanup);
|
|
3768 |
src.removeListener('data', ondata);
|
|
3769 |
|
|
3770 |
// if the reader is waiting for a drain event from this
|
|
3771 |
// specific writer, then it would cause it to never start
|
|
3772 |
// flowing again.
|
|
3773 |
// So, if this is awaiting a drain, then we just call it now.
|
|
3774 |
// If we don't know, then assume that we are waiting for one.
|
|
3775 |
if (state.awaitDrain &&
|
|
3776 |
(!dest._writableState || dest._writableState.needDrain))
|
|
3777 |
ondrain();
|
|
3778 |
}
|
|
3779 |
|
|
3780 |
src.on('data', ondata);
|
|
3781 |
function ondata(chunk) {
|
|
3782 |
debug('ondata');
|
|
3783 |
var ret = dest.write(chunk);
|
|
3784 |
if (false === ret) {
|
|
3785 |
debug('false write response, pause',
|
|
3786 |
src._readableState.awaitDrain);
|
|
3787 |
src._readableState.awaitDrain++;
|
|
3788 |
src.pause();
|
|
3789 |
}
|
|
3790 |
}
|
|
3791 |
|
|
3792 |
// if the dest has an error, then stop piping into it.
|
|
3793 |
// however, don't suppress the throwing behavior for this.
|
|
3794 |
function onerror(er) {
|
|
3795 |
debug('onerror', er);
|
|
3796 |
unpipe();
|
|
3797 |
dest.removeListener('error', onerror);
|
|
3798 |
if (EE.listenerCount(dest, 'error') === 0)
|
|
3799 |
dest.emit('error', er);
|
|
3800 |
}
|
|
3801 |
// This is a brutally ugly hack to make sure that our error handler
|
|
3802 |
// is attached before any userland ones. NEVER DO THIS.
|
|
3803 |
if (!dest._events || !dest._events.error)
|
|
3804 |
dest.on('error', onerror);
|
|
3805 |
else if (isArray(dest._events.error))
|
|
3806 |
dest._events.error.unshift(onerror);
|
|
3807 |
else
|
|
3808 |
dest._events.error = [onerror, dest._events.error];
|
|
3809 |
|
|
3810 |
|
|
3811 |
|
|
3812 |
// Both close and finish should trigger unpipe, but only once.
|
|
3813 |
function onclose() {
|
|
3814 |
dest.removeListener('finish', onfinish);
|
|
3815 |
unpipe();
|
|
3816 |
}
|
|
3817 |
dest.once('close', onclose);
|
|
3818 |
function onfinish() {
|
|
3819 |
debug('onfinish');
|
|
3820 |
dest.removeListener('close', onclose);
|
|
3821 |
unpipe();
|
|
3822 |
}
|
|
3823 |
dest.once('finish', onfinish);
|
|
3824 |
|
|
3825 |
function unpipe() {
|
|
3826 |
debug('unpipe');
|
|
3827 |
src.unpipe(dest);
|
|
3828 |
}
|
|
3829 |
|
|
3830 |
// tell the dest that it's being piped to
|
|
3831 |
dest.emit('pipe', src);
|
|
3832 |
|
|
3833 |
// start the flow if it hasn't been started already.
|
|
3834 |
if (!state.flowing) {
|
|
3835 |
debug('pipe resume');
|
|
3836 |
src.resume();
|
|
3837 |
}
|
|
3838 |
|
|
3839 |
return dest;
|
|
3840 |
};
|
|
3841 |
|
|
3842 |
function pipeOnDrain(src) {
|
|
3843 |
return function() {
|
|
3844 |
var state = src._readableState;
|
|
3845 |
debug('pipeOnDrain', state.awaitDrain);
|
|
3846 |
if (state.awaitDrain)
|
|
3847 |
state.awaitDrain--;
|
|
3848 |
if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
|
|
3849 |
state.flowing = true;
|
|
3850 |
flow(src);
|
|
3851 |
}
|
|
3852 |
};
|
|
3853 |
}
|
|
3854 |
|
|
3855 |
|
|
3856 |
Readable.prototype.unpipe = function(dest) {
|
|
3857 |
var state = this._readableState;
|
|
3858 |
|
|
3859 |
// if we're not piping anywhere, then do nothing.
|
|
3860 |
if (state.pipesCount === 0)
|
|
3861 |
return this;
|
|
3862 |
|
|
3863 |
// just one destination. most common case.
|
|
3864 |
if (state.pipesCount === 1) {
|
|
3865 |
// passed in one, but it's not the right one.
|
|
3866 |
if (dest && dest !== state.pipes)
|
|
3867 |
return this;
|
|
3868 |
|
|
3869 |
if (!dest)
|
|
3870 |
dest = state.pipes;
|
|
3871 |
|
|
3872 |
// got a match.
|
|
3873 |
state.pipes = null;
|
|
3874 |
state.pipesCount = 0;
|
|
3875 |
state.flowing = false;
|
|
3876 |
if (dest)
|
|
3877 |
dest.emit('unpipe', this);
|
|
3878 |
return this;
|
|
3879 |
}
|
|
3880 |
|
|
3881 |
// slow case. multiple pipe destinations.
|
|
3882 |
|
|
3883 |
if (!dest) {
|
|
3884 |
// remove all.
|
|
3885 |
var dests = state.pipes;
|
|
3886 |
var len = state.pipesCount;
|
|
3887 |
state.pipes = null;
|
|
3888 |
state.pipesCount = 0;
|
|
3889 |
state.flowing = false;
|
|
3890 |
|
|
3891 |
for (var i = 0; i < len; i++)
|
|
3892 |
dests[i].emit('unpipe', this);
|
|
3893 |
return this;
|
|
3894 |
}
|
|
3895 |
|
|
3896 |
// try to find the right one.
|
|
3897 |
var i = indexOf(state.pipes, dest);
|
|
3898 |
if (i === -1)
|
|
3899 |
return this;
|
|
3900 |
|
|
3901 |
state.pipes.splice(i, 1);
|
|
3902 |
state.pipesCount -= 1;
|
|
3903 |
if (state.pipesCount === 1)
|
|
3904 |
state.pipes = state.pipes[0];
|
|
3905 |
|
|
3906 |
dest.emit('unpipe', this);
|
|
3907 |
|
|
3908 |
return this;
|
|
3909 |
};
|
|
3910 |
|
|
3911 |
// set up data events if they are asked for
|
|
3912 |
// Ensure readable listeners eventually get something
|
|
3913 |
Readable.prototype.on = function(ev, fn) {
|
|
3914 |
var res = Stream.prototype.on.call(this, ev, fn);
|
|
3915 |
|
|
3916 |
// If listening to data, and it has not explicitly been paused,
|
|
3917 |
// then call resume to start the flow of data on the next tick.
|
|
3918 |
if (ev === 'data' && false !== this._readableState.flowing) {
|
|
3919 |
this.resume();
|
|
3920 |
}
|
|
3921 |
|
|
3922 |
if (ev === 'readable' && this.readable) {
|
|
3923 |
var state = this._readableState;
|
|
3924 |
if (!state.readableListening) {
|
|
3925 |
state.readableListening = true;
|
|
3926 |
state.emittedReadable = false;
|
|
3927 |
state.needReadable = true;
|
|
3928 |
if (!state.reading) {
|
|
3929 |
var self = this;
|
|
3930 |
process.nextTick(function() {
|
|
3931 |
debug('readable nexttick read 0');
|
|
3932 |
self.read(0);
|
|
3933 |
});
|
|
3934 |
} else if (state.length) {
|
|
3935 |
emitReadable(this, state);
|
|
3936 |
}
|
|
3937 |
}
|
|
3938 |
}
|
|
3939 |
|
|
3940 |
return res;
|
|
3941 |
};
|
|
3942 |
Readable.prototype.addListener = Readable.prototype.on;
|
|
3943 |
|
|
3944 |
// pause() and resume() are remnants of the legacy readable stream API
|
|
3945 |
// If the user uses them, then switch into old mode.
|
|
3946 |
Readable.prototype.resume = function() {
|
|
3947 |
var state = this._readableState;
|
|
3948 |
if (!state.flowing) {
|
|
3949 |
debug('resume');
|
|
3950 |
state.flowing = true;
|
|
3951 |
if (!state.reading) {
|
|
3952 |
debug('resume read 0');
|
|
3953 |
this.read(0);
|
|
3954 |
}
|
|
3955 |
resume(this, state);
|
|
3956 |
}
|
|
3957 |
return this;
|
|
3958 |
};
|
|
3959 |
|
|
3960 |
function resume(stream, state) {
|
|
3961 |
if (!state.resumeScheduled) {
|
|
3962 |
state.resumeScheduled = true;
|
|
3963 |
process.nextTick(function() {
|
|
3964 |
resume_(stream, state);
|
|
3965 |
});
|
|
3966 |
}
|
|
3967 |
}
|
|
3968 |
|
|
3969 |
function resume_(stream, state) {
|
|
3970 |
state.resumeScheduled = false;
|
|
3971 |
stream.emit('resume');
|
|
3972 |
flow(stream);
|
|
3973 |
if (state.flowing && !state.reading)
|
|
3974 |
stream.read(0);
|
|
3975 |
}
|
|
3976 |
|
|
3977 |
Readable.prototype.pause = function() {
|
|
3978 |
debug('call pause flowing=%j', this._readableState.flowing);
|
|
3979 |
if (false !== this._readableState.flowing) {
|
|
3980 |
debug('pause');
|
|
3981 |
this._readableState.flowing = false;
|
|
3982 |
this.emit('pause');
|
|
3983 |
}
|
|
3984 |
return this;
|
|
3985 |
};
|
|
3986 |
|
|
3987 |
function flow(stream) {
|
|
3988 |
var state = stream._readableState;
|
|
3989 |
debug('flow', state.flowing);
|
|
3990 |
if (state.flowing) {
|
|
3991 |
do {
|
|
3992 |
var chunk = stream.read();
|
|
3993 |
} while (null !== chunk && state.flowing);
|
|
3994 |
}
|
|
3995 |
}
|
|
3996 |
|
|
3997 |
// wrap an old-style stream as the async data source.
|
|
3998 |
// This is *not* part of the readable stream interface.
|
|
3999 |
// It is an ugly unfortunate mess of history.
|
|
4000 |
Readable.prototype.wrap = function(stream) {
|
|
4001 |
var state = this._readableState;
|
|
4002 |
var paused = false;
|
|
4003 |
|
|
4004 |
var self = this;
|
|
4005 |
stream.on('end', function() {
|
|
4006 |
debug('wrapped end');
|
|
4007 |
if (state.decoder && !state.ended) {
|
|
4008 |
var chunk = state.decoder.end();
|
|
4009 |
if (chunk && chunk.length)
|
|
4010 |
self.push(chunk);
|
|
4011 |
}
|
|
4012 |
|
|
4013 |
self.push(null);
|
|
4014 |
});
|
|
4015 |
|
|
4016 |
stream.on('data', function(chunk) {
|
|
4017 |
debug('wrapped data');
|
|
4018 |
if (state.decoder)
|
|
4019 |
chunk = state.decoder.write(chunk);
|
|
4020 |
if (!chunk || !state.objectMode && !chunk.length)
|
|
4021 |
return;
|
|
4022 |
|
|
4023 |
var ret = self.push(chunk);
|
|
4024 |
if (!ret) {
|
|
4025 |
paused = true;
|
|
4026 |
stream.pause();
|
|
4027 |
}
|
|
4028 |
});
|
|
4029 |
|
|
4030 |
// proxy all the other methods.
|
|
4031 |
// important when wrapping filters and duplexes.
|
|
4032 |
for (var i in stream) {
|
|
4033 |
if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
|
|
4034 |
this[i] = function(method) { return function() {
|
|
4035 |
return stream[method].apply(stream, arguments);
|
|
4036 |
}}(i);
|
|
4037 |
}
|
|
4038 |
}
|
|
4039 |
|
|
4040 |
// proxy certain important events.
|
|
4041 |
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
|
4042 |
forEach(events, function(ev) {
|
|
4043 |
stream.on(ev, self.emit.bind(self, ev));
|
|
4044 |
});
|
|
4045 |
|
|
4046 |
// when we try to consume some more bytes, simply unpause the
|
|
4047 |
// underlying stream.
|
|
4048 |
self._read = function(n) {
|
|
4049 |
debug('wrapped _read', n);
|
|
4050 |
if (paused) {
|
|
4051 |
paused = false;
|
|
4052 |
stream.resume();
|
|
4053 |
}
|
|
4054 |
};
|
|
4055 |
|
|
4056 |
return self;
|
|
4057 |
};
|
|
4058 |
|
|
4059 |
|
|
4060 |
|
|
4061 |
// exposed for testing purposes only.
|
|
4062 |
Readable._fromList = fromList;
|
|
4063 |
|
|
4064 |
// Pluck off n bytes from an array of buffers.
|
|
4065 |
// Length is the combined lengths of all the buffers in the list.
|
|
4066 |
function fromList(n, state) {
|
|
4067 |
var list = state.buffer;
|
|
4068 |
var length = state.length;
|
|
4069 |
var stringMode = !!state.decoder;
|
|
4070 |
var objectMode = !!state.objectMode;
|
|
4071 |
var ret;
|
|
4072 |
|
|
4073 |
// nothing in the list, definitely empty.
|
|
4074 |
if (list.length === 0)
|
|
4075 |
return null;
|
|
4076 |
|
|
4077 |
if (length === 0)
|
|
4078 |
ret = null;
|
|
4079 |
else if (objectMode)
|
|
4080 |
ret = list.shift();
|
|
4081 |
else if (!n || n >= length) {
|
|
4082 |
// read it all, truncate the array.
|
|
4083 |
if (stringMode)
|
|
4084 |
ret = list.join('');
|
|
4085 |
else
|
|
4086 |
ret = Buffer.concat(list, length);
|
|
4087 |
list.length = 0;
|
|
4088 |
} else {
|
|
4089 |
// read just some of it.
|
|
4090 |
if (n < list[0].length) {
|
|
4091 |
// just take a part of the first list item.
|
|
4092 |
// slice is the same for buffers and strings.
|
|
4093 |
var buf = list[0];
|
|
4094 |
ret = buf.slice(0, n);
|
|
4095 |
list[0] = buf.slice(n);
|
|
4096 |
} else if (n === list[0].length) {
|
|
4097 |
// first list is a perfect match
|
|
4098 |
ret = list.shift();
|
|
4099 |
} else {
|
|
4100 |
// complex case.
|
|
4101 |
// we have enough to cover it, but it spans past the first buffer.
|
|
4102 |
if (stringMode)
|
|
4103 |
ret = '';
|
|
4104 |
else
|
|
4105 |
ret = new Buffer(n);
|
|
4106 |
|
|
4107 |
var c = 0;
|
|
4108 |
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
|
4109 |
var buf = list[0];
|
|
4110 |
var cpy = Math.min(n - c, buf.length);
|
|
4111 |
|
|
4112 |
if (stringMode)
|
|
4113 |
ret += buf.slice(0, cpy);
|
|
4114 |
else
|
|
4115 |
buf.copy(ret, c, 0, cpy);
|
|
4116 |
|
|
4117 |
if (cpy < buf.length)
|
|
4118 |
list[0] = buf.slice(cpy);
|
|
4119 |
else
|
|
4120 |
list.shift();
|
|
4121 |
|
|
4122 |
c += cpy;
|
|
4123 |
}
|
|
4124 |
}
|
|
4125 |
}
|
|
4126 |
|
|
4127 |
return ret;
|
|
4128 |
}
|
|
4129 |
|
|
4130 |
function endReadable(stream) {
|
|
4131 |
var state = stream._readableState;
|
|
4132 |
|
|
4133 |
// If we get here before consuming all the bytes, then that is a
|
|
4134 |
// bug in node. Should never happen.
|
|
4135 |
if (state.length > 0)
|
|
4136 |
throw new Error('endReadable called on non-empty stream');
|
|
4137 |
|
|
4138 |
if (!state.endEmitted) {
|
|
4139 |
state.ended = true;
|
|
4140 |
process.nextTick(function() {
|
|
4141 |
// Check that we didn't get one last unshift.
|
|
4142 |
if (!state.endEmitted && state.length === 0) {
|
|
4143 |
state.endEmitted = true;
|
|
4144 |
stream.readable = false;
|
|
4145 |
stream.emit('end');
|
|
4146 |
}
|
|
4147 |
});
|
|
4148 |
}
|
|
4149 |
}
|
|
4150 |
|
|
4151 |
function forEach (xs, f) {
|
|
4152 |
for (var i = 0, l = xs.length; i < l; i++) {
|
|
4153 |
f(xs[i], i);
|
|
4154 |
}
|
|
4155 |
}
|
|
4156 |
|
|
4157 |
function indexOf (xs, x) {
|
|
4158 |
for (var i = 0, l = xs.length; i < l; i++) {
|
|
4159 |
if (xs[i] === x) return i;
|
|
4160 |
}
|
|
4161 |
return -1;
|
|
4162 |
}
|
|
4163 |
|
|
4164 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
|
|
4165 |
|
|
4166 |
/***/ },
|
|
4167 |
/* 22 */
|
|
4168 |
/***/ function(module, exports) {
|
|
4169 |
|
|
4170 |
module.exports = Array.isArray || function (arr) {
|
|
4171 |
return Object.prototype.toString.call(arr) == '[object Array]';
|
|
4172 |
};
|
|
4173 |
|
|
4174 |
|
|
4175 |
/***/ },
|
|
4176 |
/* 23 */
|
|
4177 |
/***/ function(module, exports, __webpack_require__) {
|
|
4178 |
|
|
4179 |
/* WEBPACK VAR INJECTION */(function(Buffer, global) {/*!
|
|
4180 |
* The buffer module from node.js, for the browser.
|
|
4181 |
*
|
|
4182 |
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
4183 |
* @license MIT
|
|
4184 |
*/
|
|
4185 |
/* eslint-disable no-proto */
|
|
4186 |
|
|
4187 |
'use strict'
|
|
4188 |
|
|
4189 |
var base64 = __webpack_require__(24)
|
|
4190 |
var ieee754 = __webpack_require__(25)
|
|
4191 |
var isArray = __webpack_require__(26)
|
|
4192 |
|
|
4193 |
exports.Buffer = Buffer
|
|
4194 |
exports.SlowBuffer = SlowBuffer
|
|
4195 |
exports.INSPECT_MAX_BYTES = 50
|
|
4196 |
Buffer.poolSize = 8192 // not used by this implementation
|
|
4197 |
|
|
4198 |
var rootParent = {}
|
|
4199 |
|
|
4200 |
/**
|
|
4201 |
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
4202 |
* === true Use Uint8Array implementation (fastest)
|
|
4203 |
* === false Use Object implementation (most compatible, even IE6)
|
|
4204 |
*
|
|
4205 |
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
4206 |
* Opera 11.6+, iOS 4.2+.
|
|
4207 |
*
|
|
4208 |
* Due to various browser bugs, sometimes the Object implementation will be used even
|
|
4209 |
* when the browser supports typed arrays.
|
|
4210 |
*
|
|
4211 |
* Note:
|
|
4212 |
*
|
|
4213 |
* - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
|
|
4214 |
* See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
|
|
4215 |
*
|
|
4216 |
* - Safari 5-7 lacks support for changing the `Object.prototype.constructor` property
|
|
4217 |
* on objects.
|
|
4218 |
*
|
|
4219 |
* - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
|
|
4220 |
*
|
|
4221 |
* - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
|
|
4222 |
* incorrect length in some situations.
|
|
4223 |
|
|
4224 |
* We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
|
|
4225 |
* get the Object implementation, which is slower but behaves correctly.
|
|
4226 |
*/
|
|
4227 |
Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
|
|
4228 |
? global.TYPED_ARRAY_SUPPORT
|
|
4229 |
: typedArraySupport()
|
|
4230 |
|
|
4231 |
function typedArraySupport () {
|
|
4232 |
function Bar () {}
|
|
4233 |
try {
|
|
4234 |
var arr = new Uint8Array(1)
|
|
4235 |
arr.foo = function () { return 42 }
|
|
4236 |
arr.constructor = Bar
|
|
4237 |
return arr.foo() === 42 && // typed array instances can be augmented
|
|
4238 |
arr.constructor === Bar && // constructor can be set
|
|
4239 |
typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
|
|
4240 |
arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
|
|
4241 |
} catch (e) {
|
|
4242 |
return false
|
|
4243 |
}
|
|
4244 |
}
|
|
4245 |
|
|
4246 |
function kMaxLength () {
|
|
4247 |
return Buffer.TYPED_ARRAY_SUPPORT
|
|
4248 |
? 0x7fffffff
|
|
4249 |
: 0x3fffffff
|
|
4250 |
}
|
|
4251 |
|
|
4252 |
/**
|
|
4253 |
* Class: Buffer
|
|
4254 |
* =============
|
|
4255 |
*
|
|
4256 |
* The Buffer constructor returns instances of `Uint8Array` that are augmented
|
|
4257 |
* with function properties for all the node `Buffer` API functions. We use
|
|
4258 |
* `Uint8Array` so that square bracket notation works as expected -- it returns
|
|
4259 |
* a single octet.
|
|
4260 |
*
|
|
4261 |
* By augmenting the instances, we can avoid modifying the `Uint8Array`
|
|
4262 |
* prototype.
|
|
4263 |
*/
|
|
4264 |
function Buffer (arg) {
|
|
4265 |
if (!(this instanceof Buffer)) {
|
|
4266 |
// Avoid going through an ArgumentsAdaptorTrampoline in the common case.
|
|
4267 |
if (arguments.length > 1) return new Buffer(arg, arguments[1])
|
|
4268 |
return new Buffer(arg)
|
|
4269 |
}
|
|
4270 |
|
|
4271 |
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
|
4272 |
this.length = 0
|
|
4273 |
this.parent = undefined
|
|
4274 |
}
|
|
4275 |
|
|
4276 |
// Common case.
|
|
4277 |
if (typeof arg === 'number') {
|
|
4278 |
return fromNumber(this, arg)
|
|
4279 |
}
|
|
4280 |
|
|
4281 |
// Slightly less common case.
|
|
4282 |
if (typeof arg === 'string') {
|
|
4283 |
return fromString(this, arg, arguments.length > 1 ? arguments[1] : 'utf8')
|
|
4284 |
}
|
|
4285 |
|
|
4286 |
// Unusual.
|
|
4287 |
return fromObject(this, arg)
|
|
4288 |
}
|
|
4289 |
|
|
4290 |
function fromNumber (that, length) {
|
|
4291 |
that = allocate(that, length < 0 ? 0 : checked(length) | 0)
|
|
4292 |
if (!Buffer.TYPED_ARRAY_SUPPORT) {
|
|
4293 |
for (var i = 0; i < length; i++) {
|
|
4294 |
that[i] = 0
|
|
4295 |
}
|
|
4296 |
}
|
|
4297 |
return that
|
|
4298 |
}
|
|
4299 |
|
|
4300 |
function fromString (that, string, encoding) {
|
|
4301 |
if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8'
|
|
4302 |
|
|
4303 |
// Assumption: byteLength() return value is always < kMaxLength.
|
|
4304 |
var length = byteLength(string, encoding) | 0
|
|
4305 |
that = allocate(that, length)
|
|
4306 |
|
|
4307 |
that.write(string, encoding)
|
|
4308 |
return that
|
|
4309 |
}
|
|
4310 |
|
|
4311 |
function fromObject (that, object) {
|
|
4312 |
if (Buffer.isBuffer(object)) return fromBuffer(that, object)
|
|
4313 |
|
|
4314 |
if (isArray(object)) return fromArray(that, object)
|
|
4315 |
|
|
4316 |
if (object == null) {
|
|
4317 |
throw new TypeError('must start with number, buffer, array or string')
|
|
4318 |
}
|
|
4319 |
|
|
4320 |
if (typeof ArrayBuffer !== 'undefined') {
|
|
4321 |
if (object.buffer instanceof ArrayBuffer) {
|
|
4322 |
return fromTypedArray(that, object)
|
|
4323 |
}
|
|
4324 |
if (object instanceof ArrayBuffer) {
|
|
4325 |
return fromArrayBuffer(that, object)
|
|
4326 |
}
|
|
4327 |
}
|
|
4328 |
|
|
4329 |
if (object.length) return fromArrayLike(that, object)
|
|
4330 |
|
|
4331 |
return fromJsonObject(that, object)
|
|
4332 |
}
|
|
4333 |
|
|
4334 |
function fromBuffer (that, buffer) {
|
|
4335 |
var length = checked(buffer.length) | 0
|
|
4336 |
that = allocate(that, length)
|
|
4337 |
buffer.copy(that, 0, 0, length)
|
|
4338 |
return that
|
|
4339 |
}
|
|
4340 |
|
|
4341 |
function fromArray (that, array) {
|
|
4342 |
var length = checked(array.length) | 0
|
|
4343 |
that = allocate(that, length)
|
|
4344 |
for (var i = 0; i < length; i += 1) {
|
|
4345 |
that[i] = array[i] & 255
|
|
4346 |
}
|
|
4347 |
return that
|
|
4348 |
}
|
|
4349 |
|
|
4350 |
// Duplicate of fromArray() to keep fromArray() monomorphic.
|
|
4351 |
function fromTypedArray (that, array) {
|
|
4352 |
var length = checked(array.length) | 0
|
|
4353 |
that = allocate(that, length)
|
|
4354 |
// Truncating the elements is probably not what people expect from typed
|
|
4355 |
// arrays with BYTES_PER_ELEMENT > 1 but it's compatible with the behavior
|
|
4356 |
// of the old Buffer constructor.
|
|
4357 |
for (var i = 0; i < length; i += 1) {
|
|
4358 |
that[i] = array[i] & 255
|
|
4359 |
}
|
|
4360 |
return that
|
|
4361 |
}
|
|
4362 |
|
|
4363 |
function fromArrayBuffer (that, array) {
|
|
4364 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
4365 |
// Return an augmented `Uint8Array` instance, for best performance
|
|
4366 |
array.byteLength
|
|
4367 |
that = Buffer._augment(new Uint8Array(array))
|
|
4368 |
} else {
|
|
4369 |
// Fallback: Return an object instance of the Buffer class
|
|
4370 |
that = fromTypedArray(that, new Uint8Array(array))
|
|
4371 |
}
|
|
4372 |
return that
|
|
4373 |
}
|
|
4374 |
|
|
4375 |
function fromArrayLike (that, array) {
|
|
4376 |
var length = checked(array.length) | 0
|
|
4377 |
that = allocate(that, length)
|
|
4378 |
for (var i = 0; i < length; i += 1) {
|
|
4379 |
that[i] = array[i] & 255
|
|
4380 |
}
|
|
4381 |
return that
|
|
4382 |
}
|
|
4383 |
|
|
4384 |
// Deserialize { type: 'Buffer', data: [1,2,3,...] } into a Buffer object.
|
|
4385 |
// Returns a zero-length buffer for inputs that don't conform to the spec.
|
|
4386 |
function fromJsonObject (that, object) {
|
|
4387 |
var array
|
|
4388 |
var length = 0
|
|
4389 |
|
|
4390 |
if (object.type === 'Buffer' && isArray(object.data)) {
|
|
4391 |
array = object.data
|
|
4392 |
length = checked(array.length) | 0
|
|
4393 |
}
|
|
4394 |
that = allocate(that, length)
|
|
4395 |
|
|
4396 |
for (var i = 0; i < length; i += 1) {
|
|
4397 |
that[i] = array[i] & 255
|
|
4398 |
}
|
|
4399 |
return that
|
|
4400 |
}
|
|
4401 |
|
|
4402 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
4403 |
Buffer.prototype.__proto__ = Uint8Array.prototype
|
|
4404 |
Buffer.__proto__ = Uint8Array
|
|
4405 |
} else {
|
|
4406 |
// pre-set for values that may exist in the future
|
|
4407 |
Buffer.prototype.length = undefined
|
|
4408 |
Buffer.prototype.parent = undefined
|
|
4409 |
}
|
|
4410 |
|
|
4411 |
function allocate (that, length) {
|
|
4412 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
4413 |
// Return an augmented `Uint8Array` instance, for best performance
|
|
4414 |
that = Buffer._augment(new Uint8Array(length))
|
|
4415 |
that.__proto__ = Buffer.prototype
|
|
4416 |
} else {
|
|
4417 |
// Fallback: Return an object instance of the Buffer class
|
|
4418 |
that.length = length
|
|
4419 |
that._isBuffer = true
|
|
4420 |
}
|
|
4421 |
|
|
4422 |
var fromPool = length !== 0 && length <= Buffer.poolSize >>> 1
|
|
4423 |
if (fromPool) that.parent = rootParent
|
|
4424 |
|
|
4425 |
return that
|
|
4426 |
}
|
|
4427 |
|
|
4428 |
function checked (length) {
|
|
4429 |
// Note: cannot use `length < kMaxLength` here because that fails when
|
|
4430 |
// length is NaN (which is otherwise coerced to zero.)
|
|
4431 |
if (length >= kMaxLength()) {
|
|
4432 |
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
4433 |
'size: 0x' + kMaxLength().toString(16) + ' bytes')
|
|
4434 |
}
|
|
4435 |
return length | 0
|
|
4436 |
}
|
|
4437 |
|
|
4438 |
function SlowBuffer (subject, encoding) {
|
|
4439 |
if (!(this instanceof SlowBuffer)) return new SlowBuffer(subject, encoding)
|
|
4440 |
|
|
4441 |
var buf = new Buffer(subject, encoding)
|
|
4442 |
delete buf.parent
|
|
4443 |
return buf
|
|
4444 |
}
|
|
4445 |
|
|
4446 |
Buffer.isBuffer = function isBuffer (b) {
|
|
4447 |
return !!(b != null && b._isBuffer)
|
|
4448 |
}
|
|
4449 |
|
|
4450 |
Buffer.compare = function compare (a, b) {
|
|
4451 |
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
4452 |
throw new TypeError('Arguments must be Buffers')
|
|
4453 |
}
|
|
4454 |
|
|
4455 |
if (a === b) return 0
|
|
4456 |
|
|
4457 |
var x = a.length
|
|
4458 |
var y = b.length
|
|
4459 |
|
|
4460 |
var i = 0
|
|
4461 |
var len = Math.min(x, y)
|
|
4462 |
while (i < len) {
|
|
4463 |
if (a[i] !== b[i]) break
|
|
4464 |
|
|
4465 |
++i
|
|
4466 |
}
|
|
4467 |
|
|
4468 |
if (i !== len) {
|
|
4469 |
x = a[i]
|
|
4470 |
y = b[i]
|
|
4471 |
}
|
|
4472 |
|
|
4473 |
if (x < y) return -1
|
|
4474 |
if (y < x) return 1
|
|
4475 |
return 0
|
|
4476 |
}
|
|
4477 |
|
|
4478 |
Buffer.isEncoding = function isEncoding (encoding) {
|
|
4479 |
switch (String(encoding).toLowerCase()) {
|
|
4480 |
case 'hex':
|
|
4481 |
case 'utf8':
|
|
4482 |
case 'utf-8':
|
|
4483 |
case 'ascii':
|
|
4484 |
case 'binary':
|
|
4485 |
case 'base64':
|
|
4486 |
case 'raw':
|
|
4487 |
case 'ucs2':
|
|
4488 |
case 'ucs-2':
|
|
4489 |
case 'utf16le':
|
|
4490 |
case 'utf-16le':
|
|
4491 |
return true
|
|
4492 |
default:
|
|
4493 |
return false
|
|
4494 |
}
|
|
4495 |
}
|
|
4496 |
|
|
4497 |
Buffer.concat = function concat (list, length) {
|
|
4498 |
if (!isArray(list)) throw new TypeError('list argument must be an Array of Buffers.')
|
|
4499 |
|
|
4500 |
if (list.length === 0) {
|
|
4501 |
return new Buffer(0)
|
|
4502 |
}
|
|
4503 |
|
|
4504 |
var i
|
|
4505 |
if (length === undefined) {
|
|
4506 |
length = 0
|
|
4507 |
for (i = 0; i < list.length; i++) {
|
|
4508 |
length += list[i].length
|
|
4509 |
}
|
|
4510 |
}
|
|
4511 |
|
|
4512 |
var buf = new Buffer(length)
|
|
4513 |
var pos = 0
|
|
4514 |
for (i = 0; i < list.length; i++) {
|
|
4515 |
var item = list[i]
|
|
4516 |
item.copy(buf, pos)
|
|
4517 |
pos += item.length
|
|
4518 |
}
|
|
4519 |
return buf
|
|
4520 |
}
|
|
4521 |
|
|
4522 |
function byteLength (string, encoding) {
|
|
4523 |
if (typeof string !== 'string') string = '' + string
|
|
4524 |
|
|
4525 |
var len = string.length
|
|
4526 |
if (len === 0) return 0
|
|
4527 |
|
|
4528 |
// Use a for loop to avoid recursion
|
|
4529 |
var loweredCase = false
|
|
4530 |
for (;;) {
|
|
4531 |
switch (encoding) {
|
|
4532 |
case 'ascii':
|
|
4533 |
case 'binary':
|
|
4534 |
// Deprecated
|
|
4535 |
case 'raw':
|
|
4536 |
case 'raws':
|
|
4537 |
return len
|
|
4538 |
case 'utf8':
|
|
4539 |
case 'utf-8':
|
|
4540 |
return utf8ToBytes(string).length
|
|
4541 |
case 'ucs2':
|
|
4542 |
case 'ucs-2':
|
|
4543 |
case 'utf16le':
|
|
4544 |
case 'utf-16le':
|
|
4545 |
return len * 2
|
|
4546 |
case 'hex':
|
|
4547 |
return len >>> 1
|
|
4548 |
case 'base64':
|
|
4549 |
return base64ToBytes(string).length
|
|
4550 |
default:
|
|
4551 |
if (loweredCase) return utf8ToBytes(string).length // assume utf8
|
|
4552 |
encoding = ('' + encoding).toLowerCase()
|
|
4553 |
loweredCase = true
|
|
4554 |
}
|
|
4555 |
}
|
|
4556 |
}
|
|
4557 |
Buffer.byteLength = byteLength
|
|
4558 |
|
|
4559 |
function slowToString (encoding, start, end) {
|
|
4560 |
var loweredCase = false
|
|
4561 |
|
|
4562 |
start = start | 0
|
|
4563 |
end = end === undefined || end === Infinity ? this.length : end | 0
|
|
4564 |
|
|
4565 |
if (!encoding) encoding = 'utf8'
|
|
4566 |
if (start < 0) start = 0
|
|
4567 |
if (end > this.length) end = this.length
|
|
4568 |
if (end <= start) return ''
|
|
4569 |
|
|
4570 |
while (true) {
|
|
4571 |
switch (encoding) {
|
|
4572 |
case 'hex':
|
|
4573 |
return hexSlice(this, start, end)
|
|
4574 |
|
|
4575 |
case 'utf8':
|
|
4576 |
case 'utf-8':
|
|
4577 |
return utf8Slice(this, start, end)
|
|
4578 |
|
|
4579 |
case 'ascii':
|
|
4580 |
return asciiSlice(this, start, end)
|
|
4581 |
|
|
4582 |
case 'binary':
|
|
4583 |
return binarySlice(this, start, end)
|
|
4584 |
|
|
4585 |
case 'base64':
|
|
4586 |
return base64Slice(this, start, end)
|
|
4587 |
|
|
4588 |
case 'ucs2':
|
|
4589 |
case 'ucs-2':
|
|
4590 |
case 'utf16le':
|
|
4591 |
case 'utf-16le':
|
|
4592 |
return utf16leSlice(this, start, end)
|
|
4593 |
|
|
4594 |
default:
|
|
4595 |
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
4596 |
encoding = (encoding + '').toLowerCase()
|
|
4597 |
loweredCase = true
|
|
4598 |
}
|
|
4599 |
}
|
|
4600 |
}
|
|
4601 |
|
|
4602 |
Buffer.prototype.toString = function toString () {
|
|
4603 |
var length = this.length | 0
|
|
4604 |
if (length === 0) return ''
|
|
4605 |
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
4606 |
return slowToString.apply(this, arguments)
|
|
4607 |
}
|
|
4608 |
|
|
4609 |
Buffer.prototype.equals = function equals (b) {
|
|
4610 |
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
4611 |
if (this === b) return true
|
|
4612 |
return Buffer.compare(this, b) === 0
|
|
4613 |
}
|
|
4614 |
|
|
4615 |
Buffer.prototype.inspect = function inspect () {
|
|
4616 |
var str = ''
|
|
4617 |
var max = exports.INSPECT_MAX_BYTES
|
|
4618 |
if (this.length > 0) {
|
|
4619 |
str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
|
|
4620 |
if (this.length > max) str += ' ... '
|
|
4621 |
}
|
|
4622 |
return '<Buffer ' + str + '>'
|
|
4623 |
}
|
|
4624 |
|
|
4625 |
Buffer.prototype.compare = function compare (b) {
|
|
4626 |
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
4627 |
if (this === b) return 0
|
|
4628 |
return Buffer.compare(this, b)
|
|
4629 |
}
|
|
4630 |
|
|
4631 |
Buffer.prototype.indexOf = function indexOf (val, byteOffset) {
|
|
4632 |
if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff
|
|
4633 |
else if (byteOffset < -0x80000000) byteOffset = -0x80000000
|
|
4634 |
byteOffset >>= 0
|
|
4635 |
|
|
4636 |
if (this.length === 0) return -1
|
|
4637 |
if (byteOffset >= this.length) return -1
|
|
4638 |
|
|
4639 |
// Negative offsets start from the end of the buffer
|
|
4640 |
if (byteOffset < 0) byteOffset = Math.max(this.length + byteOffset, 0)
|
|
4641 |
|
|
4642 |
if (typeof val === 'string') {
|
|
4643 |
if (val.length === 0) return -1 // special case: looking for empty string always fails
|
|
4644 |
return String.prototype.indexOf.call(this, val, byteOffset)
|
|
4645 |
}
|
|
4646 |
if (Buffer.isBuffer(val)) {
|
|
4647 |
return arrayIndexOf(this, val, byteOffset)
|
|
4648 |
}
|
|
4649 |
if (typeof val === 'number') {
|
|
4650 |
if (Buffer.TYPED_ARRAY_SUPPORT && Uint8Array.prototype.indexOf === 'function') {
|
|
4651 |
return Uint8Array.prototype.indexOf.call(this, val, byteOffset)
|
|
4652 |
}
|
|
4653 |
return arrayIndexOf(this, [ val ], byteOffset)
|
|
4654 |
}
|
|
4655 |
|
|
4656 |
function arrayIndexOf (arr, val, byteOffset) {
|
|
4657 |
var foundIndex = -1
|
|
4658 |
for (var i = 0; byteOffset + i < arr.length; i++) {
|
|
4659 |
if (arr[byteOffset + i] === val[foundIndex === -1 ? 0 : i - foundIndex]) {
|
|
4660 |
if (foundIndex === -1) foundIndex = i
|
|
4661 |
if (i - foundIndex + 1 === val.length) return byteOffset + foundIndex
|
|
4662 |
} else {
|
|
4663 |
foundIndex = -1
|
|
4664 |
}
|
|
4665 |
}
|
|
4666 |
return -1
|
|
4667 |
}
|
|
4668 |
|
|
4669 |
throw new TypeError('val must be string, number or Buffer')
|
|
4670 |
}
|
|
4671 |
|
|
4672 |
// `get` is deprecated
|
|
4673 |
Buffer.prototype.get = function get (offset) {
|
|
4674 |
console.log('.get() is deprecated. Access using array indexes instead.')
|
|
4675 |
return this.readUInt8(offset)
|
|
4676 |
}
|
|
4677 |
|
|
4678 |
// `set` is deprecated
|
|
4679 |
Buffer.prototype.set = function set (v, offset) {
|
|
4680 |
console.log('.set() is deprecated. Access using array indexes instead.')
|
|
4681 |
return this.writeUInt8(v, offset)
|
|
4682 |
}
|
|
4683 |
|
|
4684 |
function hexWrite (buf, string, offset, length) {
|
|
4685 |
offset = Number(offset) || 0
|
|
4686 |
var remaining = buf.length - offset
|
|
4687 |
if (!length) {
|
|
4688 |
length = remaining
|
|
4689 |
} else {
|
|
4690 |
length = Number(length)
|
|
4691 |
if (length > remaining) {
|
|
4692 |
length = remaining
|
|
4693 |
}
|
|
4694 |
}
|
|
4695 |
|
|
4696 |
// must be an even number of digits
|
|
4697 |
var strLen = string.length
|
|
4698 |
if (strLen % 2 !== 0) throw new Error('Invalid hex string')
|
|
4699 |
|
|
4700 |
if (length > strLen / 2) {
|
|
4701 |
length = strLen / 2
|
|
4702 |
}
|
|
4703 |
for (var i = 0; i < length; i++) {
|
|
4704 |
var parsed = parseInt(string.substr(i * 2, 2), 16)
|
|
4705 |
if (isNaN(parsed)) throw new Error('Invalid hex string')
|
|
4706 |
buf[offset + i] = parsed
|
|
4707 |
}
|
|
4708 |
return i
|
|
4709 |
}
|
|
4710 |
|
|
4711 |
function utf8Write (buf, string, offset, length) {
|
|
4712 |
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
4713 |
}
|
|
4714 |
|
|
4715 |
function asciiWrite (buf, string, offset, length) {
|
|
4716 |
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
4717 |
}
|
|
4718 |
|
|
4719 |
function binaryWrite (buf, string, offset, length) {
|
|
4720 |
return asciiWrite(buf, string, offset, length)
|
|
4721 |
}
|
|
4722 |
|
|
4723 |
function base64Write (buf, string, offset, length) {
|
|
4724 |
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
4725 |
}
|
|
4726 |
|
|
4727 |
function ucs2Write (buf, string, offset, length) {
|
|
4728 |
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
4729 |
}
|
|
4730 |
|
|
4731 |
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
4732 |
// Buffer#write(string)
|
|
4733 |
if (offset === undefined) {
|
|
4734 |
encoding = 'utf8'
|
|
4735 |
length = this.length
|
|
4736 |
offset = 0
|
|
4737 |
// Buffer#write(string, encoding)
|
|
4738 |
} else if (length === undefined && typeof offset === 'string') {
|
|
4739 |
encoding = offset
|
|
4740 |
length = this.length
|
|
4741 |
offset = 0
|
|
4742 |
// Buffer#write(string, offset[, length][, encoding])
|
|
4743 |
} else if (isFinite(offset)) {
|
|
4744 |
offset = offset | 0
|
|
4745 |
if (isFinite(length)) {
|
|
4746 |
length = length | 0
|
|
4747 |
if (encoding === undefined) encoding = 'utf8'
|
|
4748 |
} else {
|
|
4749 |
encoding = length
|
|
4750 |
length = undefined
|
|
4751 |
}
|
|
4752 |
// legacy write(string, encoding, offset, length) - remove in v0.13
|
|
4753 |
} else {
|
|
4754 |
var swap = encoding
|
|
4755 |
encoding = offset
|
|
4756 |
offset = length | 0
|
|
4757 |
length = swap
|
|
4758 |
}
|
|
4759 |
|
|
4760 |
var remaining = this.length - offset
|
|
4761 |
if (length === undefined || length > remaining) length = remaining
|
|
4762 |
|
|
4763 |
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
4764 |
throw new RangeError('attempt to write outside buffer bounds')
|
|
4765 |
}
|
|
4766 |
|
|
4767 |
if (!encoding) encoding = 'utf8'
|
|
4768 |
|
|
4769 |
var loweredCase = false
|
|
4770 |
for (;;) {
|
|
4771 |
switch (encoding) {
|
|
4772 |
case 'hex':
|
|
4773 |
return hexWrite(this, string, offset, length)
|
|
4774 |
|
|
4775 |
case 'utf8':
|
|
4776 |
case 'utf-8':
|
|
4777 |
return utf8Write(this, string, offset, length)
|
|
4778 |
|
|
4779 |
case 'ascii':
|
|
4780 |
return asciiWrite(this, string, offset, length)
|
|
4781 |
|
|
4782 |
case 'binary':
|
|
4783 |
return binaryWrite(this, string, offset, length)
|
|
4784 |
|
|
4785 |
case 'base64':
|
|
4786 |
// Warning: maxLength not taken into account in base64Write
|
|
4787 |
return base64Write(this, string, offset, length)
|
|
4788 |
|
|
4789 |
case 'ucs2':
|
|
4790 |
case 'ucs-2':
|
|
4791 |
case 'utf16le':
|
|
4792 |
case 'utf-16le':
|
|
4793 |
return ucs2Write(this, string, offset, length)
|
|
4794 |
|
|
4795 |
default:
|
|
4796 |
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
4797 |
encoding = ('' + encoding).toLowerCase()
|
|
4798 |
loweredCase = true
|
|
4799 |
}
|
|
4800 |
}
|
|
4801 |
}
|
|
4802 |
|
|
4803 |
Buffer.prototype.toJSON = function toJSON () {
|
|
4804 |
return {
|
|
4805 |
type: 'Buffer',
|
|
4806 |
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
4807 |
}
|
|
4808 |
}
|
|
4809 |
|
|
4810 |
function base64Slice (buf, start, end) {
|
|
4811 |
if (start === 0 && end === buf.length) {
|
|
4812 |
return base64.fromByteArray(buf)
|
|
4813 |
} else {
|
|
4814 |
return base64.fromByteArray(buf.slice(start, end))
|
|
4815 |
}
|
|
4816 |
}
|
|
4817 |
|
|
4818 |
function utf8Slice (buf, start, end) {
|
|
4819 |
end = Math.min(buf.length, end)
|
|
4820 |
var res = []
|
|
4821 |
|
|
4822 |
var i = start
|
|
4823 |
while (i < end) {
|
|
4824 |
var firstByte = buf[i]
|
|
4825 |
var codePoint = null
|
|
4826 |
var bytesPerSequence = (firstByte > 0xEF) ? 4
|
|
4827 |
: (firstByte > 0xDF) ? 3
|
|
4828 |
: (firstByte > 0xBF) ? 2
|
|
4829 |
: 1
|
|
4830 |
|
|
4831 |
if (i + bytesPerSequence <= end) {
|
|
4832 |
var secondByte, thirdByte, fourthByte, tempCodePoint
|
|
4833 |
|
|
4834 |
switch (bytesPerSequence) {
|
|
4835 |
case 1:
|
|
4836 |
if (firstByte < 0x80) {
|
|
4837 |
codePoint = firstByte
|
|
4838 |
}
|
|
4839 |
break
|
|
4840 |
case 2:
|
|
4841 |
secondByte = buf[i + 1]
|
|
4842 |
if ((secondByte & 0xC0) === 0x80) {
|
|
4843 |
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
|
|
4844 |
if (tempCodePoint > 0x7F) {
|
|
4845 |
codePoint = tempCodePoint
|
|
4846 |
}
|
|
4847 |
}
|
|
4848 |
break
|
|
4849 |
case 3:
|
|
4850 |
secondByte = buf[i + 1]
|
|
4851 |
thirdByte = buf[i + 2]
|
|
4852 |
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
4853 |
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
|
|
4854 |
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
4855 |
codePoint = tempCodePoint
|
|
4856 |
}
|
|
4857 |
}
|
|
4858 |
break
|
|
4859 |
case 4:
|
|
4860 |
secondByte = buf[i + 1]
|
|
4861 |
thirdByte = buf[i + 2]
|
|
4862 |
fourthByte = buf[i + 3]
|
|
4863 |
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
4864 |
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
|
|
4865 |
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
4866 |
codePoint = tempCodePoint
|
|
4867 |
}
|
|
4868 |
}
|
|
4869 |
}
|
|
4870 |
}
|
|
4871 |
|
|
4872 |
if (codePoint === null) {
|
|
4873 |
// we did not generate a valid codePoint so insert a
|
|
4874 |
// replacement char (U+FFFD) and advance only 1 byte
|
|
4875 |
codePoint = 0xFFFD
|
|
4876 |
bytesPerSequence = 1
|
|
4877 |
} else if (codePoint > 0xFFFF) {
|
|
4878 |
// encode to utf16 (surrogate pair dance)
|
|
4879 |
codePoint -= 0x10000
|
|
4880 |
res.push(codePoint >>> 10 & 0x3FF | 0xD800)
|
|
4881 |
codePoint = 0xDC00 | codePoint & 0x3FF
|
|
4882 |
}
|
|
4883 |
|
|
4884 |
res.push(codePoint)
|
|
4885 |
i += bytesPerSequence
|
|
4886 |
}
|
|
4887 |
|
|
4888 |
return decodeCodePointsArray(res)
|
|
4889 |
}
|
|
4890 |
|
|
4891 |
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
4892 |
// the lowest limit is Chrome, with 0x10000 args.
|
|
4893 |
// We go 1 magnitude less, for safety
|
|
4894 |
var MAX_ARGUMENTS_LENGTH = 0x1000
|
|
4895 |
|
|
4896 |
function decodeCodePointsArray (codePoints) {
|
|
4897 |
var len = codePoints.length
|
|
4898 |
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
4899 |
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
4900 |
}
|
|
4901 |
|
|
4902 |
// Decode in chunks to avoid "call stack size exceeded".
|
|
4903 |
var res = ''
|
|
4904 |
var i = 0
|
|
4905 |
while (i < len) {
|
|
4906 |
res += String.fromCharCode.apply(
|
|
4907 |
String,
|
|
4908 |
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
4909 |
)
|
|
4910 |
}
|
|
4911 |
return res
|
|
4912 |
}
|
|
4913 |
|
|
4914 |
function asciiSlice (buf, start, end) {
|
|
4915 |
var ret = ''
|
|
4916 |
end = Math.min(buf.length, end)
|
|
4917 |
|
|
4918 |
for (var i = start; i < end; i++) {
|
|
4919 |
ret += String.fromCharCode(buf[i] & 0x7F)
|
|
4920 |
}
|
|
4921 |
return ret
|
|
4922 |
}
|
|
4923 |
|
|
4924 |
function binarySlice (buf, start, end) {
|
|
4925 |
var ret = ''
|
|
4926 |
end = Math.min(buf.length, end)
|
|
4927 |
|
|
4928 |
for (var i = start; i < end; i++) {
|
|
4929 |
ret += String.fromCharCode(buf[i])
|
|
4930 |
}
|
|
4931 |
return ret
|
|
4932 |
}
|
|
4933 |
|
|
4934 |
function hexSlice (buf, start, end) {
|
|
4935 |
var len = buf.length
|
|
4936 |
|
|
4937 |
if (!start || start < 0) start = 0
|
|
4938 |
if (!end || end < 0 || end > len) end = len
|
|
4939 |
|
|
4940 |
var out = ''
|
|
4941 |
for (var i = start; i < end; i++) {
|
|
4942 |
out += toHex(buf[i])
|
|
4943 |
}
|
|
4944 |
return out
|
|
4945 |
}
|
|
4946 |
|
|
4947 |
function utf16leSlice (buf, start, end) {
|
|
4948 |
var bytes = buf.slice(start, end)
|
|
4949 |
var res = ''
|
|
4950 |
for (var i = 0; i < bytes.length; i += 2) {
|
|
4951 |
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
|
|
4952 |
}
|
|
4953 |
return res
|
|
4954 |
}
|
|
4955 |
|
|
4956 |
Buffer.prototype.slice = function slice (start, end) {
|
|
4957 |
var len = this.length
|
|
4958 |
start = ~~start
|
|
4959 |
end = end === undefined ? len : ~~end
|
|
4960 |
|
|
4961 |
if (start < 0) {
|
|
4962 |
start += len
|
|
4963 |
if (start < 0) start = 0
|
|
4964 |
} else if (start > len) {
|
|
4965 |
start = len
|
|
4966 |
}
|
|
4967 |
|
|
4968 |
if (end < 0) {
|
|
4969 |
end += len
|
|
4970 |
if (end < 0) end = 0
|
|
4971 |
} else if (end > len) {
|
|
4972 |
end = len
|
|
4973 |
}
|
|
4974 |
|
|
4975 |
if (end < start) end = start
|
|
4976 |
|
|
4977 |
var newBuf
|
|
4978 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
4979 |
newBuf = Buffer._augment(this.subarray(start, end))
|
|
4980 |
} else {
|
|
4981 |
var sliceLen = end - start
|
|
4982 |
newBuf = new Buffer(sliceLen, undefined)
|
|
4983 |
for (var i = 0; i < sliceLen; i++) {
|
|
4984 |
newBuf[i] = this[i + start]
|
|
4985 |
}
|
|
4986 |
}
|
|
4987 |
|
|
4988 |
if (newBuf.length) newBuf.parent = this.parent || this
|
|
4989 |
|
|
4990 |
return newBuf
|
|
4991 |
}
|
|
4992 |
|
|
4993 |
/*
|
|
4994 |
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
4995 |
*/
|
|
4996 |
function checkOffset (offset, ext, length) {
|
|
4997 |
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
4998 |
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
4999 |
}
|
|
5000 |
|
|
5001 |
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
5002 |
offset = offset | 0
|
|
5003 |
byteLength = byteLength | 0
|
|
5004 |
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
5005 |
|
|
5006 |
var val = this[offset]
|
|
5007 |
var mul = 1
|
|
5008 |
var i = 0
|
|
5009 |
while (++i < byteLength && (mul *= 0x100)) {
|
|
5010 |
val += this[offset + i] * mul
|
|
5011 |
}
|
|
5012 |
|
|
5013 |
return val
|
|
5014 |
}
|
|
5015 |
|
|
5016 |
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
5017 |
offset = offset | 0
|
|
5018 |
byteLength = byteLength | 0
|
|
5019 |
if (!noAssert) {
|
|
5020 |
checkOffset(offset, byteLength, this.length)
|
|
5021 |
}
|
|
5022 |
|
|
5023 |
var val = this[offset + --byteLength]
|
|
5024 |
var mul = 1
|
|
5025 |
while (byteLength > 0 && (mul *= 0x100)) {
|
|
5026 |
val += this[offset + --byteLength] * mul
|
|
5027 |
}
|
|
5028 |
|
|
5029 |
return val
|
|
5030 |
}
|
|
5031 |
|
|
5032 |
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
5033 |
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
5034 |
return this[offset]
|
|
5035 |
}
|
|
5036 |
|
|
5037 |
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
5038 |
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
5039 |
return this[offset] | (this[offset + 1] << 8)
|
|
5040 |
}
|
|
5041 |
|
|
5042 |
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
5043 |
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
5044 |
return (this[offset] << 8) | this[offset + 1]
|
|
5045 |
}
|
|
5046 |
|
|
5047 |
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
5048 |
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
5049 |
|
|
5050 |
return ((this[offset]) |
|
|
5051 |
(this[offset + 1] << 8) |
|
|
5052 |
(this[offset + 2] << 16)) +
|
|
5053 |
(this[offset + 3] * 0x1000000)
|
|
5054 |
}
|
|
5055 |
|
|
5056 |
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
5057 |
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
5058 |
|
|
5059 |
return (this[offset] * 0x1000000) +
|
|
5060 |
((this[offset + 1] << 16) |
|
|
5061 |
(this[offset + 2] << 8) |
|
|
5062 |
this[offset + 3])
|
|
5063 |
}
|
|
5064 |
|
|
5065 |
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
5066 |
offset = offset | 0
|
|
5067 |
byteLength = byteLength | 0
|
|
5068 |
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
5069 |
|
|
5070 |
var val = this[offset]
|
|
5071 |
var mul = 1
|
|
5072 |
var i = 0
|
|
5073 |
while (++i < byteLength && (mul *= 0x100)) {
|
|
5074 |
val += this[offset + i] * mul
|
|
5075 |
}
|
|
5076 |
mul *= 0x80
|
|
5077 |
|
|
5078 |
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
5079 |
|
|
5080 |
return val
|
|
5081 |
}
|
|
5082 |
|
|
5083 |
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
5084 |
offset = offset | 0
|
|
5085 |
byteLength = byteLength | 0
|
|
5086 |
if (!noAssert) checkOffset(offset, byteLength, this.length)
|
|
5087 |
|
|
5088 |
var i = byteLength
|
|
5089 |
var mul = 1
|
|
5090 |
var val = this[offset + --i]
|
|
5091 |
while (i > 0 && (mul *= 0x100)) {
|
|
5092 |
val += this[offset + --i] * mul
|
|
5093 |
}
|
|
5094 |
mul *= 0x80
|
|
5095 |
|
|
5096 |
if (val >= mul) val -= Math.pow(2, 8 * byteLength)
|
|
5097 |
|
|
5098 |
return val
|
|
5099 |
}
|
|
5100 |
|
|
5101 |
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
5102 |
if (!noAssert) checkOffset(offset, 1, this.length)
|
|
5103 |
if (!(this[offset] & 0x80)) return (this[offset])
|
|
5104 |
return ((0xff - this[offset] + 1) * -1)
|
|
5105 |
}
|
|
5106 |
|
|
5107 |
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
5108 |
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
5109 |
var val = this[offset] | (this[offset + 1] << 8)
|
|
5110 |
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
5111 |
}
|
|
5112 |
|
|
5113 |
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
5114 |
if (!noAssert) checkOffset(offset, 2, this.length)
|
|
5115 |
var val = this[offset + 1] | (this[offset] << 8)
|
|
5116 |
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
5117 |
}
|
|
5118 |
|
|
5119 |
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
5120 |
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
5121 |
|
|
5122 |
return (this[offset]) |
|
|
5123 |
(this[offset + 1] << 8) |
|
|
5124 |
(this[offset + 2] << 16) |
|
|
5125 |
(this[offset + 3] << 24)
|
|
5126 |
}
|
|
5127 |
|
|
5128 |
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
5129 |
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
5130 |
|
|
5131 |
return (this[offset] << 24) |
|
|
5132 |
(this[offset + 1] << 16) |
|
|
5133 |
(this[offset + 2] << 8) |
|
|
5134 |
(this[offset + 3])
|
|
5135 |
}
|
|
5136 |
|
|
5137 |
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
5138 |
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
5139 |
return ieee754.read(this, offset, true, 23, 4)
|
|
5140 |
}
|
|
5141 |
|
|
5142 |
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
5143 |
if (!noAssert) checkOffset(offset, 4, this.length)
|
|
5144 |
return ieee754.read(this, offset, false, 23, 4)
|
|
5145 |
}
|
|
5146 |
|
|
5147 |
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
5148 |
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
5149 |
return ieee754.read(this, offset, true, 52, 8)
|
|
5150 |
}
|
|
5151 |
|
|
5152 |
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
5153 |
if (!noAssert) checkOffset(offset, 8, this.length)
|
|
5154 |
return ieee754.read(this, offset, false, 52, 8)
|
|
5155 |
}
|
|
5156 |
|
|
5157 |
function checkInt (buf, value, offset, ext, max, min) {
|
|
5158 |
if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
|
|
5159 |
if (value > max || value < min) throw new RangeError('value is out of bounds')
|
|
5160 |
if (offset + ext > buf.length) throw new RangeError('index out of range')
|
|
5161 |
}
|
|
5162 |
|
|
5163 |
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
5164 |
value = +value
|
|
5165 |
offset = offset | 0
|
|
5166 |
byteLength = byteLength | 0
|
|
5167 |
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
|
5168 |
|
|
5169 |
var mul = 1
|
|
5170 |
var i = 0
|
|
5171 |
this[offset] = value & 0xFF
|
|
5172 |
while (++i < byteLength && (mul *= 0x100)) {
|
|
5173 |
this[offset + i] = (value / mul) & 0xFF
|
|
5174 |
}
|
|
5175 |
|
|
5176 |
return offset + byteLength
|
|
5177 |
}
|
|
5178 |
|
|
5179 |
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
5180 |
value = +value
|
|
5181 |
offset = offset | 0
|
|
5182 |
byteLength = byteLength | 0
|
|
5183 |
if (!noAssert) checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0)
|
|
5184 |
|
|
5185 |
var i = byteLength - 1
|
|
5186 |
var mul = 1
|
|
5187 |
this[offset + i] = value & 0xFF
|
|
5188 |
while (--i >= 0 && (mul *= 0x100)) {
|
|
5189 |
this[offset + i] = (value / mul) & 0xFF
|
|
5190 |
}
|
|
5191 |
|
|
5192 |
return offset + byteLength
|
|
5193 |
}
|
|
5194 |
|
|
5195 |
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
5196 |
value = +value
|
|
5197 |
offset = offset | 0
|
|
5198 |
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
|
|
5199 |
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
5200 |
this[offset] = (value & 0xff)
|
|
5201 |
return offset + 1
|
|
5202 |
}
|
|
5203 |
|
|
5204 |
function objectWriteUInt16 (buf, value, offset, littleEndian) {
|
|
5205 |
if (value < 0) value = 0xffff + value + 1
|
|
5206 |
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
|
|
5207 |
buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
|
5208 |
(littleEndian ? i : 1 - i) * 8
|
|
5209 |
}
|
|
5210 |
}
|
|
5211 |
|
|
5212 |
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
5213 |
value = +value
|
|
5214 |
offset = offset | 0
|
|
5215 |
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
5216 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5217 |
this[offset] = (value & 0xff)
|
|
5218 |
this[offset + 1] = (value >>> 8)
|
|
5219 |
} else {
|
|
5220 |
objectWriteUInt16(this, value, offset, true)
|
|
5221 |
}
|
|
5222 |
return offset + 2
|
|
5223 |
}
|
|
5224 |
|
|
5225 |
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
5226 |
value = +value
|
|
5227 |
offset = offset | 0
|
|
5228 |
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
|
|
5229 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5230 |
this[offset] = (value >>> 8)
|
|
5231 |
this[offset + 1] = (value & 0xff)
|
|
5232 |
} else {
|
|
5233 |
objectWriteUInt16(this, value, offset, false)
|
|
5234 |
}
|
|
5235 |
return offset + 2
|
|
5236 |
}
|
|
5237 |
|
|
5238 |
function objectWriteUInt32 (buf, value, offset, littleEndian) {
|
|
5239 |
if (value < 0) value = 0xffffffff + value + 1
|
|
5240 |
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
|
|
5241 |
buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
|
5242 |
}
|
|
5243 |
}
|
|
5244 |
|
|
5245 |
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
5246 |
value = +value
|
|
5247 |
offset = offset | 0
|
|
5248 |
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
5249 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5250 |
this[offset + 3] = (value >>> 24)
|
|
5251 |
this[offset + 2] = (value >>> 16)
|
|
5252 |
this[offset + 1] = (value >>> 8)
|
|
5253 |
this[offset] = (value & 0xff)
|
|
5254 |
} else {
|
|
5255 |
objectWriteUInt32(this, value, offset, true)
|
|
5256 |
}
|
|
5257 |
return offset + 4
|
|
5258 |
}
|
|
5259 |
|
|
5260 |
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
5261 |
value = +value
|
|
5262 |
offset = offset | 0
|
|
5263 |
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
|
|
5264 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5265 |
this[offset] = (value >>> 24)
|
|
5266 |
this[offset + 1] = (value >>> 16)
|
|
5267 |
this[offset + 2] = (value >>> 8)
|
|
5268 |
this[offset + 3] = (value & 0xff)
|
|
5269 |
} else {
|
|
5270 |
objectWriteUInt32(this, value, offset, false)
|
|
5271 |
}
|
|
5272 |
return offset + 4
|
|
5273 |
}
|
|
5274 |
|
|
5275 |
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
5276 |
value = +value
|
|
5277 |
offset = offset | 0
|
|
5278 |
if (!noAssert) {
|
|
5279 |
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
5280 |
|
|
5281 |
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
5282 |
}
|
|
5283 |
|
|
5284 |
var i = 0
|
|
5285 |
var mul = 1
|
|
5286 |
var sub = value < 0 ? 1 : 0
|
|
5287 |
this[offset] = value & 0xFF
|
|
5288 |
while (++i < byteLength && (mul *= 0x100)) {
|
|
5289 |
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
5290 |
}
|
|
5291 |
|
|
5292 |
return offset + byteLength
|
|
5293 |
}
|
|
5294 |
|
|
5295 |
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
5296 |
value = +value
|
|
5297 |
offset = offset | 0
|
|
5298 |
if (!noAssert) {
|
|
5299 |
var limit = Math.pow(2, 8 * byteLength - 1)
|
|
5300 |
|
|
5301 |
checkInt(this, value, offset, byteLength, limit - 1, -limit)
|
|
5302 |
}
|
|
5303 |
|
|
5304 |
var i = byteLength - 1
|
|
5305 |
var mul = 1
|
|
5306 |
var sub = value < 0 ? 1 : 0
|
|
5307 |
this[offset + i] = value & 0xFF
|
|
5308 |
while (--i >= 0 && (mul *= 0x100)) {
|
|
5309 |
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
|
|
5310 |
}
|
|
5311 |
|
|
5312 |
return offset + byteLength
|
|
5313 |
}
|
|
5314 |
|
|
5315 |
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
5316 |
value = +value
|
|
5317 |
offset = offset | 0
|
|
5318 |
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
|
|
5319 |
if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
|
|
5320 |
if (value < 0) value = 0xff + value + 1
|
|
5321 |
this[offset] = (value & 0xff)
|
|
5322 |
return offset + 1
|
|
5323 |
}
|
|
5324 |
|
|
5325 |
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
5326 |
value = +value
|
|
5327 |
offset = offset | 0
|
|
5328 |
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
5329 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5330 |
this[offset] = (value & 0xff)
|
|
5331 |
this[offset + 1] = (value >>> 8)
|
|
5332 |
} else {
|
|
5333 |
objectWriteUInt16(this, value, offset, true)
|
|
5334 |
}
|
|
5335 |
return offset + 2
|
|
5336 |
}
|
|
5337 |
|
|
5338 |
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
5339 |
value = +value
|
|
5340 |
offset = offset | 0
|
|
5341 |
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
|
|
5342 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5343 |
this[offset] = (value >>> 8)
|
|
5344 |
this[offset + 1] = (value & 0xff)
|
|
5345 |
} else {
|
|
5346 |
objectWriteUInt16(this, value, offset, false)
|
|
5347 |
}
|
|
5348 |
return offset + 2
|
|
5349 |
}
|
|
5350 |
|
|
5351 |
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
5352 |
value = +value
|
|
5353 |
offset = offset | 0
|
|
5354 |
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
5355 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5356 |
this[offset] = (value & 0xff)
|
|
5357 |
this[offset + 1] = (value >>> 8)
|
|
5358 |
this[offset + 2] = (value >>> 16)
|
|
5359 |
this[offset + 3] = (value >>> 24)
|
|
5360 |
} else {
|
|
5361 |
objectWriteUInt32(this, value, offset, true)
|
|
5362 |
}
|
|
5363 |
return offset + 4
|
|
5364 |
}
|
|
5365 |
|
|
5366 |
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
5367 |
value = +value
|
|
5368 |
offset = offset | 0
|
|
5369 |
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
|
|
5370 |
if (value < 0) value = 0xffffffff + value + 1
|
|
5371 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5372 |
this[offset] = (value >>> 24)
|
|
5373 |
this[offset + 1] = (value >>> 16)
|
|
5374 |
this[offset + 2] = (value >>> 8)
|
|
5375 |
this[offset + 3] = (value & 0xff)
|
|
5376 |
} else {
|
|
5377 |
objectWriteUInt32(this, value, offset, false)
|
|
5378 |
}
|
|
5379 |
return offset + 4
|
|
5380 |
}
|
|
5381 |
|
|
5382 |
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
5383 |
if (value > max || value < min) throw new RangeError('value is out of bounds')
|
|
5384 |
if (offset + ext > buf.length) throw new RangeError('index out of range')
|
|
5385 |
if (offset < 0) throw new RangeError('index out of range')
|
|
5386 |
}
|
|
5387 |
|
|
5388 |
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
5389 |
if (!noAssert) {
|
|
5390 |
checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
|
5391 |
}
|
|
5392 |
ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
|
5393 |
return offset + 4
|
|
5394 |
}
|
|
5395 |
|
|
5396 |
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
5397 |
return writeFloat(this, value, offset, true, noAssert)
|
|
5398 |
}
|
|
5399 |
|
|
5400 |
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
5401 |
return writeFloat(this, value, offset, false, noAssert)
|
|
5402 |
}
|
|
5403 |
|
|
5404 |
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
5405 |
if (!noAssert) {
|
|
5406 |
checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
|
5407 |
}
|
|
5408 |
ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
|
5409 |
return offset + 8
|
|
5410 |
}
|
|
5411 |
|
|
5412 |
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
5413 |
return writeDouble(this, value, offset, true, noAssert)
|
|
5414 |
}
|
|
5415 |
|
|
5416 |
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
5417 |
return writeDouble(this, value, offset, false, noAssert)
|
|
5418 |
}
|
|
5419 |
|
|
5420 |
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
5421 |
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
5422 |
if (!start) start = 0
|
|
5423 |
if (!end && end !== 0) end = this.length
|
|
5424 |
if (targetStart >= target.length) targetStart = target.length
|
|
5425 |
if (!targetStart) targetStart = 0
|
|
5426 |
if (end > 0 && end < start) end = start
|
|
5427 |
|
|
5428 |
// Copy 0 bytes; we're done
|
|
5429 |
if (end === start) return 0
|
|
5430 |
if (target.length === 0 || this.length === 0) return 0
|
|
5431 |
|
|
5432 |
// Fatal error conditions
|
|
5433 |
if (targetStart < 0) {
|
|
5434 |
throw new RangeError('targetStart out of bounds')
|
|
5435 |
}
|
|
5436 |
if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
|
|
5437 |
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
5438 |
|
|
5439 |
// Are we oob?
|
|
5440 |
if (end > this.length) end = this.length
|
|
5441 |
if (target.length - targetStart < end - start) {
|
|
5442 |
end = target.length - targetStart + start
|
|
5443 |
}
|
|
5444 |
|
|
5445 |
var len = end - start
|
|
5446 |
var i
|
|
5447 |
|
|
5448 |
if (this === target && start < targetStart && targetStart < end) {
|
|
5449 |
// descending copy from end
|
|
5450 |
for (i = len - 1; i >= 0; i--) {
|
|
5451 |
target[i + targetStart] = this[i + start]
|
|
5452 |
}
|
|
5453 |
} else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5454 |
// ascending copy from start
|
|
5455 |
for (i = 0; i < len; i++) {
|
|
5456 |
target[i + targetStart] = this[i + start]
|
|
5457 |
}
|
|
5458 |
} else {
|
|
5459 |
target._set(this.subarray(start, start + len), targetStart)
|
|
5460 |
}
|
|
5461 |
|
|
5462 |
return len
|
|
5463 |
}
|
|
5464 |
|
|
5465 |
// fill(value, start=0, end=buffer.length)
|
|
5466 |
Buffer.prototype.fill = function fill (value, start, end) {
|
|
5467 |
if (!value) value = 0
|
|
5468 |
if (!start) start = 0
|
|
5469 |
if (!end) end = this.length
|
|
5470 |
|
|
5471 |
if (end < start) throw new RangeError('end < start')
|
|
5472 |
|
|
5473 |
// Fill 0 bytes; we're done
|
|
5474 |
if (end === start) return
|
|
5475 |
if (this.length === 0) return
|
|
5476 |
|
|
5477 |
if (start < 0 || start >= this.length) throw new RangeError('start out of bounds')
|
|
5478 |
if (end < 0 || end > this.length) throw new RangeError('end out of bounds')
|
|
5479 |
|
|
5480 |
var i
|
|
5481 |
if (typeof value === 'number') {
|
|
5482 |
for (i = start; i < end; i++) {
|
|
5483 |
this[i] = value
|
|
5484 |
}
|
|
5485 |
} else {
|
|
5486 |
var bytes = utf8ToBytes(value.toString())
|
|
5487 |
var len = bytes.length
|
|
5488 |
for (i = start; i < end; i++) {
|
|
5489 |
this[i] = bytes[i % len]
|
|
5490 |
}
|
|
5491 |
}
|
|
5492 |
|
|
5493 |
return this
|
|
5494 |
}
|
|
5495 |
|
|
5496 |
/**
|
|
5497 |
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
|
|
5498 |
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
|
|
5499 |
*/
|
|
5500 |
Buffer.prototype.toArrayBuffer = function toArrayBuffer () {
|
|
5501 |
if (typeof Uint8Array !== 'undefined') {
|
|
5502 |
if (Buffer.TYPED_ARRAY_SUPPORT) {
|
|
5503 |
return (new Buffer(this)).buffer
|
|
5504 |
} else {
|
|
5505 |
var buf = new Uint8Array(this.length)
|
|
5506 |
for (var i = 0, len = buf.length; i < len; i += 1) {
|
|
5507 |
buf[i] = this[i]
|
|
5508 |
}
|
|
5509 |
return buf.buffer
|
|
5510 |
}
|
|
5511 |
} else {
|
|
5512 |
throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
|
|
5513 |
}
|
|
5514 |
}
|
|
5515 |
|
|
5516 |
// HELPER FUNCTIONS
|
|
5517 |
// ================
|
|
5518 |
|
|
5519 |
var BP = Buffer.prototype
|
|
5520 |
|
|
5521 |
/**
|
|
5522 |
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
|
|
5523 |
*/
|
|
5524 |
Buffer._augment = function _augment (arr) {
|
|
5525 |
arr.constructor = Buffer
|
|
5526 |
arr._isBuffer = true
|
|
5527 |
|
|
5528 |
// save reference to original Uint8Array set method before overwriting
|
|
5529 |
arr._set = arr.set
|
|
5530 |
|
|
5531 |
// deprecated
|
|
5532 |
arr.get = BP.get
|
|
5533 |
arr.set = BP.set
|
|
5534 |
|
|
5535 |
arr.write = BP.write
|
|
5536 |
arr.toString = BP.toString
|
|
5537 |
arr.toLocaleString = BP.toString
|
|
5538 |
arr.toJSON = BP.toJSON
|
|
5539 |
arr.equals = BP.equals
|
|
5540 |
arr.compare = BP.compare
|
|
5541 |
arr.indexOf = BP.indexOf
|
|
5542 |
arr.copy = BP.copy
|
|
5543 |
arr.slice = BP.slice
|
|
5544 |
arr.readUIntLE = BP.readUIntLE
|
|
5545 |
arr.readUIntBE = BP.readUIntBE
|
|
5546 |
arr.readUInt8 = BP.readUInt8
|
|
5547 |
arr.readUInt16LE = BP.readUInt16LE
|
|
5548 |
arr.readUInt16BE = BP.readUInt16BE
|
|
5549 |
arr.readUInt32LE = BP.readUInt32LE
|
|
5550 |
arr.readUInt32BE = BP.readUInt32BE
|
|
5551 |
arr.readIntLE = BP.readIntLE
|
|
5552 |
arr.readIntBE = BP.readIntBE
|
|
5553 |
arr.readInt8 = BP.readInt8
|
|
5554 |
arr.readInt16LE = BP.readInt16LE
|
|
5555 |
arr.readInt16BE = BP.readInt16BE
|
|
5556 |
arr.readInt32LE = BP.readInt32LE
|
|
5557 |
arr.readInt32BE = BP.readInt32BE
|
|
5558 |
arr.readFloatLE = BP.readFloatLE
|
|
5559 |
arr.readFloatBE = BP.readFloatBE
|
|
5560 |
arr.readDoubleLE = BP.readDoubleLE
|
|
5561 |
arr.readDoubleBE = BP.readDoubleBE
|
|
5562 |
arr.writeUInt8 = BP.writeUInt8
|
|
5563 |
arr.writeUIntLE = BP.writeUIntLE
|
|
5564 |
arr.writeUIntBE = BP.writeUIntBE
|
|
5565 |
arr.writeUInt16LE = BP.writeUInt16LE
|
|
5566 |
arr.writeUInt16BE = BP.writeUInt16BE
|
|
5567 |
arr.writeUInt32LE = BP.writeUInt32LE
|
|
5568 |
arr.writeUInt32BE = BP.writeUInt32BE
|
|
5569 |
arr.writeIntLE = BP.writeIntLE
|
|
5570 |
arr.writeIntBE = BP.writeIntBE
|
|
5571 |
arr.writeInt8 = BP.writeInt8
|
|
5572 |
arr.writeInt16LE = BP.writeInt16LE
|
|
5573 |
arr.writeInt16BE = BP.writeInt16BE
|
|
5574 |
arr.writeInt32LE = BP.writeInt32LE
|
|
5575 |
arr.writeInt32BE = BP.writeInt32BE
|
|
5576 |
arr.writeFloatLE = BP.writeFloatLE
|
|
5577 |
arr.writeFloatBE = BP.writeFloatBE
|
|
5578 |
arr.writeDoubleLE = BP.writeDoubleLE
|
|
5579 |
arr.writeDoubleBE = BP.writeDoubleBE
|
|
5580 |
arr.fill = BP.fill
|
|
5581 |
arr.inspect = BP.inspect
|
|
5582 |
arr.toArrayBuffer = BP.toArrayBuffer
|
|
5583 |
|
|
5584 |
return arr
|
|
5585 |
}
|
|
5586 |
|
|
5587 |
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
|
|
5588 |
|
|
5589 |
function base64clean (str) {
|
|
5590 |
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
5591 |
str = stringtrim(str).replace(INVALID_BASE64_RE, '')
|
|
5592 |
// Node converts strings with length < 2 to ''
|
|
5593 |
if (str.length < 2) return ''
|
|
5594 |
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
5595 |
while (str.length % 4 !== 0) {
|
|
5596 |
str = str + '='
|
|
5597 |
}
|
|
5598 |
return str
|
|
5599 |
}
|
|
5600 |
|
|
5601 |
function stringtrim (str) {
|
|
5602 |
if (str.trim) return str.trim()
|
|
5603 |
return str.replace(/^\s+|\s+$/g, '')
|
|
5604 |
}
|
|
5605 |
|
|
5606 |
function toHex (n) {
|
|
5607 |
if (n < 16) return '0' + n.toString(16)
|
|
5608 |
return n.toString(16)
|
|
5609 |
}
|
|
5610 |
|
|
5611 |
function utf8ToBytes (string, units) {
|
|
5612 |
units = units || Infinity
|
|
5613 |
var codePoint
|
|
5614 |
var length = string.length
|
|
5615 |
var leadSurrogate = null
|
|
5616 |
var bytes = []
|
|
5617 |
|
|
5618 |
for (var i = 0; i < length; i++) {
|
|
5619 |
codePoint = string.charCodeAt(i)
|
|
5620 |
|
|
5621 |
// is surrogate component
|
|
5622 |
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
5623 |
// last char was a lead
|
|
5624 |
if (!leadSurrogate) {
|
|
5625 |
// no lead yet
|
|
5626 |
if (codePoint > 0xDBFF) {
|
|
5627 |
// unexpected trail
|
|
5628 |
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
5629 |
continue
|
|
5630 |
} else if (i + 1 === length) {
|
|
5631 |
// unpaired lead
|
|
5632 |
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
5633 |
continue
|
|
5634 |
}
|
|
5635 |
|
|
5636 |
// valid lead
|
|
5637 |
leadSurrogate = codePoint
|
|
5638 |
|
|
5639 |
continue
|
|
5640 |
}
|
|
5641 |
|
|
5642 |
// 2 leads in a row
|
|
5643 |
if (codePoint < 0xDC00) {
|
|
5644 |
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
5645 |
leadSurrogate = codePoint
|
|
5646 |
continue
|
|
5647 |
}
|
|
5648 |
|
|
5649 |
// valid surrogate pair
|
|
5650 |
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
|
|
5651 |
} else if (leadSurrogate) {
|
|
5652 |
// valid bmp char, but last char was a lead
|
|
5653 |
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
|
|
5654 |
}
|
|
5655 |
|
|
5656 |
leadSurrogate = null
|
|
5657 |
|
|
5658 |
// encode utf8
|
|
5659 |
if (codePoint < 0x80) {
|
|
5660 |
if ((units -= 1) < 0) break
|
|
5661 |
bytes.push(codePoint)
|
|
5662 |
} else if (codePoint < 0x800) {
|
|
5663 |
if ((units -= 2) < 0) break
|
|
5664 |
bytes.push(
|
|
5665 |
codePoint >> 0x6 | 0xC0,
|
|
5666 |
codePoint & 0x3F | 0x80
|
|
5667 |
)
|
|
5668 |
} else if (codePoint < 0x10000) {
|
|
5669 |
if ((units -= 3) < 0) break
|
|
5670 |
bytes.push(
|
|
5671 |
codePoint >> 0xC | 0xE0,
|
|
5672 |
codePoint >> 0x6 & 0x3F | 0x80,
|
|
5673 |
codePoint & 0x3F | 0x80
|
|
5674 |
)
|
|
5675 |
} else if (codePoint < 0x110000) {
|
|
5676 |
if ((units -= 4) < 0) break
|
|
5677 |
bytes.push(
|
|
5678 |
codePoint >> 0x12 | 0xF0,
|
|
5679 |
codePoint >> 0xC & 0x3F | 0x80,
|
|
5680 |
codePoint >> 0x6 & 0x3F | 0x80,
|
|
5681 |
codePoint & 0x3F | 0x80
|
|
5682 |
)
|
|
5683 |
} else {
|
|
5684 |
throw new Error('Invalid code point')
|
|
5685 |
}
|
|
5686 |
}
|
|
5687 |
|
|
5688 |
return bytes
|
|
5689 |
}
|
|
5690 |
|
|
5691 |
function asciiToBytes (str) {
|
|
5692 |
var byteArray = []
|
|
5693 |
for (var i = 0; i < str.length; i++) {
|
|
5694 |
// Node's code seems to be doing this and not & 0x7F..
|
|
5695 |
byteArray.push(str.charCodeAt(i) & 0xFF)
|
|
5696 |
}
|
|
5697 |
return byteArray
|
|
5698 |
}
|
|
5699 |
|
|
5700 |
function utf16leToBytes (str, units) {
|
|
5701 |
var c, hi, lo
|
|
5702 |
var byteArray = []
|
|
5703 |
for (var i = 0; i < str.length; i++) {
|
|
5704 |
if ((units -= 2) < 0) break
|
|
5705 |
|
|
5706 |
c = str.charCodeAt(i)
|
|
5707 |
hi = c >> 8
|
|
5708 |
lo = c % 256
|
|
5709 |
byteArray.push(lo)
|
|
5710 |
byteArray.push(hi)
|
|
5711 |
}
|
|
5712 |
|
|
5713 |
return byteArray
|
|
5714 |
}
|
|
5715 |
|
|
5716 |
function base64ToBytes (str) {
|
|
5717 |
return base64.toByteArray(base64clean(str))
|
|
5718 |
}
|
|
5719 |
|
|
5720 |
function blitBuffer (src, dst, offset, length) {
|
|
5721 |
for (var i = 0; i < length; i++) {
|
|
5722 |
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
5723 |
dst[i + offset] = src[i]
|
|
5724 |
}
|
|
5725 |
return i
|
|
5726 |
}
|
|
5727 |
|
|
5728 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(23).Buffer, (function() { return this; }())))
|
|
5729 |
|
|
5730 |
/***/ },
|
|
5731 |
/* 24 */
|
|
5732 |
/***/ function(module, exports, __webpack_require__) {
|
|
5733 |
|
|
5734 |
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
5735 |
|
|
5736 |
;(function (exports) {
|
|
5737 |
'use strict';
|
|
5738 |
|
|
5739 |
var Arr = (typeof Uint8Array !== 'undefined')
|
|
5740 |
? Uint8Array
|
|
5741 |
: Array
|
|
5742 |
|
|
5743 |
var PLUS = '+'.charCodeAt(0)
|
|
5744 |
var SLASH = '/'.charCodeAt(0)
|
|
5745 |
var NUMBER = '0'.charCodeAt(0)
|
|
5746 |
var LOWER = 'a'.charCodeAt(0)
|
|
5747 |
var UPPER = 'A'.charCodeAt(0)
|
|
5748 |
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
|
5749 |
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
|
5750 |
|
|
5751 |
function decode (elt) {
|
|
5752 |
var code = elt.charCodeAt(0)
|
|
5753 |
if (code === PLUS ||
|
|
5754 |
code === PLUS_URL_SAFE)
|
|
5755 |
return 62 // '+'
|
|
5756 |
if (code === SLASH ||
|
|
5757 |
code === SLASH_URL_SAFE)
|
|
5758 |
return 63 // '/'
|
|
5759 |
if (code < NUMBER)
|
|
5760 |
return -1 //no match
|
|
5761 |
if (code < NUMBER + 10)
|
|
5762 |
return code - NUMBER + 26 + 26
|
|
5763 |
if (code < UPPER + 26)
|
|
5764 |
return code - UPPER
|
|
5765 |
if (code < LOWER + 26)
|
|
5766 |
return code - LOWER + 26
|
|
5767 |
}
|
|
5768 |
|
|
5769 |
function b64ToByteArray (b64) {
|
|
5770 |
var i, j, l, tmp, placeHolders, arr
|
|
5771 |
|
|
5772 |
if (b64.length % 4 > 0) {
|
|
5773 |
throw new Error('Invalid string. Length must be a multiple of 4')
|
|
5774 |
}
|
|
5775 |
|
|
5776 |
// the number of equal signs (place holders)
|
|
5777 |
// if there are two placeholders, than the two characters before it
|
|
5778 |
// represent one byte
|
|
5779 |
// if there is only one, then the three characters before it represent 2 bytes
|
|
5780 |
// this is just a cheap hack to not do indexOf twice
|
|
5781 |
var len = b64.length
|
|
5782 |
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
|
5783 |
|
|
5784 |
// base64 is 4/3 + up to two characters of the original data
|
|
5785 |
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
|
5786 |
|
|
5787 |
// if there are placeholders, only get up to the last complete 4 chars
|
|
5788 |
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
|
5789 |
|
|
5790 |
var L = 0
|
|
5791 |
|
|
5792 |
function push (v) {
|
|
5793 |
arr[L++] = v
|
|
5794 |
}
|
|
5795 |
|
|
5796 |
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
5797 |
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
|
5798 |
push((tmp & 0xFF0000) >> 16)
|
|
5799 |
push((tmp & 0xFF00) >> 8)
|
|
5800 |
push(tmp & 0xFF)
|
|
5801 |
}
|
|
5802 |
|
|
5803 |
if (placeHolders === 2) {
|
|
5804 |
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
|
5805 |
push(tmp & 0xFF)
|
|
5806 |
} else if (placeHolders === 1) {
|
|
5807 |
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
|
5808 |
push((tmp >> 8) & 0xFF)
|
|
5809 |
push(tmp & 0xFF)
|
|
5810 |
}
|
|
5811 |
|
|
5812 |
return arr
|
|
5813 |
}
|
|
5814 |
|
|
5815 |
function uint8ToBase64 (uint8) {
|
|
5816 |
var i,
|
|
5817 |
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
|
5818 |
output = "",
|
|
5819 |
temp, length
|
|
5820 |
|
|
5821 |
function encode (num) {
|
|
5822 |
return lookup.charAt(num)
|
|
5823 |
}
|
|
5824 |
|
|
5825 |
function tripletToBase64 (num) {
|
|
5826 |
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
|
5827 |
}
|
|
5828 |
|
|
5829 |
// go through the array every three bytes, we'll deal with trailing stuff later
|
|
5830 |
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
|
5831 |
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
|
5832 |
output += tripletToBase64(temp)
|
|
5833 |
}
|
|
5834 |
|
|
5835 |
// pad the end with zeros, but make sure to not forget the extra bytes
|
|
5836 |
switch (extraBytes) {
|
|
5837 |
case 1:
|
|
5838 |
temp = uint8[uint8.length - 1]
|
|
5839 |
output += encode(temp >> 2)
|
|
5840 |
output += encode((temp << 4) & 0x3F)
|
|
5841 |
output += '=='
|
|
5842 |
break
|
|
5843 |
case 2:
|
|
5844 |
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
|
5845 |
output += encode(temp >> 10)
|
|
5846 |
output += encode((temp >> 4) & 0x3F)
|
|
5847 |
output += encode((temp << 2) & 0x3F)
|
|
5848 |
output += '='
|
|
5849 |
break
|
|
5850 |
}
|
|
5851 |
|
|
5852 |
return output
|
|
5853 |
}
|
|
5854 |
|
|
5855 |
exports.toByteArray = b64ToByteArray
|
|
5856 |
exports.fromByteArray = uint8ToBase64
|
|
5857 |
}( false ? (this.base64js = {}) : exports))
|
|
5858 |
|
|
5859 |
|
|
5860 |
/***/ },
|
|
5861 |
/* 25 */
|
|
5862 |
/***/ function(module, exports) {
|
|
5863 |
|
|
5864 |
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
|
5865 |
var e, m
|
|
5866 |
var eLen = nBytes * 8 - mLen - 1
|
|
5867 |
var eMax = (1 << eLen) - 1
|
|
5868 |
var eBias = eMax >> 1
|
|
5869 |
var nBits = -7
|
|
5870 |
var i = isLE ? (nBytes - 1) : 0
|
|
5871 |
var d = isLE ? -1 : 1
|
|
5872 |
var s = buffer[offset + i]
|
|
5873 |
|
|
5874 |
i += d
|
|
5875 |
|
|
5876 |
e = s & ((1 << (-nBits)) - 1)
|
|
5877 |
s >>= (-nBits)
|
|
5878 |
nBits += eLen
|
|
5879 |
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
5880 |
|
|
5881 |
m = e & ((1 << (-nBits)) - 1)
|
|
5882 |
e >>= (-nBits)
|
|
5883 |
nBits += mLen
|
|
5884 |
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
|
|
5885 |
|
|
5886 |
if (e === 0) {
|
|
5887 |
e = 1 - eBias
|
|
5888 |
} else if (e === eMax) {
|
|
5889 |
return m ? NaN : ((s ? -1 : 1) * Infinity)
|
|
5890 |
} else {
|
|
5891 |
m = m + Math.pow(2, mLen)
|
|
5892 |
e = e - eBias
|
|
5893 |
}
|
|
5894 |
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
|
5895 |
}
|
|
5896 |
|
|
5897 |
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
|
5898 |
var e, m, c
|
|
5899 |
var eLen = nBytes * 8 - mLen - 1
|
|
5900 |
var eMax = (1 << eLen) - 1
|
|
5901 |
var eBias = eMax >> 1
|
|
5902 |
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
|
5903 |
var i = isLE ? 0 : (nBytes - 1)
|
|
5904 |
var d = isLE ? 1 : -1
|
|
5905 |
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
|
5906 |
|
|
5907 |
value = Math.abs(value)
|
|
5908 |
|
|
5909 |
if (isNaN(value) || value === Infinity) {
|
|
5910 |
m = isNaN(value) ? 1 : 0
|
|
5911 |
e = eMax
|
|
5912 |
} else {
|
|
5913 |
e = Math.floor(Math.log(value) / Math.LN2)
|
|
5914 |
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
5915 |
e--
|
|
5916 |
c *= 2
|
|
5917 |
}
|
|
5918 |
if (e + eBias >= 1) {
|
|
5919 |
value += rt / c
|
|
5920 |
} else {
|
|
5921 |
value += rt * Math.pow(2, 1 - eBias)
|
|
5922 |
}
|
|
5923 |
if (value * c >= 2) {
|
|
5924 |
e++
|
|
5925 |
c /= 2
|
|
5926 |
}
|
|
5927 |
|
|
5928 |
if (e + eBias >= eMax) {
|
|
5929 |
m = 0
|
|
5930 |
e = eMax
|
|
5931 |
} else if (e + eBias >= 1) {
|
|
5932 |
m = (value * c - 1) * Math.pow(2, mLen)
|
|
5933 |
e = e + eBias
|
|
5934 |
} else {
|
|
5935 |
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
|
5936 |
e = 0
|
|
5937 |
}
|
|
5938 |
}
|
|
5939 |
|
|
5940 |
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
|
5941 |
|
|
5942 |
e = (e << mLen) | m
|
|
5943 |
eLen += mLen
|
|
5944 |
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
|
5945 |
|
|
5946 |
buffer[offset + i - d] |= s * 128
|
|
5947 |
}
|
|
5948 |
|
|
5949 |
|
|
5950 |
/***/ },
|
|
5951 |
/* 26 */
|
|
5952 |
/***/ function(module, exports) {
|
|
5953 |
|
|
5954 |
var toString = {}.toString;
|
|
5955 |
|
|
5956 |
module.exports = Array.isArray || function (arr) {
|
|
5957 |
return toString.call(arr) == '[object Array]';
|
|
5958 |
};
|
|
5959 |
|
|
5960 |
|
|
5961 |
/***/ },
|
|
5962 |
/* 27 */
|
|
5963 |
/***/ function(module, exports, __webpack_require__) {
|
|
5964 |
|
|
5965 |
/* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
|
|
5966 |
//
|
|
5967 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
5968 |
// copy of this software and associated documentation files (the
|
|
5969 |
// "Software"), to deal in the Software without restriction, including
|
|
5970 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
5971 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
5972 |
// persons to whom the Software is furnished to do so, subject to the
|
|
5973 |
// following conditions:
|
|
5974 |
//
|
|
5975 |
// The above copyright notice and this permission notice shall be included
|
|
5976 |
// in all copies or substantial portions of the Software.
|
|
5977 |
//
|
|
5978 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
5979 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
5980 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
5981 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
5982 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
5983 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
5984 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
5985 |
|
|
5986 |
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
5987 |
// because it is fragile and can be easily faked with `Object.create()`.
|
|
5988 |
|
|
5989 |
function isArray(arg) {
|
|
5990 |
if (Array.isArray) {
|
|
5991 |
return Array.isArray(arg);
|
|
5992 |
}
|
|
5993 |
return objectToString(arg) === '[object Array]';
|
|
5994 |
}
|
|
5995 |
exports.isArray = isArray;
|
|
5996 |
|
|
5997 |
function isBoolean(arg) {
|
|
5998 |
return typeof arg === 'boolean';
|
|
5999 |
}
|
|
6000 |
exports.isBoolean = isBoolean;
|
|
6001 |
|
|
6002 |
function isNull(arg) {
|
|
6003 |
return arg === null;
|
|
6004 |
}
|
|
6005 |
exports.isNull = isNull;
|
|
6006 |
|
|
6007 |
function isNullOrUndefined(arg) {
|
|
6008 |
return arg == null;
|
|
6009 |
}
|
|
6010 |
exports.isNullOrUndefined = isNullOrUndefined;
|
|
6011 |
|
|
6012 |
function isNumber(arg) {
|
|
6013 |
return typeof arg === 'number';
|
|
6014 |
}
|
|
6015 |
exports.isNumber = isNumber;
|
|
6016 |
|
|
6017 |
function isString(arg) {
|
|
6018 |
return typeof arg === 'string';
|
|
6019 |
}
|
|
6020 |
exports.isString = isString;
|
|
6021 |
|
|
6022 |
function isSymbol(arg) {
|
|
6023 |
return typeof arg === 'symbol';
|
|
6024 |
}
|
|
6025 |
exports.isSymbol = isSymbol;
|
|
6026 |
|
|
6027 |
function isUndefined(arg) {
|
|
6028 |
return arg === void 0;
|
|
6029 |
}
|
|
6030 |
exports.isUndefined = isUndefined;
|
|
6031 |
|
|
6032 |
function isRegExp(re) {
|
|
6033 |
return objectToString(re) === '[object RegExp]';
|
|
6034 |
}
|
|
6035 |
exports.isRegExp = isRegExp;
|
|
6036 |
|
|
6037 |
function isObject(arg) {
|
|
6038 |
return typeof arg === 'object' && arg !== null;
|
|
6039 |
}
|
|
6040 |
exports.isObject = isObject;
|
|
6041 |
|
|
6042 |
function isDate(d) {
|
|
6043 |
return objectToString(d) === '[object Date]';
|
|
6044 |
}
|
|
6045 |
exports.isDate = isDate;
|
|
6046 |
|
|
6047 |
function isError(e) {
|
|
6048 |
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
|
6049 |
}
|
|
6050 |
exports.isError = isError;
|
|
6051 |
|
|
6052 |
function isFunction(arg) {
|
|
6053 |
return typeof arg === 'function';
|
|
6054 |
}
|
|
6055 |
exports.isFunction = isFunction;
|
|
6056 |
|
|
6057 |
function isPrimitive(arg) {
|
|
6058 |
return arg === null ||
|
|
6059 |
typeof arg === 'boolean' ||
|
|
6060 |
typeof arg === 'number' ||
|
|
6061 |
typeof arg === 'string' ||
|
|
6062 |
typeof arg === 'symbol' || // ES6 symbol
|
|
6063 |
typeof arg === 'undefined';
|
|
6064 |
}
|
|
6065 |
exports.isPrimitive = isPrimitive;
|
|
6066 |
|
|
6067 |
exports.isBuffer = Buffer.isBuffer;
|
|
6068 |
|
|
6069 |
function objectToString(o) {
|
|
6070 |
return Object.prototype.toString.call(o);
|
|
6071 |
}
|
|
6072 |
|
|
6073 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(23).Buffer))
|
|
6074 |
|
|
6075 |
/***/ },
|
|
6076 |
/* 28 */
|
|
6077 |
/***/ function(module, exports) {
|
|
6078 |
|
|
6079 |
/* (ignored) */
|
|
6080 |
|
|
6081 |
/***/ },
|
|
6082 |
/* 29 */
|
|
6083 |
/***/ function(module, exports, __webpack_require__) {
|
|
6084 |
|
|
6085 |
/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
|
|
6086 |
//
|
|
6087 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6088 |
// copy of this software and associated documentation files (the
|
|
6089 |
// "Software"), to deal in the Software without restriction, including
|
|
6090 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
6091 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
6092 |
// persons to whom the Software is furnished to do so, subject to the
|
|
6093 |
// following conditions:
|
|
6094 |
//
|
|
6095 |
// The above copyright notice and this permission notice shall be included
|
|
6096 |
// in all copies or substantial portions of the Software.
|
|
6097 |
//
|
|
6098 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
6099 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
6100 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
6101 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
6102 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
6103 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
6104 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
6105 |
|
|
6106 |
// a duplex stream is just a stream that is both readable and writable.
|
|
6107 |
// Since JS doesn't have multiple prototypal inheritance, this class
|
|
6108 |
// prototypally inherits from Readable, and then parasitically from
|
|
6109 |
// Writable.
|
|
6110 |
|
|
6111 |
module.exports = Duplex;
|
|
6112 |
|
|
6113 |
/*<replacement>*/
|
|
6114 |
var objectKeys = Object.keys || function (obj) {
|
|
6115 |
var keys = [];
|
|
6116 |
for (var key in obj) keys.push(key);
|
|
6117 |
return keys;
|
|
6118 |
}
|
|
6119 |
/*</replacement>*/
|
|
6120 |
|
|
6121 |
|
|
6122 |
/*<replacement>*/
|
|
6123 |
var util = __webpack_require__(27);
|
|
6124 |
util.inherits = __webpack_require__(19);
|
|
6125 |
/*</replacement>*/
|
|
6126 |
|
|
6127 |
var Readable = __webpack_require__(21);
|
|
6128 |
var Writable = __webpack_require__(30);
|
|
6129 |
|
|
6130 |
util.inherits(Duplex, Readable);
|
|
6131 |
|
|
6132 |
forEach(objectKeys(Writable.prototype), function(method) {
|
|
6133 |
if (!Duplex.prototype[method])
|
|
6134 |
Duplex.prototype[method] = Writable.prototype[method];
|
|
6135 |
});
|
|
6136 |
|
|
6137 |
function Duplex(options) {
|
|
6138 |
if (!(this instanceof Duplex))
|
|
6139 |
return new Duplex(options);
|
|
6140 |
|
|
6141 |
Readable.call(this, options);
|
|
6142 |
Writable.call(this, options);
|
|
6143 |
|
|
6144 |
if (options && options.readable === false)
|
|
6145 |
this.readable = false;
|
|
6146 |
|
|
6147 |
if (options && options.writable === false)
|
|
6148 |
this.writable = false;
|
|
6149 |
|
|
6150 |
this.allowHalfOpen = true;
|
|
6151 |
if (options && options.allowHalfOpen === false)
|
|
6152 |
this.allowHalfOpen = false;
|
|
6153 |
|
|
6154 |
this.once('end', onend);
|
|
6155 |
}
|
|
6156 |
|
|
6157 |
// the no-half-open enforcer
|
|
6158 |
function onend() {
|
|
6159 |
// if we allow half-open state, or if the writable side ended,
|
|
6160 |
// then we're ok.
|
|
6161 |
if (this.allowHalfOpen || this._writableState.ended)
|
|
6162 |
return;
|
|
6163 |
|
|
6164 |
// no more data can be written.
|
|
6165 |
// But allow more writes to happen in this tick.
|
|
6166 |
process.nextTick(this.end.bind(this));
|
|
6167 |
}
|
|
6168 |
|
|
6169 |
function forEach (xs, f) {
|
|
6170 |
for (var i = 0, l = xs.length; i < l; i++) {
|
|
6171 |
f(xs[i], i);
|
|
6172 |
}
|
|
6173 |
}
|
|
6174 |
|
|
6175 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
|
|
6176 |
|
|
6177 |
/***/ },
|
|
6178 |
/* 30 */
|
|
6179 |
/***/ function(module, exports, __webpack_require__) {
|
|
6180 |
|
|
6181 |
/* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors.
|
|
6182 |
//
|
|
6183 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6184 |
// copy of this software and associated documentation files (the
|
|
6185 |
// "Software"), to deal in the Software without restriction, including
|
|
6186 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
6187 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
6188 |
// persons to whom the Software is furnished to do so, subject to the
|
|
6189 |
// following conditions:
|
|
6190 |
//
|
|
6191 |
// The above copyright notice and this permission notice shall be included
|
|
6192 |
// in all copies or substantial portions of the Software.
|
|
6193 |
//
|
|
6194 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
6195 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
6196 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
6197 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
6198 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
6199 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
6200 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
6201 |
|
|
6202 |
// A bit simpler than readable streams.
|
|
6203 |
// Implement an async ._write(chunk, cb), and it'll handle all
|
|
6204 |
// the drain event emission and buffering.
|
|
6205 |
|
|
6206 |
module.exports = Writable;
|
|
6207 |
|
|
6208 |
/*<replacement>*/
|
|
6209 |
var Buffer = __webpack_require__(23).Buffer;
|
|
6210 |
/*</replacement>*/
|
|
6211 |
|
|
6212 |
Writable.WritableState = WritableState;
|
|
6213 |
|
|
6214 |
|
|
6215 |
/*<replacement>*/
|
|
6216 |
var util = __webpack_require__(27);
|
|
6217 |
util.inherits = __webpack_require__(19);
|
|
6218 |
/*</replacement>*/
|
|
6219 |
|
|
6220 |
var Stream = __webpack_require__(18);
|
|
6221 |
|
|
6222 |
util.inherits(Writable, Stream);
|
|
6223 |
|
|
6224 |
function WriteReq(chunk, encoding, cb) {
|
|
6225 |
this.chunk = chunk;
|
|
6226 |
this.encoding = encoding;
|
|
6227 |
this.callback = cb;
|
|
6228 |
}
|
|
6229 |
|
|
6230 |
function WritableState(options, stream) {
|
|
6231 |
var Duplex = __webpack_require__(29);
|
|
6232 |
|
|
6233 |
options = options || {};
|
|
6234 |
|
|
6235 |
// the point at which write() starts returning false
|
|
6236 |
// Note: 0 is a valid value, means that we always return false if
|
|
6237 |
// the entire buffer is not flushed immediately on write()
|
|
6238 |
var hwm = options.highWaterMark;
|
|
6239 |
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
|
6240 |
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
|
6241 |
|
|
6242 |
// object stream flag to indicate whether or not this stream
|
|
6243 |
// contains buffers or objects.
|
|
6244 |
this.objectMode = !!options.objectMode;
|
|
6245 |
|
|
6246 |
if (stream instanceof Duplex)
|
|
6247 |
this.objectMode = this.objectMode || !!options.writableObjectMode;
|
|
6248 |
|
|
6249 |
// cast to ints.
|
|
6250 |
this.highWaterMark = ~~this.highWaterMark;
|
|
6251 |
|
|
6252 |
this.needDrain = false;
|
|
6253 |
// at the start of calling end()
|
|
6254 |
this.ending = false;
|
|
6255 |
// when end() has been called, and returned
|
|
6256 |
this.ended = false;
|
|
6257 |
// when 'finish' is emitted
|
|
6258 |
this.finished = false;
|
|
6259 |
|
|
6260 |
// should we decode strings into buffers before passing to _write?
|
|
6261 |
// this is here so that some node-core streams can optimize string
|
|
6262 |
// handling at a lower level.
|
|
6263 |
var noDecode = options.decodeStrings === false;
|
|
6264 |
this.decodeStrings = !noDecode;
|
|
6265 |
|
|
6266 |
// Crypto is kind of old and crusty. Historically, its default string
|
|
6267 |
// encoding is 'binary' so we have to make this configurable.
|
|
6268 |
// Everything else in the universe uses 'utf8', though.
|
|
6269 |
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
|
6270 |
|
|
6271 |
// not an actual buffer we keep track of, but a measurement
|
|
6272 |
// of how much we're waiting to get pushed to some underlying
|
|
6273 |
// socket or file.
|
|
6274 |
this.length = 0;
|
|
6275 |
|
|
6276 |
// a flag to see when we're in the middle of a write.
|
|
6277 |
this.writing = false;
|
|
6278 |
|
|
6279 |
// when true all writes will be buffered until .uncork() call
|
|
6280 |
this.corked = 0;
|
|
6281 |
|
|
6282 |
// a flag to be able to tell if the onwrite cb is called immediately,
|
|
6283 |
// or on a later tick. We set this to true at first, because any
|
|
6284 |
// actions that shouldn't happen until "later" should generally also
|
|
6285 |
// not happen before the first write call.
|
|
6286 |
this.sync = true;
|
|
6287 |
|
|
6288 |
// a flag to know if we're processing previously buffered items, which
|
|
6289 |
// may call the _write() callback in the same tick, so that we don't
|
|
6290 |
// end up in an overlapped onwrite situation.
|
|
6291 |
this.bufferProcessing = false;
|
|
6292 |
|
|
6293 |
// the callback that's passed to _write(chunk,cb)
|
|
6294 |
this.onwrite = function(er) {
|
|
6295 |
onwrite(stream, er);
|
|
6296 |
};
|
|
6297 |
|
|
6298 |
// the callback that the user supplies to write(chunk,encoding,cb)
|
|
6299 |
this.writecb = null;
|
|
6300 |
|
|
6301 |
// the amount that is being written when _write is called.
|
|
6302 |
this.writelen = 0;
|
|
6303 |
|
|
6304 |
this.buffer = [];
|
|
6305 |
|
|
6306 |
// number of pending user-supplied write callbacks
|
|
6307 |
// this must be 0 before 'finish' can be emitted
|
|
6308 |
this.pendingcb = 0;
|
|
6309 |
|
|
6310 |
// emit prefinish if the only thing we're waiting for is _write cbs
|
|
6311 |
// This is relevant for synchronous Transform streams
|
|
6312 |
this.prefinished = false;
|
|
6313 |
|
|
6314 |
// True if the error was already emitted and should not be thrown again
|
|
6315 |
this.errorEmitted = false;
|
|
6316 |
}
|
|
6317 |
|
|
6318 |
function Writable(options) {
|
|
6319 |
var Duplex = __webpack_require__(29);
|
|
6320 |
|
|
6321 |
// Writable ctor is applied to Duplexes, though they're not
|
|
6322 |
// instanceof Writable, they're instanceof Readable.
|
|
6323 |
if (!(this instanceof Writable) && !(this instanceof Duplex))
|
|
6324 |
return new Writable(options);
|
|
6325 |
|
|
6326 |
this._writableState = new WritableState(options, this);
|
|
6327 |
|
|
6328 |
// legacy.
|
|
6329 |
this.writable = true;
|
|
6330 |
|
|
6331 |
Stream.call(this);
|
|
6332 |
}
|
|
6333 |
|
|
6334 |
// Otherwise people can pipe Writable streams, which is just wrong.
|
|
6335 |
Writable.prototype.pipe = function() {
|
|
6336 |
this.emit('error', new Error('Cannot pipe. Not readable.'));
|
|
6337 |
};
|
|
6338 |
|
|
6339 |
|
|
6340 |
function writeAfterEnd(stream, state, cb) {
|
|
6341 |
var er = new Error('write after end');
|
|
6342 |
// TODO: defer error events consistently everywhere, not just the cb
|
|
6343 |
stream.emit('error', er);
|
|
6344 |
process.nextTick(function() {
|
|
6345 |
cb(er);
|
|
6346 |
});
|
|
6347 |
}
|
|
6348 |
|
|
6349 |
// If we get something that is not a buffer, string, null, or undefined,
|
|
6350 |
// and we're not in objectMode, then that's an error.
|
|
6351 |
// Otherwise stream chunks are all considered to be of length=1, and the
|
|
6352 |
// watermarks determine how many objects to keep in the buffer, rather than
|
|
6353 |
// how many bytes or characters.
|
|
6354 |
function validChunk(stream, state, chunk, cb) {
|
|
6355 |
var valid = true;
|
|
6356 |
if (!util.isBuffer(chunk) &&
|
|
6357 |
!util.isString(chunk) &&
|
|
6358 |
!util.isNullOrUndefined(chunk) &&
|
|
6359 |
!state.objectMode) {
|
|
6360 |
var er = new TypeError('Invalid non-string/buffer chunk');
|
|
6361 |
stream.emit('error', er);
|
|
6362 |
process.nextTick(function() {
|
|
6363 |
cb(er);
|
|
6364 |
});
|
|
6365 |
valid = false;
|
|
6366 |
}
|
|
6367 |
return valid;
|
|
6368 |
}
|
|
6369 |
|
|
6370 |
Writable.prototype.write = function(chunk, encoding, cb) {
|
|
6371 |
var state = this._writableState;
|
|
6372 |
var ret = false;
|
|
6373 |
|
|
6374 |
if (util.isFunction(encoding)) {
|
|
6375 |
cb = encoding;
|
|
6376 |
encoding = null;
|
|
6377 |
}
|
|
6378 |
|
|
6379 |
if (util.isBuffer(chunk))
|
|
6380 |
encoding = 'buffer';
|
|
6381 |
else if (!encoding)
|
|
6382 |
encoding = state.defaultEncoding;
|
|
6383 |
|
|
6384 |
if (!util.isFunction(cb))
|
|
6385 |
cb = function() {};
|
|
6386 |
|
|
6387 |
if (state.ended)
|
|
6388 |
writeAfterEnd(this, state, cb);
|
|
6389 |
else if (validChunk(this, state, chunk, cb)) {
|
|
6390 |
state.pendingcb++;
|
|
6391 |
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
|
6392 |
}
|
|
6393 |
|
|
6394 |
return ret;
|
|
6395 |
};
|
|
6396 |
|
|
6397 |
Writable.prototype.cork = function() {
|
|
6398 |
var state = this._writableState;
|
|
6399 |
|
|
6400 |
state.corked++;
|
|
6401 |
};
|
|
6402 |
|
|
6403 |
Writable.prototype.uncork = function() {
|
|
6404 |
var state = this._writableState;
|
|
6405 |
|
|
6406 |
if (state.corked) {
|
|
6407 |
state.corked--;
|
|
6408 |
|
|
6409 |
if (!state.writing &&
|
|
6410 |
!state.corked &&
|
|
6411 |
!state.finished &&
|
|
6412 |
!state.bufferProcessing &&
|
|
6413 |
state.buffer.length)
|
|
6414 |
clearBuffer(this, state);
|
|
6415 |
}
|
|
6416 |
};
|
|
6417 |
|
|
6418 |
function decodeChunk(state, chunk, encoding) {
|
|
6419 |
if (!state.objectMode &&
|
|
6420 |
state.decodeStrings !== false &&
|
|
6421 |
util.isString(chunk)) {
|
|
6422 |
chunk = new Buffer(chunk, encoding);
|
|
6423 |
}
|
|
6424 |
return chunk;
|
|
6425 |
}
|
|
6426 |
|
|
6427 |
// if we're already writing something, then just put this
|
|
6428 |
// in the queue, and wait our turn. Otherwise, call _write
|
|
6429 |
// If we return false, then we need a drain event, so set that flag.
|
|
6430 |
function writeOrBuffer(stream, state, chunk, encoding, cb) {
|
|
6431 |
chunk = decodeChunk(state, chunk, encoding);
|
|
6432 |
if (util.isBuffer(chunk))
|
|
6433 |
encoding = 'buffer';
|
|
6434 |
var len = state.objectMode ? 1 : chunk.length;
|
|
6435 |
|
|
6436 |
state.length += len;
|
|
6437 |
|
|
6438 |
var ret = state.length < state.highWaterMark;
|
|
6439 |
// we must ensure that previous needDrain will not be reset to false.
|
|
6440 |
if (!ret)
|
|
6441 |
state.needDrain = true;
|
|
6442 |
|
|
6443 |
if (state.writing || state.corked)
|
|
6444 |
state.buffer.push(new WriteReq(chunk, encoding, cb));
|
|
6445 |
else
|
|
6446 |
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
6447 |
|
|
6448 |
return ret;
|
|
6449 |
}
|
|
6450 |
|
|
6451 |
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
|
6452 |
state.writelen = len;
|
|
6453 |
state.writecb = cb;
|
|
6454 |
state.writing = true;
|
|
6455 |
state.sync = true;
|
|
6456 |
if (writev)
|
|
6457 |
stream._writev(chunk, state.onwrite);
|
|
6458 |
else
|
|
6459 |
stream._write(chunk, encoding, state.onwrite);
|
|
6460 |
state.sync = false;
|
|
6461 |
}
|
|
6462 |
|
|
6463 |
function onwriteError(stream, state, sync, er, cb) {
|
|
6464 |
if (sync)
|
|
6465 |
process.nextTick(function() {
|
|
6466 |
state.pendingcb--;
|
|
6467 |
cb(er);
|
|
6468 |
});
|
|
6469 |
else {
|
|
6470 |
state.pendingcb--;
|
|
6471 |
cb(er);
|
|
6472 |
}
|
|
6473 |
|
|
6474 |
stream._writableState.errorEmitted = true;
|
|
6475 |
stream.emit('error', er);
|
|
6476 |
}
|
|
6477 |
|
|
6478 |
function onwriteStateUpdate(state) {
|
|
6479 |
state.writing = false;
|
|
6480 |
state.writecb = null;
|
|
6481 |
state.length -= state.writelen;
|
|
6482 |
state.writelen = 0;
|
|
6483 |
}
|
|
6484 |
|
|
6485 |
function onwrite(stream, er) {
|
|
6486 |
var state = stream._writableState;
|
|
6487 |
var sync = state.sync;
|
|
6488 |
var cb = state.writecb;
|
|
6489 |
|
|
6490 |
onwriteStateUpdate(state);
|
|
6491 |
|
|
6492 |
if (er)
|
|
6493 |
onwriteError(stream, state, sync, er, cb);
|
|
6494 |
else {
|
|
6495 |
// Check if we're actually ready to finish, but don't emit yet
|
|
6496 |
var finished = needFinish(stream, state);
|
|
6497 |
|
|
6498 |
if (!finished &&
|
|
6499 |
!state.corked &&
|
|
6500 |
!state.bufferProcessing &&
|
|
6501 |
state.buffer.length) {
|
|
6502 |
clearBuffer(stream, state);
|
|
6503 |
}
|
|
6504 |
|
|
6505 |
if (sync) {
|
|
6506 |
process.nextTick(function() {
|
|
6507 |
afterWrite(stream, state, finished, cb);
|
|
6508 |
});
|
|
6509 |
} else {
|
|
6510 |
afterWrite(stream, state, finished, cb);
|
|
6511 |
}
|
|
6512 |
}
|
|
6513 |
}
|
|
6514 |
|
|
6515 |
function afterWrite(stream, state, finished, cb) {
|
|
6516 |
if (!finished)
|
|
6517 |
onwriteDrain(stream, state);
|
|
6518 |
state.pendingcb--;
|
|
6519 |
cb();
|
|
6520 |
finishMaybe(stream, state);
|
|
6521 |
}
|
|
6522 |
|
|
6523 |
// Must force callback to be called on nextTick, so that we don't
|
|
6524 |
// emit 'drain' before the write() consumer gets the 'false' return
|
|
6525 |
// value, and has a chance to attach a 'drain' listener.
|
|
6526 |
function onwriteDrain(stream, state) {
|
|
6527 |
if (state.length === 0 && state.needDrain) {
|
|
6528 |
state.needDrain = false;
|
|
6529 |
stream.emit('drain');
|
|
6530 |
}
|
|
6531 |
}
|
|
6532 |
|
|
6533 |
|
|
6534 |
// if there's something in the buffer waiting, then process it
|
|
6535 |
function clearBuffer(stream, state) {
|
|
6536 |
state.bufferProcessing = true;
|
|
6537 |
|
|
6538 |
if (stream._writev && state.buffer.length > 1) {
|
|
6539 |
// Fast case, write everything using _writev()
|
|
6540 |
var cbs = [];
|
|
6541 |
for (var c = 0; c < state.buffer.length; c++)
|
|
6542 |
cbs.push(state.buffer[c].callback);
|
|
6543 |
|
|
6544 |
// count the one we are adding, as well.
|
|
6545 |
// TODO(isaacs) clean this up
|
|
6546 |
state.pendingcb++;
|
|
6547 |
doWrite(stream, state, true, state.length, state.buffer, '', function(err) {
|
|
6548 |
for (var i = 0; i < cbs.length; i++) {
|
|
6549 |
state.pendingcb--;
|
|
6550 |
cbs[i](err);
|
|
6551 |
}
|
|
6552 |
});
|
|
6553 |
|
|
6554 |
// Clear buffer
|
|
6555 |
state.buffer = [];
|
|
6556 |
} else {
|
|
6557 |
// Slow case, write chunks one-by-one
|
|
6558 |
for (var c = 0; c < state.buffer.length; c++) {
|
|
6559 |
var entry = state.buffer[c];
|
|
6560 |
var chunk = entry.chunk;
|
|
6561 |
var encoding = entry.encoding;
|
|
6562 |
var cb = entry.callback;
|
|
6563 |
var len = state.objectMode ? 1 : chunk.length;
|
|
6564 |
|
|
6565 |
doWrite(stream, state, false, len, chunk, encoding, cb);
|
|
6566 |
|
|
6567 |
// if we didn't call the onwrite immediately, then
|
|
6568 |
// it means that we need to wait until it does.
|
|
6569 |
// also, that means that the chunk and cb are currently
|
|
6570 |
// being processed, so move the buffer counter past them.
|
|
6571 |
if (state.writing) {
|
|
6572 |
c++;
|
|
6573 |
break;
|
|
6574 |
}
|
|
6575 |
}
|
|
6576 |
|
|
6577 |
if (c < state.buffer.length)
|
|
6578 |
state.buffer = state.buffer.slice(c);
|
|
6579 |
else
|
|
6580 |
state.buffer.length = 0;
|
|
6581 |
}
|
|
6582 |
|
|
6583 |
state.bufferProcessing = false;
|
|
6584 |
}
|
|
6585 |
|
|
6586 |
Writable.prototype._write = function(chunk, encoding, cb) {
|
|
6587 |
cb(new Error('not implemented'));
|
|
6588 |
|
|
6589 |
};
|
|
6590 |
|
|
6591 |
Writable.prototype._writev = null;
|
|
6592 |
|
|
6593 |
Writable.prototype.end = function(chunk, encoding, cb) {
|
|
6594 |
var state = this._writableState;
|
|
6595 |
|
|
6596 |
if (util.isFunction(chunk)) {
|
|
6597 |
cb = chunk;
|
|
6598 |
chunk = null;
|
|
6599 |
encoding = null;
|
|
6600 |
} else if (util.isFunction(encoding)) {
|
|
6601 |
cb = encoding;
|
|
6602 |
encoding = null;
|
|
6603 |
}
|
|
6604 |
|
|
6605 |
if (!util.isNullOrUndefined(chunk))
|
|
6606 |
this.write(chunk, encoding);
|
|
6607 |
|
|
6608 |
// .end() fully uncorks
|
|
6609 |
if (state.corked) {
|
|
6610 |
state.corked = 1;
|
|
6611 |
this.uncork();
|
|
6612 |
}
|
|
6613 |
|
|
6614 |
// ignore unnecessary end() calls.
|
|
6615 |
if (!state.ending && !state.finished)
|
|
6616 |
endWritable(this, state, cb);
|
|
6617 |
};
|
|
6618 |
|
|
6619 |
|
|
6620 |
function needFinish(stream, state) {
|
|
6621 |
return (state.ending &&
|
|
6622 |
state.length === 0 &&
|
|
6623 |
!state.finished &&
|
|
6624 |
!state.writing);
|
|
6625 |
}
|
|
6626 |
|
|
6627 |
function prefinish(stream, state) {
|
|
6628 |
if (!state.prefinished) {
|
|
6629 |
state.prefinished = true;
|
|
6630 |
stream.emit('prefinish');
|
|
6631 |
}
|
|
6632 |
}
|
|
6633 |
|
|
6634 |
function finishMaybe(stream, state) {
|
|
6635 |
var need = needFinish(stream, state);
|
|
6636 |
if (need) {
|
|
6637 |
if (state.pendingcb === 0) {
|
|
6638 |
prefinish(stream, state);
|
|
6639 |
state.finished = true;
|
|
6640 |
stream.emit('finish');
|
|
6641 |
} else
|
|
6642 |
prefinish(stream, state);
|
|
6643 |
}
|
|
6644 |
return need;
|
|
6645 |
}
|
|
6646 |
|
|
6647 |
function endWritable(stream, state, cb) {
|
|
6648 |
state.ending = true;
|
|
6649 |
finishMaybe(stream, state);
|
|
6650 |
if (cb) {
|
|
6651 |
if (state.finished)
|
|
6652 |
process.nextTick(cb);
|
|
6653 |
else
|
|
6654 |
stream.once('finish', cb);
|
|
6655 |
}
|
|
6656 |
state.ended = true;
|
|
6657 |
}
|
|
6658 |
|
|
6659 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2)))
|
|
6660 |
|
|
6661 |
/***/ },
|
|
6662 |
/* 31 */
|
|
6663 |
/***/ function(module, exports, __webpack_require__) {
|
|
6664 |
|
|
6665 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
6666 |
//
|
|
6667 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6668 |
// copy of this software and associated documentation files (the
|
|
6669 |
// "Software"), to deal in the Software without restriction, including
|
|
6670 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
6671 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
6672 |
// persons to whom the Software is furnished to do so, subject to the
|
|
6673 |
// following conditions:
|
|
6674 |
//
|
|
6675 |
// The above copyright notice and this permission notice shall be included
|
|
6676 |
// in all copies or substantial portions of the Software.
|
|
6677 |
//
|
|
6678 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
6679 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
6680 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
6681 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
6682 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
6683 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
6684 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
6685 |
|
|
6686 |
var Buffer = __webpack_require__(23).Buffer;
|
|
6687 |
|
|
6688 |
var isBufferEncoding = Buffer.isEncoding
|
|
6689 |
|| function(encoding) {
|
|
6690 |
switch (encoding && encoding.toLowerCase()) {
|
|
6691 |
case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
|
|
6692 |
default: return false;
|
|
6693 |
}
|
|
6694 |
}
|
|
6695 |
|
|
6696 |
|
|
6697 |
function assertEncoding(encoding) {
|
|
6698 |
if (encoding && !isBufferEncoding(encoding)) {
|
|
6699 |
throw new Error('Unknown encoding: ' + encoding);
|
|
6700 |
}
|
|
6701 |
}
|
|
6702 |
|
|
6703 |
// StringDecoder provides an interface for efficiently splitting a series of
|
|
6704 |
// buffers into a series of JS strings without breaking apart multi-byte
|
|
6705 |
// characters. CESU-8 is handled as part of the UTF-8 encoding.
|
|
6706 |
//
|
|
6707 |
// @TODO Handling all encodings inside a single object makes it very difficult
|
|
6708 |
// to reason about this code, so it should be split up in the future.
|
|
6709 |
// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
|
|
6710 |
// points as used by CESU-8.
|
|
6711 |
var StringDecoder = exports.StringDecoder = function(encoding) {
|
|
6712 |
this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
|
6713 |
assertEncoding(encoding);
|
|
6714 |
switch (this.encoding) {
|
|
6715 |
case 'utf8':
|
|
6716 |
// CESU-8 represents each of Surrogate Pair by 3-bytes
|
|
6717 |
this.surrogateSize = 3;
|
|
6718 |
break;
|
|
6719 |
case 'ucs2':
|
|
6720 |
case 'utf16le':
|
|
6721 |
// UTF-16 represents each of Surrogate Pair by 2-bytes
|
|
6722 |
this.surrogateSize = 2;
|
|
6723 |
this.detectIncompleteChar = utf16DetectIncompleteChar;
|
|
6724 |
break;
|
|
6725 |
case 'base64':
|
|
6726 |
// Base-64 stores 3 bytes in 4 chars, and pads the remainder.
|
|
6727 |
this.surrogateSize = 3;
|
|
6728 |
this.detectIncompleteChar = base64DetectIncompleteChar;
|
|
6729 |
break;
|
|
6730 |
default:
|
|
6731 |
this.write = passThroughWrite;
|
|
6732 |
return;
|
|
6733 |
}
|
|
6734 |
|
|
6735 |
// Enough space to store all bytes of a single character. UTF-8 needs 4
|
|
6736 |
// bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
|
|
6737 |
this.charBuffer = new Buffer(6);
|
|
6738 |
// Number of bytes received for the current incomplete multi-byte character.
|
|
6739 |
this.charReceived = 0;
|
|
6740 |
// Number of bytes expected for the current incomplete multi-byte character.
|
|
6741 |
this.charLength = 0;
|
|
6742 |
};
|
|
6743 |
|
|
6744 |
|
|
6745 |
// write decodes the given buffer and returns it as JS string that is
|
|
6746 |
// guaranteed to not contain any partial multi-byte characters. Any partial
|
|
6747 |
// character found at the end of the buffer is buffered up, and will be
|
|
6748 |
// returned when calling write again with the remaining bytes.
|
|
6749 |
//
|
|
6750 |
// Note: Converting a Buffer containing an orphan surrogate to a String
|
|
6751 |
// currently works, but converting a String to a Buffer (via `new Buffer`, or
|
|
6752 |
// Buffer#write) will replace incomplete surrogates with the unicode
|
|
6753 |
// replacement character. See https://codereview.chromium.org/121173009/ .
|
|
6754 |
StringDecoder.prototype.write = function(buffer) {
|
|
6755 |
var charStr = '';
|
|
6756 |
// if our last write ended with an incomplete multibyte character
|
|
6757 |
while (this.charLength) {
|
|
6758 |
// determine how many remaining bytes this buffer has to offer for this char
|
|
6759 |
var available = (buffer.length >= this.charLength - this.charReceived) ?
|
|
6760 |
this.charLength - this.charReceived :
|
|
6761 |
buffer.length;
|
|
6762 |
|
|
6763 |
// add the new bytes to the char buffer
|
|
6764 |
buffer.copy(this.charBuffer, this.charReceived, 0, available);
|
|
6765 |
this.charReceived += available;
|
|
6766 |
|
|
6767 |
if (this.charReceived < this.charLength) {
|
|
6768 |
// still not enough chars in this buffer? wait for more ...
|
|
6769 |
return '';
|
|
6770 |
}
|
|
6771 |
|
|
6772 |
// remove bytes belonging to the current character from the buffer
|
|
6773 |
buffer = buffer.slice(available, buffer.length);
|
|
6774 |
|
|
6775 |
// get the character that was split
|
|
6776 |
charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
|
6777 |
|
|
6778 |
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
|
|
6779 |
var charCode = charStr.charCodeAt(charStr.length - 1);
|
|
6780 |
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
6781 |
this.charLength += this.surrogateSize;
|
|
6782 |
charStr = '';
|
|
6783 |
continue;
|
|
6784 |
}
|
|
6785 |
this.charReceived = this.charLength = 0;
|
|
6786 |
|
|
6787 |
// if there are no more bytes in this buffer, just emit our char
|
|
6788 |
if (buffer.length === 0) {
|
|
6789 |
return charStr;
|
|
6790 |
}
|
|
6791 |
break;
|
|
6792 |
}
|
|
6793 |
|
|
6794 |
// determine and set charLength / charReceived
|
|
6795 |
this.detectIncompleteChar(buffer);
|
|
6796 |
|
|
6797 |
var end = buffer.length;
|
|
6798 |
if (this.charLength) {
|
|
6799 |
// buffer the incomplete character bytes we got
|
|
6800 |
buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
|
|
6801 |
end -= this.charReceived;
|
|
6802 |
}
|
|
6803 |
|
|
6804 |
charStr += buffer.toString(this.encoding, 0, end);
|
|
6805 |
|
|
6806 |
var end = charStr.length - 1;
|
|
6807 |
var charCode = charStr.charCodeAt(end);
|
|
6808 |
// CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
|
|
6809 |
if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
|
6810 |
var size = this.surrogateSize;
|
|
6811 |
this.charLength += size;
|
|
6812 |
this.charReceived += size;
|
|
6813 |
this.charBuffer.copy(this.charBuffer, size, 0, size);
|
|
6814 |
buffer.copy(this.charBuffer, 0, 0, size);
|
|
6815 |
return charStr.substring(0, end);
|
|
6816 |
}
|
|
6817 |
|
|
6818 |
// or just emit the charStr
|
|
6819 |
return charStr;
|
|
6820 |
};
|
|
6821 |
|
|
6822 |
// detectIncompleteChar determines if there is an incomplete UTF-8 character at
|
|
6823 |
// the end of the given buffer. If so, it sets this.charLength to the byte
|
|
6824 |
// length that character, and sets this.charReceived to the number of bytes
|
|
6825 |
// that are available for this character.
|
|
6826 |
StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
|
6827 |
// determine how many bytes we have to check at the end of this buffer
|
|
6828 |
var i = (buffer.length >= 3) ? 3 : buffer.length;
|
|
6829 |
|
|
6830 |
// Figure out if one of the last i bytes of our buffer announces an
|
|
6831 |
// incomplete char.
|
|
6832 |
for (; i > 0; i--) {
|
|
6833 |
var c = buffer[buffer.length - i];
|
|
6834 |
|
|
6835 |
// See http://en.wikipedia.org/wiki/UTF-8#Description
|
|
6836 |
|
|
6837 |
// 110XXXXX
|
|
6838 |
if (i == 1 && c >> 5 == 0x06) {
|
|
6839 |
this.charLength = 2;
|
|
6840 |
break;
|
|
6841 |
}
|
|
6842 |
|
|
6843 |
// 1110XXXX
|
|
6844 |
if (i <= 2 && c >> 4 == 0x0E) {
|
|
6845 |
this.charLength = 3;
|
|
6846 |
break;
|
|
6847 |
}
|
|
6848 |
|
|
6849 |
// 11110XXX
|
|
6850 |
if (i <= 3 && c >> 3 == 0x1E) {
|
|
6851 |
this.charLength = 4;
|
|
6852 |
break;
|
|
6853 |
}
|
|
6854 |
}
|
|
6855 |
this.charReceived = i;
|
|
6856 |
};
|
|
6857 |
|
|
6858 |
StringDecoder.prototype.end = function(buffer) {
|
|
6859 |
var res = '';
|
|
6860 |
if (buffer && buffer.length)
|
|
6861 |
res = this.write(buffer);
|
|
6862 |
|
|
6863 |
if (this.charReceived) {
|
|
6864 |
var cr = this.charReceived;
|
|
6865 |
var buf = this.charBuffer;
|
|
6866 |
var enc = this.encoding;
|
|
6867 |
res += buf.slice(0, cr).toString(enc);
|
|
6868 |
}
|
|
6869 |
|
|
6870 |
return res;
|
|
6871 |
};
|
|
6872 |
|
|
6873 |
function passThroughWrite(buffer) {
|
|
6874 |
return buffer.toString(this.encoding);
|
|
6875 |
}
|
|
6876 |
|
|
6877 |
function utf16DetectIncompleteChar(buffer) {
|
|
6878 |
this.charReceived = buffer.length % 2;
|
|
6879 |
this.charLength = this.charReceived ? 2 : 0;
|
|
6880 |
}
|
|
6881 |
|
|
6882 |
function base64DetectIncompleteChar(buffer) {
|
|
6883 |
this.charReceived = buffer.length % 3;
|
|
6884 |
this.charLength = this.charReceived ? 3 : 0;
|
|
6885 |
}
|
|
6886 |
|
|
6887 |
|
|
6888 |
/***/ },
|
|
6889 |
/* 32 */
|
|
6890 |
/***/ function(module, exports, __webpack_require__) {
|
|
6891 |
|
|
6892 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
6893 |
//
|
|
6894 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
6895 |
// copy of this software and associated documentation files (the
|
|
6896 |
// "Software"), to deal in the Software without restriction, including
|
|
6897 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
6898 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
6899 |
// persons to whom the Software is furnished to do so, subject to the
|
|
6900 |
// following conditions:
|
|
6901 |
//
|
|
6902 |
// The above copyright notice and this permission notice shall be included
|
|
6903 |
// in all copies or substantial portions of the Software.
|
|
6904 |
//
|
|
6905 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
6906 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
6907 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
6908 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
6909 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
6910 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
6911 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
6912 |
|
|
6913 |
|
|
6914 |
// a transform stream is a readable/writable stream where you do
|
|
6915 |
// something with the data. Sometimes it's called a "filter",
|
|
6916 |
// but that's not a great name for it, since that implies a thing where
|
|
6917 |
// some bits pass through, and others are simply ignored. (That would
|
|
6918 |
// be a valid example of a transform, of course.)
|
|
6919 |
//
|
|
6920 |
// While the output is causally related to the input, it's not a
|
|
6921 |
// necessarily symmetric or synchronous transformation. For example,
|
|
6922 |
// a zlib stream might take multiple plain-text writes(), and then
|
|
6923 |
// emit a single compressed chunk some time in the future.
|
|
6924 |
//
|
|
6925 |
// Here's how this works:
|
|
6926 |
//
|
|
6927 |
// The Transform stream has all the aspects of the readable and writable
|
|
6928 |
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
|
6929 |
// internally, and returns false if there's a lot of pending writes
|
|
6930 |
// buffered up. When you call read(), that calls _read(n) until
|
|
6931 |
// there's enough pending readable data buffered up.
|
|
6932 |
//
|
|
6933 |
// In a transform stream, the written data is placed in a buffer. When
|
|
6934 |
// _read(n) is called, it transforms the queued up data, calling the
|
|
6935 |
// buffered _write cb's as it consumes chunks. If consuming a single
|
|
6936 |
// written chunk would result in multiple output chunks, then the first
|
|
6937 |
// outputted bit calls the readcb, and subsequent chunks just go into
|
|
6938 |
// the read buffer, and will cause it to emit 'readable' if necessary.
|
|
6939 |
//
|
|
6940 |
// This way, back-pressure is actually determined by the reading side,
|
|
6941 |
// since _read has to be called to start processing a new chunk. However,
|
|
6942 |
// a pathological inflate type of transform can cause excessive buffering
|
|
6943 |
// here. For example, imagine a stream where every byte of input is
|
|
6944 |
// interpreted as an integer from 0-255, and then results in that many
|
|
6945 |
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
|
6946 |
// 1kb of data being output. In this case, you could write a very small
|
|
6947 |
// amount of input, and end up with a very large amount of output. In
|
|
6948 |
// such a pathological inflating mechanism, there'd be no way to tell
|
|
6949 |
// the system to stop doing the transform. A single 4MB write could
|
|
6950 |
// cause the system to run out of memory.
|
|
6951 |
//
|
|
6952 |
// However, even in such a pathological case, only a single written chunk
|
|
6953 |
// would be consumed, and then the rest would wait (un-transformed) until
|
|
6954 |
// the results of the previous transformed chunk were consumed.
|
|
6955 |
|
|
6956 |
module.exports = Transform;
|
|
6957 |
|
|
6958 |
var Duplex = __webpack_require__(29);
|
|
6959 |
|
|
6960 |
/*<replacement>*/
|
|
6961 |
var util = __webpack_require__(27);
|
|
6962 |
util.inherits = __webpack_require__(19);
|
|
6963 |
/*</replacement>*/
|
|
6964 |
|
|
6965 |
util.inherits(Transform, Duplex);
|
|
6966 |
|
|
6967 |
|
|
6968 |
function TransformState(options, stream) {
|
|
6969 |
this.afterTransform = function(er, data) {
|
|
6970 |
return afterTransform(stream, er, data);
|
|
6971 |
};
|
|
6972 |
|
|
6973 |
this.needTransform = false;
|
|
6974 |
this.transforming = false;
|
|
6975 |
this.writecb = null;
|
|
6976 |
this.writechunk = null;
|
|
6977 |
}
|
|
6978 |
|
|
6979 |
function afterTransform(stream, er, data) {
|
|
6980 |
var ts = stream._transformState;
|
|
6981 |
ts.transforming = false;
|
|
6982 |
|
|
6983 |
var cb = ts.writecb;
|
|
6984 |
|
|
6985 |
if (!cb)
|
|
6986 |
return stream.emit('error', new Error('no writecb in Transform class'));
|
|
6987 |
|
|
6988 |
ts.writechunk = null;
|
|
6989 |
ts.writecb = null;
|
|
6990 |
|
|
6991 |
if (!util.isNullOrUndefined(data))
|
|
6992 |
stream.push(data);
|
|
6993 |
|
|
6994 |
if (cb)
|
|
6995 |
cb(er);
|
|
6996 |
|
|
6997 |
var rs = stream._readableState;
|
|
6998 |
rs.reading = false;
|
|
6999 |
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
|
7000 |
stream._read(rs.highWaterMark);
|
|
7001 |
}
|
|
7002 |
}
|
|
7003 |
|
|
7004 |
|
|
7005 |
function Transform(options) {
|
|
7006 |
if (!(this instanceof Transform))
|
|
7007 |
return new Transform(options);
|
|
7008 |
|
|
7009 |
Duplex.call(this, options);
|
|
7010 |
|
|
7011 |
this._transformState = new TransformState(options, this);
|
|
7012 |
|
|
7013 |
// when the writable side finishes, then flush out anything remaining.
|
|
7014 |
var stream = this;
|
|
7015 |
|
|
7016 |
// start out asking for a readable event once data is transformed.
|
|
7017 |
this._readableState.needReadable = true;
|
|
7018 |
|
|
7019 |
// we have implemented the _read method, and done the other things
|
|
7020 |
// that Readable wants before the first _read call, so unset the
|
|
7021 |
// sync guard flag.
|
|
7022 |
this._readableState.sync = false;
|
|
7023 |
|
|
7024 |
this.once('prefinish', function() {
|
|
7025 |
if (util.isFunction(this._flush))
|
|
7026 |
this._flush(function(er) {
|
|
7027 |
done(stream, er);
|
|
7028 |
});
|
|
7029 |
else
|
|
7030 |
done(stream);
|
|
7031 |
});
|
|
7032 |
}
|
|
7033 |
|
|
7034 |
Transform.prototype.push = function(chunk, encoding) {
|
|
7035 |
this._transformState.needTransform = false;
|
|
7036 |
return Duplex.prototype.push.call(this, chunk, encoding);
|
|
7037 |
};
|
|
7038 |
|
|
7039 |
// This is the part where you do stuff!
|
|
7040 |
// override this function in implementation classes.
|
|
7041 |
// 'chunk' is an input chunk.
|
|
7042 |
//
|
|
7043 |
// Call `push(newChunk)` to pass along transformed output
|
|
7044 |
// to the readable side. You may call 'push' zero or more times.
|
|
7045 |
//
|
|
7046 |
// Call `cb(err)` when you are done with this chunk. If you pass
|
|
7047 |
// an error, then that'll put the hurt on the whole operation. If you
|
|
7048 |
// never call cb(), then you'll never get another chunk.
|
|
7049 |
Transform.prototype._transform = function(chunk, encoding, cb) {
|
|
7050 |
throw new Error('not implemented');
|
|
7051 |
};
|
|
7052 |
|
|
7053 |
Transform.prototype._write = function(chunk, encoding, cb) {
|
|
7054 |
var ts = this._transformState;
|
|
7055 |
ts.writecb = cb;
|
|
7056 |
ts.writechunk = chunk;
|
|
7057 |
ts.writeencoding = encoding;
|
|
7058 |
if (!ts.transforming) {
|
|
7059 |
var rs = this._readableState;
|
|
7060 |
if (ts.needTransform ||
|
|
7061 |
rs.needReadable ||
|
|
7062 |
rs.length < rs.highWaterMark)
|
|
7063 |
this._read(rs.highWaterMark);
|
|
7064 |
}
|
|
7065 |
};
|
|
7066 |
|
|
7067 |
// Doesn't matter what the args are here.
|
|
7068 |
// _transform does all the work.
|
|
7069 |
// That we got here means that the readable side wants more data.
|
|
7070 |
Transform.prototype._read = function(n) {
|
|
7071 |
var ts = this._transformState;
|
|
7072 |
|
|
7073 |
if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
|
|
7074 |
ts.transforming = true;
|
|
7075 |
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
|
7076 |
} else {
|
|
7077 |
// mark that we need a transform, so that any data that comes in
|
|
7078 |
// will get processed, now that we've asked for it.
|
|
7079 |
ts.needTransform = true;
|
|
7080 |
}
|
|
7081 |
};
|
|
7082 |
|
|
7083 |
|
|
7084 |
function done(stream, er) {
|
|
7085 |
if (er)
|
|
7086 |
return stream.emit('error', er);
|
|
7087 |
|
|
7088 |
// if there's nothing in the write buffer, then that means
|
|
7089 |
// that nothing more will ever be provided
|
|
7090 |
var ws = stream._writableState;
|
|
7091 |
var ts = stream._transformState;
|
|
7092 |
|
|
7093 |
if (ws.length)
|
|
7094 |
throw new Error('calling transform done when ws.length != 0');
|
|
7095 |
|
|
7096 |
if (ts.transforming)
|
|
7097 |
throw new Error('calling transform done when still transforming');
|
|
7098 |
|
|
7099 |
return stream.push(null);
|
|
7100 |
}
|
|
7101 |
|
|
7102 |
|
|
7103 |
/***/ },
|
|
7104 |
/* 33 */
|
|
7105 |
/***/ function(module, exports, __webpack_require__) {
|
|
7106 |
|
|
7107 |
// Copyright Joyent, Inc. and other Node contributors.
|
|
7108 |
//
|
|
7109 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
7110 |
// copy of this software and associated documentation files (the
|
|
7111 |
// "Software"), to deal in the Software without restriction, including
|
|
7112 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7113 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
7114 |
// persons to whom the Software is furnished to do so, subject to the
|
|
7115 |
// following conditions:
|
|
7116 |
//
|
|
7117 |
// The above copyright notice and this permission notice shall be included
|
|
7118 |
// in all copies or substantial portions of the Software.
|
|
7119 |
//
|
|
7120 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
7121 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
7122 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
7123 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
7124 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
7125 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
7126 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
7127 |
|
|
7128 |
// a passthrough stream.
|
|
7129 |
// basically just the most minimal sort of Transform stream.
|
|
7130 |
// Every written chunk gets output as-is.
|
|
7131 |
|
|
7132 |
module.exports = PassThrough;
|
|
7133 |
|
|
7134 |
var Transform = __webpack_require__(32);
|
|
7135 |
|
|
7136 |
/*<replacement>*/
|
|
7137 |
var util = __webpack_require__(27);
|
|
7138 |
util.inherits = __webpack_require__(19);
|
|
7139 |
/*</replacement>*/
|
|
7140 |
|
|
7141 |
util.inherits(PassThrough, Transform);
|
|
7142 |
|
|
7143 |
function PassThrough(options) {
|
|
7144 |
if (!(this instanceof PassThrough))
|
|
7145 |
return new PassThrough(options);
|
|
7146 |
|
|
7147 |
Transform.call(this, options);
|
|
7148 |
}
|
|
7149 |
|
|
7150 |
PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
|
7151 |
cb(null, chunk);
|
|
7152 |
};
|
|
7153 |
|
|
7154 |
|
|
7155 |
/***/ },
|
|
7156 |
/* 34 */
|
|
7157 |
/***/ function(module, exports, __webpack_require__) {
|
|
7158 |
|
|
7159 |
module.exports = __webpack_require__(30)
|
|
7160 |
|
|
7161 |
|
|
7162 |
/***/ },
|
|
7163 |
/* 35 */
|
|
7164 |
/***/ function(module, exports, __webpack_require__) {
|
|
7165 |
|
|
7166 |
module.exports = __webpack_require__(29)
|
|
7167 |
|
|
7168 |
|
|
7169 |
/***/ },
|
|
7170 |
/* 36 */
|
|
7171 |
/***/ function(module, exports, __webpack_require__) {
|
|
7172 |
|
|
7173 |
module.exports = __webpack_require__(32)
|
|
7174 |
|
|
7175 |
|
|
7176 |
/***/ },
|
|
7177 |
/* 37 */
|
|
7178 |
/***/ function(module, exports, __webpack_require__) {
|
|
7179 |
|
|
7180 |
module.exports = __webpack_require__(33)
|
|
7181 |
|
|
7182 |
|
|
7183 |
/***/ },
|
|
7184 |
/* 38 */
|
|
7185 |
/***/ function(module, exports, __webpack_require__) {
|
|
7186 |
|
|
7187 |
var Stream = __webpack_require__(18);
|
|
7188 |
var util = __webpack_require__(39);
|
|
7189 |
|
|
7190 |
var Response = module.exports = function (res) {
|
|
7191 |
this.offset = 0;
|
|
7192 |
this.readable = true;
|
|
7193 |
};
|
|
7194 |
|
|
7195 |
util.inherits(Response, Stream);
|
|
7196 |
|
|
7197 |
var capable = {
|
|
7198 |
streaming : true,
|
|
7199 |
status2 : true
|
|
7200 |
};
|
|
7201 |
|
|
7202 |
function parseHeaders (res) {
|
|
7203 |
var lines = res.getAllResponseHeaders().split(/\r?\n/);
|
|
7204 |
var headers = {};
|
|
7205 |
for (var i = 0; i < lines.length; i++) {
|
|
7206 |
var line = lines[i];
|
|
7207 |
if (line === '') continue;
|
|
7208 |
|
|
7209 |
var m = line.match(/^([^:]+):\s*(.*)/);
|
|
7210 |
if (m) {
|
|
7211 |
var key = m[1].toLowerCase(), value = m[2];
|
|
7212 |
|
|
7213 |
if (headers[key] !== undefined) {
|
|
7214 |
|
|
7215 |
if (isArray(headers[key])) {
|
|
7216 |
headers[key].push(value);
|
|
7217 |
}
|
|
7218 |
else {
|
|
7219 |
headers[key] = [ headers[key], value ];
|
|
7220 |
}
|
|
7221 |
}
|
|
7222 |
else {
|
|
7223 |
headers[key] = value;
|
|
7224 |
}
|
|
7225 |
}
|
|
7226 |
else {
|
|
7227 |
headers[line] = true;
|
|
7228 |
}
|
|
7229 |
}
|
|
7230 |
return headers;
|
|
7231 |
}
|
|
7232 |
|
|
7233 |
Response.prototype.getResponse = function (xhr) {
|
|
7234 |
var respType = String(xhr.responseType).toLowerCase();
|
|
7235 |
if (respType === 'blob') return xhr.responseBlob || xhr.response;
|
|
7236 |
if (respType === 'arraybuffer') return xhr.response;
|
|
7237 |
return xhr.responseText;
|
|
7238 |
}
|
|
7239 |
|
|
7240 |
Response.prototype.getHeader = function (key) {
|
|
7241 |
return this.headers[key.toLowerCase()];
|
|
7242 |
};
|
|
7243 |
|
|
7244 |
Response.prototype.handle = function (res) {
|
|
7245 |
if (res.readyState === 2 && capable.status2) {
|
|
7246 |
try {
|
|
7247 |
this.statusCode = res.status;
|
|
7248 |
this.headers = parseHeaders(res);
|
|
7249 |
}
|
|
7250 |
catch (err) {
|
|
7251 |
capable.status2 = false;
|
|
7252 |
}
|
|
7253 |
|
|
7254 |
if (capable.status2) {
|
|
7255 |
this.emit('ready');
|
|
7256 |
}
|
|
7257 |
}
|
|
7258 |
else if (capable.streaming && res.readyState === 3) {
|
|
7259 |
try {
|
|
7260 |
if (!this.statusCode) {
|
|
7261 |
this.statusCode = res.status;
|
|
7262 |
this.headers = parseHeaders(res);
|
|
7263 |
this.emit('ready');
|
|
7264 |
}
|
|
7265 |
}
|
|
7266 |
catch (err) {}
|
|
7267 |
|
|
7268 |
try {
|
|
7269 |
this._emitData(res);
|
|
7270 |
}
|
|
7271 |
catch (err) {
|
|
7272 |
capable.streaming = false;
|
|
7273 |
}
|
|
7274 |
}
|
|
7275 |
else if (res.readyState === 4) {
|
|
7276 |
if (!this.statusCode) {
|
|
7277 |
this.statusCode = res.status;
|
|
7278 |
this.emit('ready');
|
|
7279 |
}
|
|
7280 |
this._emitData(res);
|
|
7281 |
|
|
7282 |
if (res.error) {
|
|
7283 |
this.emit('error', this.getResponse(res));
|
|
7284 |
}
|
|
7285 |
else this.emit('end');
|
|
7286 |
|
|
7287 |
this.emit('close');
|
|
7288 |
}
|
|
7289 |
};
|
|
7290 |
|
|
7291 |
Response.prototype._emitData = function (res) {
|
|
7292 |
var respBody = this.getResponse(res);
|
|
7293 |
if (respBody.toString().match(/ArrayBuffer/)) {
|
|
7294 |
this.emit('data', new Uint8Array(respBody, this.offset));
|
|
7295 |
this.offset = respBody.byteLength;
|
|
7296 |
return;
|
|
7297 |
}
|
|
7298 |
if (respBody.length > this.offset) {
|
|
7299 |
this.emit('data', respBody.slice(this.offset));
|
|
7300 |
this.offset = respBody.length;
|
|
7301 |
}
|
|
7302 |
};
|
|
7303 |
|
|
7304 |
var isArray = Array.isArray || function (xs) {
|
|
7305 |
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
7306 |
};
|
|
7307 |
|
|
7308 |
|
|
7309 |
/***/ },
|
|
7310 |
/* 39 */
|
|
7311 |
/***/ function(module, exports, __webpack_require__) {
|
|
7312 |
|
|
7313 |
/* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
|
|
7314 |
//
|
|
7315 |
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
7316 |
// copy of this software and associated documentation files (the
|
|
7317 |
// "Software"), to deal in the Software without restriction, including
|
|
7318 |
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7319 |
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
7320 |
// persons to whom the Software is furnished to do so, subject to the
|
|
7321 |
// following conditions:
|
|
7322 |
//
|
|
7323 |
// The above copyright notice and this permission notice shall be included
|
|
7324 |
// in all copies or substantial portions of the Software.
|
|
7325 |
//
|
|
7326 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
7327 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
7328 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
7329 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
7330 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
7331 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
7332 |
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
7333 |
|
|
7334 |
var formatRegExp = /%[sdj%]/g;
|
|
7335 |
exports.format = function(f) {
|
|
7336 |
if (!isString(f)) {
|
|
7337 |
var objects = [];
|
|
7338 |
for (var i = 0; i < arguments.length; i++) {
|
|
7339 |
objects.push(inspect(arguments[i]));
|
|
7340 |
}
|
|
7341 |
return objects.join(' ');
|
|
7342 |
}
|
|
7343 |
|
|
7344 |
var i = 1;
|
|
7345 |
var args = arguments;
|
|
7346 |
var len = args.length;
|
|
7347 |
var str = String(f).replace(formatRegExp, function(x) {
|
|
7348 |
if (x === '%%') return '%';
|
|
7349 |
if (i >= len) return x;
|
|
7350 |
switch (x) {
|
|
7351 |
case '%s': return String(args[i++]);
|
|
7352 |
case '%d': return Number(args[i++]);
|
|
7353 |
case '%j':
|
|
7354 |
try {
|
|
7355 |
return JSON.stringify(args[i++]);
|
|
7356 |
} catch (_) {
|
|
7357 |
return '[Circular]';
|
|
7358 |
}
|
|
7359 |
default:
|
|
7360 |
return x;
|
|
7361 |
}
|
|
7362 |
});
|
|
7363 |
for (var x = args[i]; i < len; x = args[++i]) {
|
|
7364 |
if (isNull(x) || !isObject(x)) {
|
|
7365 |
str += ' ' + x;
|
|
7366 |
} else {
|
|
7367 |
str += ' ' + inspect(x);
|
|
7368 |
}
|
|
7369 |
}
|
|
7370 |
return str;
|
|
7371 |
};
|
|
7372 |
|
|
7373 |
|
|
7374 |
// Mark that a method should not be used.
|
|
7375 |
// Returns a modified function which warns once by default.
|
|
7376 |
// If --no-deprecation is set, then it is a no-op.
|
|
7377 |
exports.deprecate = function(fn, msg) {
|
|
7378 |
// Allow for deprecating things in the process of starting up.
|
|
7379 |
if (isUndefined(global.process)) {
|
|
7380 |
return function() {
|
|
7381 |
return exports.deprecate(fn, msg).apply(this, arguments);
|
|
7382 |
};
|
|
7383 |
}
|
|
7384 |
|
|
7385 |
if (process.noDeprecation === true) {
|
|
7386 |
return fn;
|
|
7387 |
}
|
|
7388 |
|
|
7389 |
var warned = false;
|
|
7390 |
function deprecated() {
|
|
7391 |
if (!warned) {
|
|
7392 |
if (process.throwDeprecation) {
|
|
7393 |
throw new Error(msg);
|
|
7394 |
} else if (process.traceDeprecation) {
|
|
7395 |
console.trace(msg);
|
|
7396 |
} else {
|
|
7397 |
console.error(msg);
|
|
7398 |
}
|
|
7399 |
warned = true;
|
|
7400 |
}
|
|
7401 |
return fn.apply(this, arguments);
|
|
7402 |
}
|
|
7403 |
|
|
7404 |
return deprecated;
|
|
7405 |
};
|
|
7406 |
|
|
7407 |
|
|
7408 |
var debugs = {};
|
|
7409 |
var debugEnviron;
|
|
7410 |
exports.debuglog = function(set) {
|
|
7411 |
if (isUndefined(debugEnviron))
|
|
7412 |
debugEnviron = process.env.NODE_DEBUG || '';
|
|
7413 |
set = set.toUpperCase();
|
|
7414 |
if (!debugs[set]) {
|
|
7415 |
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
|
7416 |
var pid = process.pid;
|
|
7417 |
debugs[set] = function() {
|
|
7418 |
var msg = exports.format.apply(exports, arguments);
|
|
7419 |
console.error('%s %d: %s', set, pid, msg);
|
|
7420 |
};
|
|
7421 |
} else {
|
|
7422 |
debugs[set] = function() {};
|
|
7423 |
}
|
|
7424 |
}
|
|
7425 |
return debugs[set];
|
|
7426 |
};
|
|
7427 |
|
|
7428 |
|
|
7429 |
/**
|
|
7430 |
* Echos the value of a value. Trys to print the value out
|
|
7431 |
* in the best way possible given the different types.
|
|
7432 |
*
|
|
7433 |
* @param {Object} obj The object to print out.
|
|
7434 |
* @param {Object} opts Optional options object that alters the output.
|
|
7435 |
*/
|
|
7436 |
/* legacy: obj, showHidden, depth, colors*/
|
|
7437 |
function inspect(obj, opts) {
|
|
7438 |
// default options
|
|
7439 |
var ctx = {
|
|
7440 |
seen: [],
|
|
7441 |
stylize: stylizeNoColor
|
|
7442 |
};
|
|
7443 |
// legacy...
|
|
7444 |
if (arguments.length >= 3) ctx.depth = arguments[2];
|
|
7445 |
if (arguments.length >= 4) ctx.colors = arguments[3];
|
|
7446 |
if (isBoolean(opts)) {
|
|
7447 |
// legacy...
|
|
7448 |
ctx.showHidden = opts;
|
|
7449 |
} else if (opts) {
|
|
7450 |
// got an "options" object
|
|
7451 |
exports._extend(ctx, opts);
|
|
7452 |
}
|
|
7453 |
// set default options
|
|
7454 |
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
|
7455 |
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
|
7456 |
if (isUndefined(ctx.colors)) ctx.colors = false;
|
|
7457 |
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
|
7458 |
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
|
7459 |
return formatValue(ctx, obj, ctx.depth);
|
|
7460 |
}
|
|
7461 |
exports.inspect = inspect;
|
|
7462 |
|
|
7463 |
|
|
7464 |
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
|
7465 |
inspect.colors = {
|
|
7466 |
'bold' : [1, 22],
|
|
7467 |
'italic' : [3, 23],
|
|
7468 |
'underline' : [4, 24],
|
|
7469 |
'inverse' : [7, 27],
|
|
7470 |
'white' : [37, 39],
|
|
7471 |
'grey' : [90, 39],
|
|
7472 |
'black' : [30, 39],
|
|
7473 |
'blue' : [34, 39],
|
|
7474 |
'cyan' : [36, 39],
|
|
7475 |
'green' : [32, 39],
|
|
7476 |
'magenta' : [35, 39],
|
|
7477 |
'red' : [31, 39],
|
|
7478 |
'yellow' : [33, 39]
|
|
7479 |
};
|
|
7480 |
|
|
7481 |
// Don't use 'blue' not visible on cmd.exe
|
|
7482 |
inspect.styles = {
|
|
7483 |
'special': 'cyan',
|
|
7484 |
'number': 'yellow',
|
|
7485 |
'boolean': 'yellow',
|
|
7486 |
'undefined': 'grey',
|
|
7487 |
'null': 'bold',
|
|
7488 |
'string': 'green',
|
|
7489 |
'date': 'magenta',
|
|
7490 |
// "name": intentionally not styling
|
|
7491 |
'regexp': 'red'
|
|
7492 |
};
|
|
7493 |
|
|
7494 |
|
|
7495 |
function stylizeWithColor(str, styleType) {
|
|
7496 |
var style = inspect.styles[styleType];
|
|
7497 |
|
|
7498 |
if (style) {
|
|
7499 |
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
|
7500 |
'\u001b[' + inspect.colors[style][1] + 'm';
|
|
7501 |
} else {
|
|
7502 |
return str;
|
|
7503 |
}
|
|
7504 |
}
|
|
7505 |
|
|
7506 |
|
|
7507 |
function stylizeNoColor(str, styleType) {
|
|
7508 |
return str;
|
|
7509 |
}
|
|
7510 |
|
|
7511 |
|
|
7512 |
function arrayToHash(array) {
|
|
7513 |
var hash = {};
|
|
7514 |
|
|
7515 |
array.forEach(function(val, idx) {
|
|
7516 |
hash[val] = true;
|
|
7517 |
});
|
|
7518 |
|
|
7519 |
return hash;
|
|
7520 |
}
|
|
7521 |
|
|
7522 |
|
|
7523 |
function formatValue(ctx, value, recurseTimes) {
|
|
7524 |
// Provide a hook for user-specified inspect functions.
|
|
7525 |
// Check that value is an object with an inspect function on it
|
|
7526 |
if (ctx.customInspect &&
|
|
7527 |
value &&
|
|
7528 |
isFunction(value.inspect) &&
|
|
7529 |
// Filter out the util module, it's inspect function is special
|
|
7530 |
value.inspect !== exports.inspect &&
|
|
7531 |
// Also filter out any prototype objects using the circular check.
|
|
7532 |
!(value.constructor && value.constructor.prototype === value)) {
|
|
7533 |
var ret = value.inspect(recurseTimes, ctx);
|
|
7534 |
if (!isString(ret)) {
|
|
7535 |
ret = formatValue(ctx, ret, recurseTimes);
|
|
7536 |
}
|
|
7537 |
return ret;
|
|
7538 |
}
|
|
7539 |
|
|
7540 |
// Primitive types cannot have properties
|
|
7541 |
var primitive = formatPrimitive(ctx, value);
|
|
7542 |
if (primitive) {
|
|
7543 |
return primitive;
|
|
7544 |
}
|
|
7545 |
|
|
7546 |
// Look up the keys of the object.
|
|
7547 |
var keys = Object.keys(value);
|
|
7548 |
var visibleKeys = arrayToHash(keys);
|
|
7549 |
|
|
7550 |
if (ctx.showHidden) {
|
|
7551 |
keys = Object.getOwnPropertyNames(value);
|
|
7552 |
}
|
|
7553 |
|
|
7554 |
// IE doesn't make error fields non-enumerable
|
|
7555 |
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
|
7556 |
if (isError(value)
|
|
7557 |
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
|
7558 |
return formatError(value);
|
|
7559 |
}
|
|
7560 |
|
|
7561 |
// Some type of object without properties can be shortcutted.
|
|
7562 |
if (keys.length === 0) {
|
|
7563 |
if (isFunction(value)) {
|
|
7564 |
var name = value.name ? ': ' + value.name : '';
|
|
7565 |
return ctx.stylize('[Function' + name + ']', 'special');
|
|
7566 |
}
|
|
7567 |
if (isRegExp(value)) {
|
|
7568 |
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
7569 |
}
|
|
7570 |
if (isDate(value)) {
|
|
7571 |
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
|
7572 |
}
|
|
7573 |
if (isError(value)) {
|
|
7574 |
return formatError(value);
|
|
7575 |
}
|
|
7576 |
}
|
|
7577 |
|
|
7578 |
var base = '', array = false, braces = ['{', '}'];
|
|
7579 |
|
|
7580 |
// Make Array say that they are Array
|
|
7581 |
if (isArray(value)) {
|
|
7582 |
array = true;
|
|
7583 |
braces = ['[', ']'];
|
|
7584 |
}
|
|
7585 |
|
|
7586 |
// Make functions say that they are functions
|
|
7587 |
if (isFunction(value)) {
|
|
7588 |
var n = value.name ? ': ' + value.name : '';
|
|
7589 |
base = ' [Function' + n + ']';
|
|
7590 |
}
|
|
7591 |
|
|
7592 |
// Make RegExps say that they are RegExps
|
|
7593 |
if (isRegExp(value)) {
|
|
7594 |
base = ' ' + RegExp.prototype.toString.call(value);
|
|
7595 |
}
|
|
7596 |
|
|
7597 |
// Make dates with properties first say the date
|
|
7598 |
if (isDate(value)) {
|
|
7599 |
base = ' ' + Date.prototype.toUTCString.call(value);
|
|
7600 |
}
|
|
7601 |
|
|
7602 |
// Make error with message first say the error
|
|
7603 |
if (isError(value)) {
|
|
7604 |
base = ' ' + formatError(value);
|
|
7605 |
}
|
|
7606 |
|
|
7607 |
if (keys.length === 0 && (!array || value.length == 0)) {
|
|
7608 |
return braces[0] + base + braces[1];
|
|
7609 |
}
|
|
7610 |
|
|
7611 |
if (recurseTimes < 0) {
|
|
7612 |
if (isRegExp(value)) {
|
|
7613 |
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
|
7614 |
} else {
|
|
7615 |
return ctx.stylize('[Object]', 'special');
|
|
7616 |
}
|
|
7617 |
}
|
|
7618 |
|
|
7619 |
ctx.seen.push(value);
|
|
7620 |
|
|
7621 |
var output;
|
|
7622 |
if (array) {
|
|
7623 |
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
|
7624 |
} else {
|
|
7625 |
output = keys.map(function(key) {
|
|
7626 |
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
|
7627 |
});
|
|
7628 |
}
|
|
7629 |
|
|
7630 |
ctx.seen.pop();
|
|
7631 |
|
|
7632 |
return reduceToSingleString(output, base, braces);
|
|
7633 |
}
|
|
7634 |
|
|
7635 |
|
|
7636 |
function formatPrimitive(ctx, value) {
|
|
7637 |
if (isUndefined(value))
|
|
7638 |
return ctx.stylize('undefined', 'undefined');
|
|
7639 |
if (isString(value)) {
|
|
7640 |
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
|
7641 |
.replace(/'/g, "\\'")
|
|
7642 |
.replace(/\\"/g, '"') + '\'';
|
|
7643 |
return ctx.stylize(simple, 'string');
|
|
7644 |
}
|
|
7645 |
if (isNumber(value))
|
|
7646 |
return ctx.stylize('' + value, 'number');
|
|
7647 |
if (isBoolean(value))
|
|
7648 |
return ctx.stylize('' + value, 'boolean');
|
|
7649 |
// For some reason typeof null is "object", so special case here.
|
|
7650 |
if (isNull(value))
|
|
7651 |
return ctx.stylize('null', 'null');
|
|
7652 |
}
|
|
7653 |
|
|
7654 |
|
|
7655 |
function formatError(value) {
|
|
7656 |
return '[' + Error.prototype.toString.call(value) + ']';
|
|
7657 |
}
|
|
7658 |
|
|
7659 |
|
|
7660 |
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
|
7661 |
var output = [];
|
|
7662 |
for (var i = 0, l = value.length; i < l; ++i) {
|
|
7663 |
if (hasOwnProperty(value, String(i))) {
|
|
7664 |
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
7665 |
String(i), true));
|
|
7666 |
} else {
|
|
7667 |
output.push('');
|
|
7668 |
}
|
|
7669 |
}
|
|
7670 |
keys.forEach(function(key) {
|
|
7671 |
if (!key.match(/^\d+$/)) {
|
|
7672 |
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
|
7673 |
key, true));
|
|
7674 |
}
|
|
7675 |
});
|
|
7676 |
return output;
|
|
7677 |
}
|
|
7678 |
|
|
7679 |
|
|
7680 |
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
|
7681 |
var name, str, desc;
|
|
7682 |
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
|
7683 |
if (desc.get) {
|
|
7684 |
if (desc.set) {
|
|
7685 |
str = ctx.stylize('[Getter/Setter]', 'special');
|
|
7686 |
} else {
|
|
7687 |
str = ctx.stylize('[Getter]', 'special');
|
|
7688 |
}
|
|
7689 |
} else {
|
|
7690 |
if (desc.set) {
|
|
7691 |
str = ctx.stylize('[Setter]', 'special');
|
|
7692 |
}
|
|
7693 |
}
|
|
7694 |
if (!hasOwnProperty(visibleKeys, key)) {
|
|
7695 |
name = '[' + key + ']';
|
|
7696 |
}
|
|
7697 |
if (!str) {
|
|
7698 |
if (ctx.seen.indexOf(desc.value) < 0) {
|
|
7699 |
if (isNull(recurseTimes)) {
|
|
7700 |
str = formatValue(ctx, desc.value, null);
|
|
7701 |
} else {
|
|
7702 |
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
|
7703 |
}
|
|
7704 |
if (str.indexOf('\n') > -1) {
|
|
7705 |
if (array) {
|
|
7706 |
str = str.split('\n').map(function(line) {
|
|
7707 |
return ' ' + line;
|
|
7708 |
}).join('\n').substr(2);
|
|
7709 |
} else {
|
|
7710 |
str = '\n' + str.split('\n').map(function(line) {
|
|
7711 |
return ' ' + line;
|
|
7712 |
}).join('\n');
|
|
7713 |
}
|
|
7714 |
}
|
|
7715 |
} else {
|
|
7716 |
str = ctx.stylize('[Circular]', 'special');
|
|
7717 |
}
|
|
7718 |
}
|
|
7719 |
if (isUndefined(name)) {
|
|
7720 |
if (array && key.match(/^\d+$/)) {
|
|
7721 |
return str;
|
|
7722 |
}
|
|
7723 |
name = JSON.stringify('' + key);
|
|
7724 |
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
|
7725 |
name = name.substr(1, name.length - 2);
|
|
7726 |
name = ctx.stylize(name, 'name');
|
|
7727 |
} else {
|
|
7728 |
name = name.replace(/'/g, "\\'")
|
|
7729 |
.replace(/\\"/g, '"')
|
|
7730 |
.replace(/(^"|"$)/g, "'");
|
|
7731 |
name = ctx.stylize(name, 'string');
|
|
7732 |
}
|
|
7733 |
}
|
|
7734 |
|
|
7735 |
return name + ': ' + str;
|
|
7736 |
}
|
|
7737 |
|
|
7738 |
|
|
7739 |
function reduceToSingleString(output, base, braces) {
|
|
7740 |
var numLinesEst = 0;
|
|
7741 |
var length = output.reduce(function(prev, cur) {
|
|
7742 |
numLinesEst++;
|
|
7743 |
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
|
7744 |
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
|
7745 |
}, 0);
|
|
7746 |
|
|
7747 |
if (length > 60) {
|
|
7748 |
return braces[0] +
|
|
7749 |
(base === '' ? '' : base + '\n ') +
|
|
7750 |
' ' +
|
|
7751 |
output.join(',\n ') +
|
|
7752 |
' ' +
|
|
7753 |
braces[1];
|
|
7754 |
}
|
|
7755 |
|
|
7756 |
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
|
7757 |
}
|
|
7758 |
|
|
7759 |
|
|
7760 |
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
7761 |
// because it is fragile and can be easily faked with `Object.create()`.
|
|
7762 |
function isArray(ar) {
|
|
7763 |
return Array.isArray(ar);
|
|
7764 |
}
|
|
7765 |
exports.isArray = isArray;
|
|
7766 |
|
|
7767 |
function isBoolean(arg) {
|
|
7768 |
return typeof arg === 'boolean';
|
|
7769 |
}
|
|
7770 |
exports.isBoolean = isBoolean;
|
|
7771 |
|
|
7772 |
function isNull(arg) {
|
|
7773 |
return arg === null;
|
|
7774 |
}
|
|
7775 |
exports.isNull = isNull;
|
|
7776 |
|
|
7777 |
function isNullOrUndefined(arg) {
|
|
7778 |
return arg == null;
|
|
7779 |
}
|
|
7780 |
exports.isNullOrUndefined = isNullOrUndefined;
|
|
7781 |
|
|
7782 |
function isNumber(arg) {
|
|
7783 |
return typeof arg === 'number';
|
|
7784 |
}
|
|
7785 |
exports.isNumber = isNumber;
|
|
7786 |
|
|
7787 |
function isString(arg) {
|
|
7788 |
return typeof arg === 'string';
|
|
7789 |
}
|
|
7790 |
exports.isString = isString;
|
|
7791 |
|
|
7792 |
function isSymbol(arg) {
|
|
7793 |
return typeof arg === 'symbol';
|
|
7794 |
}
|
|
7795 |
exports.isSymbol = isSymbol;
|
|
7796 |
|
|
7797 |
function isUndefined(arg) {
|
|
7798 |
return arg === void 0;
|
|
7799 |
}
|
|
7800 |
exports.isUndefined = isUndefined;
|
|
7801 |
|
|
7802 |
function isRegExp(re) {
|
|
7803 |
return isObject(re) && objectToString(re) === '[object RegExp]';
|
|
7804 |
}
|
|
7805 |
exports.isRegExp = isRegExp;
|
|
7806 |
|
|
7807 |
function isObject(arg) {
|
|
7808 |
return typeof arg === 'object' && arg !== null;
|
|
7809 |
}
|
|
7810 |
exports.isObject = isObject;
|
|
7811 |
|
|
7812 |
function isDate(d) {
|
|
7813 |
return isObject(d) && objectToString(d) === '[object Date]';
|
|
7814 |
}
|
|
7815 |
exports.isDate = isDate;
|
|
7816 |
|
|
7817 |
function isError(e) {
|
|
7818 |
return isObject(e) &&
|
|
7819 |
(objectToString(e) === '[object Error]' || e instanceof Error);
|
|
7820 |
}
|
|
7821 |
exports.isError = isError;
|
|
7822 |
|
|
7823 |
function isFunction(arg) {
|
|
7824 |
return typeof arg === 'function';
|
|
7825 |
}
|
|
7826 |
exports.isFunction = isFunction;
|
|
7827 |
|
|
7828 |
function isPrimitive(arg) {
|
|
7829 |
return arg === null ||
|
|
7830 |
typeof arg === 'boolean' ||
|
|
7831 |
typeof arg === 'number' ||
|
|
7832 |
typeof arg === 'string' ||
|
|
7833 |
typeof arg === 'symbol' || // ES6 symbol
|
|
7834 |
typeof arg === 'undefined';
|
|
7835 |
}
|
|
7836 |
exports.isPrimitive = isPrimitive;
|
|
7837 |
|
|
7838 |
exports.isBuffer = __webpack_require__(40);
|
|
7839 |
|
|
7840 |
function objectToString(o) {
|
|
7841 |
return Object.prototype.toString.call(o);
|
|
7842 |
}
|
|
7843 |
|
|
7844 |
|
|
7845 |
function pad(n) {
|
|
7846 |
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
|
7847 |
}
|
|
7848 |
|
|
7849 |
|
|
7850 |
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
|
7851 |
'Oct', 'Nov', 'Dec'];
|
|
7852 |
|
|
7853 |
// 26 Feb 16:19:34
|
|
7854 |
function timestamp() {
|
|
7855 |
var d = new Date();
|
|
7856 |
var time = [pad(d.getHours()),
|
|
7857 |
pad(d.getMinutes()),
|
|
7858 |
pad(d.getSeconds())].join(':');
|
|
7859 |
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
|
7860 |
}
|
|
7861 |
|
|
7862 |
|
|
7863 |
// log is just a thin wrapper to console.log that prepends a timestamp
|
|
7864 |
exports.log = function() {
|
|
7865 |
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
|
7866 |
};
|
|
7867 |
|
|
7868 |
|
|
7869 |
/**
|
|
7870 |
* Inherit the prototype methods from one constructor into another.
|
|
7871 |
*
|
|
7872 |
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
|
7873 |
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
|
7874 |
* during bootstrapping this function needs to be rewritten using some native
|
|
7875 |
* functions as prototype setup using normal JavaScript does not work as
|
|
7876 |
* expected during bootstrapping (see mirror.js in r114903).
|
|
7877 |
*
|
|
7878 |
* @param {function} ctor Constructor function which needs to inherit the
|
|
7879 |
* prototype.
|
|
7880 |
* @param {function} superCtor Constructor function to inherit prototype from.
|
|
7881 |
*/
|
|
7882 |
exports.inherits = __webpack_require__(19);
|
|
7883 |
|
|
7884 |
exports._extend = function(origin, add) {
|
|
7885 |
// Don't do anything if add isn't an object
|
|
7886 |
if (!add || !isObject(add)) return origin;
|
|
7887 |
|
|
7888 |
var keys = Object.keys(add);
|
|
7889 |
var i = keys.length;
|
|
7890 |
while (i--) {
|
|
7891 |
origin[keys[i]] = add[keys[i]];
|
|
7892 |
}
|
|
7893 |
return origin;
|
|
7894 |
};
|
|
7895 |
|
|
7896 |
function hasOwnProperty(obj, prop) {
|
|
7897 |
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
7898 |
}
|
|
7899 |
|
|
7900 |
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(2)))
|
|
7901 |
|
|
7902 |
/***/ },
|
|
7903 |
/* 40 */
|
|
7904 |
/***/ function(module, exports) {
|
|
7905 |
|
|
7906 |
module.exports = function isBuffer(arg) {
|
|
7907 |
return arg && typeof arg === 'object'
|
|
7908 |
&& typeof arg.copy === 'function'
|
|
7909 |
&& typeof arg.fill === 'function'
|
|
7910 |
&& typeof arg.readUInt8 === 'function';
|
|
7911 |
}
|
|
7912 |
|
|
7913 |
/***/ },
|
|
7914 |
/* 41 */
|
|
7915 |
/***/ function(module, exports, __webpack_require__) {
|
|
7916 |
|
|
7917 |
;(function () {
|
|
7918 |
|
|
7919 |
var object = true ? exports : this; // #8: web workers
|
|
7920 |
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
7921 |
|
|
7922 |
function InvalidCharacterError(message) {
|
|
7923 |
this.message = message;
|
|
7924 |
}
|
|
7925 |
InvalidCharacterError.prototype = new Error;
|
|
7926 |
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
|
7927 |
|
|
7928 |
// encoder
|
|
7929 |
// [https://gist.github.com/999166] by [https://github.com/nignag]
|
|
7930 |
object.btoa || (
|
|
7931 |
object.btoa = function (input) {
|
|
7932 |
for (
|
|
7933 |
// initialize result and counter
|
|
7934 |
var block, charCode, idx = 0, map = chars, output = '';
|
|
7935 |
// if the next input index does not exist:
|
|
7936 |
// change the mapping table to "="
|
|
7937 |
// check if d has no fractional digits
|
|
7938 |
input.charAt(idx | 0) || (map = '=', idx % 1);
|
|
7939 |
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
|
7940 |
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
|
7941 |
) {
|
|
7942 |
charCode = input.charCodeAt(idx += 3/4);
|
|
7943 |
if (charCode > 0xFF) {
|
|
7944 |
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
|
7945 |
}
|
|
7946 |
block = block << 8 | charCode;
|
|
7947 |
}
|
|
7948 |
return output;
|
|
7949 |
});
|
|
7950 |
|
|
7951 |
// decoder
|
|
7952 |
// [https://gist.github.com/1020396] by [https://github.com/atk]
|
|
7953 |
object.atob || (
|
|
7954 |
object.atob = function (input) {
|
|
7955 |
input = input.replace(/=+$/, '');
|
|
7956 |
if (input.length % 4 == 1) {
|
|
7957 |
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
|
|
7958 |
}
|
|
7959 |
for (
|
|
7960 |
// initialize result and counters
|
|
7961 |
var bc = 0, bs, buffer, idx = 0, output = '';
|
|
7962 |
// get next character
|
|
7963 |
buffer = input.charAt(idx++);
|
|
7964 |
// character found in table? initialize bit storage and add its ascii value;
|
|
7965 |
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
|
7966 |
// and if not first of each 4 characters,
|
|
7967 |
// convert the first 8 bits to one ascii character
|
|
7968 |
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
|
|
7969 |
) {
|
|
7970 |
// try to find character in table (0-63, not found => -1)
|
|
7971 |
buffer = chars.indexOf(buffer);
|
|
7972 |
}
|
|
7973 |
return output;
|
|
7974 |
});
|
|
7975 |
|
|
7976 |
}());
|
|
7977 |
|
|
7978 |
|
|
7979 |
/***/ }
|
|
7980 |
/******/ ]);⏎
|