UNPKG

307 kBJavaScriptView Raw
1(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.GitHub = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2'use strict';
3
4var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
5
6var _Requestable2 = require('./Requestable');
7
8var _Requestable3 = _interopRequireDefault(_Requestable2);
9
10function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
12function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
14function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
15
16function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
17 * @file
18 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
19 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
20 * Github.js is freely distributable.
21 */
22
23/**
24 * A Gist can retrieve and modify gists.
25 */
26var Gist = function (_Requestable) {
27 _inherits(Gist, _Requestable);
28
29 /**
30 * Create a Gist.
31 * @param {string} id - the id of the gist (not required when creating a gist)
32 * @param {Requestable.auth} [auth] - information required to authenticate to Github
33 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
34 */
35 function Gist(id, auth, apiBase) {
36 _classCallCheck(this, Gist);
37
38 var _this = _possibleConstructorReturn(this, (Gist.__proto__ || Object.getPrototypeOf(Gist)).call(this, auth, apiBase));
39
40 _this.__id = id;
41 return _this;
42 }
43
44 /**
45 * Fetch a gist.
46 * @see https://developer.github.com/v3/gists/#get-a-single-gist
47 * @param {Requestable.callback} [cb] - will receive the gist
48 * @return {Promise} - the Promise for the http request
49 */
50
51
52 _createClass(Gist, [{
53 key: 'read',
54 value: function read(cb) {
55 return this._request('GET', '/gists/' + this.__id, null, cb);
56 }
57
58 /**
59 * Create a new gist.
60 * @see https://developer.github.com/v3/gists/#create-a-gist
61 * @param {Object} gist - the data for the new gist
62 * @param {Requestable.callback} [cb] - will receive the new gist upon creation
63 * @return {Promise} - the Promise for the http request
64 */
65
66 }, {
67 key: 'create',
68 value: function create(gist, cb) {
69 var _this2 = this;
70
71 return this._request('POST', '/gists', gist, cb).then(function (response) {
72 _this2.__id = response.data.id;
73 return response;
74 });
75 }
76
77 /**
78 * Delete a gist.
79 * @see https://developer.github.com/v3/gists/#delete-a-gist
80 * @param {Requestable.callback} [cb] - will receive true if the request succeeds
81 * @return {Promise} - the Promise for the http request
82 */
83
84 }, {
85 key: 'delete',
86 value: function _delete(cb) {
87 return this._request('DELETE', '/gists/' + this.__id, null, cb);
88 }
89
90 /**
91 * Fork a gist.
92 * @see https://developer.github.com/v3/gists/#fork-a-gist
93 * @param {Requestable.callback} [cb] - the function that will receive the gist
94 * @return {Promise} - the Promise for the http request
95 */
96
97 }, {
98 key: 'fork',
99 value: function fork(cb) {
100 return this._request('POST', '/gists/' + this.__id + '/forks', null, cb);
101 }
102
103 /**
104 * Update a gist.
105 * @see https://developer.github.com/v3/gists/#edit-a-gist
106 * @param {Object} gist - the new data for the gist
107 * @param {Requestable.callback} [cb] - the function that receives the API result
108 * @return {Promise} - the Promise for the http request
109 */
110
111 }, {
112 key: 'update',
113 value: function update(gist, cb) {
114 return this._request('PATCH', '/gists/' + this.__id, gist, cb);
115 }
116
117 /**
118 * Star a gist.
119 * @see https://developer.github.com/v3/gists/#star-a-gist
120 * @param {Requestable.callback} [cb] - will receive true if the request is successful
121 * @return {Promise} - the Promise for the http request
122 */
123
124 }, {
125 key: 'star',
126 value: function star(cb) {
127 return this._request('PUT', '/gists/' + this.__id + '/star', null, cb);
128 }
129
130 /**
131 * Unstar a gist.
132 * @see https://developer.github.com/v3/gists/#unstar-a-gist
133 * @param {Requestable.callback} [cb] - will receive true if the request is successful
134 * @return {Promise} - the Promise for the http request
135 */
136
137 }, {
138 key: 'unstar',
139 value: function unstar(cb) {
140 return this._request('DELETE', '/gists/' + this.__id + '/star', null, cb);
141 }
142
143 /**
144 * Check if a gist is starred by the user.
145 * @see https://developer.github.com/v3/gists/#check-if-a-gist-is-starred
146 * @param {Requestable.callback} [cb] - will receive true if the gist is starred and false if the gist is not starred
147 * @return {Promise} - the Promise for the http request
148 */
149
150 }, {
151 key: 'isStarred',
152 value: function isStarred(cb) {
153 return this._request204or404('/gists/' + this.__id + '/star', null, cb);
154 }
155
156 /**
157 * List the gist's commits
158 * @see https://developer.github.com/v3/gists/#list-gist-commits
159 * @param {Requestable.callback} [cb] - will receive the array of commits
160 * @return {Promise} - the Promise for the http request
161 */
162
163 }, {
164 key: 'listCommits',
165 value: function listCommits(cb) {
166 return this._requestAllPages('/gists/' + this.__id + '/commits', null, cb);
167 }
168
169 /**
170 * Fetch one of the gist's revision.
171 * @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
172 * @param {string} revision - the id of the revision
173 * @param {Requestable.callback} [cb] - will receive the revision
174 * @return {Promise} - the Promise for the http request
175 */
176
177 }, {
178 key: 'getRevision',
179 value: function getRevision(revision, cb) {
180 return this._request('GET', '/gists/' + this.__id + '/' + revision, null, cb);
181 }
182
183 /**
184 * List the gist's comments
185 * @see https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
186 * @param {Requestable.callback} [cb] - will receive the array of comments
187 * @return {Promise} - the promise for the http request
188 */
189
190 }, {
191 key: 'listComments',
192 value: function listComments(cb) {
193 return this._requestAllPages('/gists/' + this.__id + '/comments', null, cb);
194 }
195
196 /**
197 * Fetch one of the gist's comments
198 * @see https://developer.github.com/v3/gists/comments/#get-a-single-comment
199 * @param {number} comment - the id of the comment
200 * @param {Requestable.callback} [cb] - will receive the comment
201 * @return {Promise} - the Promise for the http request
202 */
203
204 }, {
205 key: 'getComment',
206 value: function getComment(comment, cb) {
207 return this._request('GET', '/gists/' + this.__id + '/comments/' + comment, null, cb);
208 }
209
210 /**
211 * Comment on a gist
212 * @see https://developer.github.com/v3/gists/comments/#create-a-comment
213 * @param {string} comment - the comment to add
214 * @param {Requestable.callback} [cb] - the function that receives the API result
215 * @return {Promise} - the Promise for the http request
216 */
217
218 }, {
219 key: 'createComment',
220 value: function createComment(comment, cb) {
221 return this._request('POST', '/gists/' + this.__id + '/comments', { body: comment }, cb);
222 }
223
224 /**
225 * Edit a comment on the gist
226 * @see https://developer.github.com/v3/gists/comments/#edit-a-comment
227 * @param {number} comment - the id of the comment
228 * @param {string} body - the new comment
229 * @param {Requestable.callback} [cb] - will receive the modified comment
230 * @return {Promise} - the promise for the http request
231 */
232
233 }, {
234 key: 'editComment',
235 value: function editComment(comment, body, cb) {
236 return this._request('PATCH', '/gists/' + this.__id + '/comments/' + comment, { body: body }, cb);
237 }
238
239 /**
240 * Delete a comment on the gist.
241 * @see https://developer.github.com/v3/gists/comments/#delete-a-comment
242 * @param {number} comment - the id of the comment
243 * @param {Requestable.callback} [cb] - will receive true if the request succeeds
244 * @return {Promise} - the Promise for the http request
245 */
246
247 }, {
248 key: 'deleteComment',
249 value: function deleteComment(comment, cb) {
250 return this._request('DELETE', '/gists/' + this.__id + '/comments/' + comment, null, cb);
251 }
252 }]);
253
254 return Gist;
255}(_Requestable3.default);
256
257module.exports = Gist;
258
259},{"./Requestable":9}],2:[function(require,module,exports){
260'use strict';
261
262var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /**
263 * @file
264 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
265 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
266 * Github.js is freely distributable.
267 */
268/* eslint valid-jsdoc: ["error", {"requireReturnDescription": false}] */
269
270var _Gist = require('./Gist');
271
272var _Gist2 = _interopRequireDefault(_Gist);
273
274var _User = require('./User');
275
276var _User2 = _interopRequireDefault(_User);
277
278var _Issue = require('./Issue');
279
280var _Issue2 = _interopRequireDefault(_Issue);
281
282var _Search = require('./Search');
283
284var _Search2 = _interopRequireDefault(_Search);
285
286var _RateLimit = require('./RateLimit');
287
288var _RateLimit2 = _interopRequireDefault(_RateLimit);
289
290var _Repository = require('./Repository');
291
292var _Repository2 = _interopRequireDefault(_Repository);
293
294var _Organization = require('./Organization');
295
296var _Organization2 = _interopRequireDefault(_Organization);
297
298var _Team = require('./Team');
299
300var _Team2 = _interopRequireDefault(_Team);
301
302var _Markdown = require('./Markdown');
303
304var _Markdown2 = _interopRequireDefault(_Markdown);
305
306var _Project = require('./Project');
307
308var _Project2 = _interopRequireDefault(_Project);
309
310function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
311
312function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
313
314/**
315 * GitHub encapsulates the functionality to create various API wrapper objects.
316 */
317var GitHub = function () {
318 /**
319 * Create a new GitHub.
320 * @param {Requestable.auth} [auth] - the credentials to authenticate to Github. If auth is
321 * not provided requests will be made unauthenticated
322 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
323 */
324 function GitHub(auth) {
325 var apiBase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'https://api.github.com';
326
327 _classCallCheck(this, GitHub);
328
329 this.__apiBase = apiBase;
330 this.__auth = auth || {};
331 }
332
333 /**
334 * Create a new Gist wrapper
335 * @param {string} [id] - the id for the gist, leave undefined when creating a new gist
336 * @return {Gist}
337 */
338
339
340 _createClass(GitHub, [{
341 key: 'getGist',
342 value: function getGist(id) {
343 return new _Gist2.default(id, this.__auth, this.__apiBase);
344 }
345
346 /**
347 * Create a new User wrapper
348 * @param {string} [user] - the name of the user to get information about
349 * leave undefined for the authenticated user
350 * @return {User}
351 */
352
353 }, {
354 key: 'getUser',
355 value: function getUser(user) {
356 return new _User2.default(user, this.__auth, this.__apiBase);
357 }
358
359 /**
360 * Create a new Organization wrapper
361 * @param {string} organization - the name of the organization
362 * @return {Organization}
363 */
364
365 }, {
366 key: 'getOrganization',
367 value: function getOrganization(organization) {
368 return new _Organization2.default(organization, this.__auth, this.__apiBase);
369 }
370
371 /**
372 * create a new Team wrapper
373 * @param {string} teamId - the name of the team
374 * @return {team}
375 */
376
377 }, {
378 key: 'getTeam',
379 value: function getTeam(teamId) {
380 return new _Team2.default(teamId, this.__auth, this.__apiBase);
381 }
382
383 /**
384 * Create a new Repository wrapper
385 * @param {string} user - the user who owns the repository
386 * @param {string} repo - the name of the repository
387 * @return {Repository}
388 */
389
390 }, {
391 key: 'getRepo',
392 value: function getRepo(user, repo) {
393 return new _Repository2.default(this._getFullName(user, repo), this.__auth, this.__apiBase);
394 }
395
396 /**
397 * Create a new Issue wrapper
398 * @param {string} user - the user who owns the repository
399 * @param {string} repo - the name of the repository
400 * @return {Issue}
401 */
402
403 }, {
404 key: 'getIssues',
405 value: function getIssues(user, repo) {
406 return new _Issue2.default(this._getFullName(user, repo), this.__auth, this.__apiBase);
407 }
408
409 /**
410 * Create a new Search wrapper
411 * @param {string} query - the query to search for
412 * @return {Search}
413 */
414
415 }, {
416 key: 'search',
417 value: function search(query) {
418 return new _Search2.default(query, this.__auth, this.__apiBase);
419 }
420
421 /**
422 * Create a new RateLimit wrapper
423 * @return {RateLimit}
424 */
425
426 }, {
427 key: 'getRateLimit',
428 value: function getRateLimit() {
429 return new _RateLimit2.default(this.__auth, this.__apiBase);
430 }
431
432 /**
433 * Create a new Markdown wrapper
434 * @return {Markdown}
435 */
436
437 }, {
438 key: 'getMarkdown',
439 value: function getMarkdown() {
440 return new _Markdown2.default(this.__auth, this.__apiBase);
441 }
442
443 /**
444 * Create a new Project wrapper
445 * @param {string} id - the id of the project
446 * @return {Project}
447 */
448
449 }, {
450 key: 'getProject',
451 value: function getProject(id) {
452 return new _Project2.default(id, this.__auth, this.__apiBase);
453 }
454
455 /**
456 * Computes the full repository name
457 * @param {string} user - the username (or the full name)
458 * @param {string} repo - the repository name, must not be passed if `user` is the full name
459 * @return {string} the repository's full name
460 */
461
462 }, {
463 key: '_getFullName',
464 value: function _getFullName(user, repo) {
465 var fullname = user;
466
467 if (repo) {
468 fullname = user + '/' + repo;
469 }
470
471 return fullname;
472 }
473 }]);
474
475 return GitHub;
476}();
477
478module.exports = GitHub;
479
480},{"./Gist":1,"./Issue":3,"./Markdown":4,"./Organization":5,"./Project":6,"./RateLimit":7,"./Repository":8,"./Search":10,"./Team":11,"./User":12}],3:[function(require,module,exports){
481'use strict';
482
483var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
484
485var _Requestable2 = require('./Requestable');
486
487var _Requestable3 = _interopRequireDefault(_Requestable2);
488
489function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
490
491function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
492
493function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
494
495function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
496 * @file
497 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
498 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
499 * Github.js is freely distributable.
500 */
501
502/**
503 * Issue wraps the functionality to get issues for repositories
504 */
505var Issue = function (_Requestable) {
506 _inherits(Issue, _Requestable);
507
508 /**
509 * Create a new Issue
510 * @param {string} repository - the full name of the repository (`:user/:repo`) to get issues for
511 * @param {Requestable.auth} [auth] - information required to authenticate to Github
512 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
513 */
514 function Issue(repository, auth, apiBase) {
515 _classCallCheck(this, Issue);
516
517 var _this = _possibleConstructorReturn(this, (Issue.__proto__ || Object.getPrototypeOf(Issue)).call(this, auth, apiBase));
518
519 _this.__repository = repository;
520 return _this;
521 }
522
523 /**
524 * Create a new issue
525 * @see https://developer.github.com/v3/issues/#create-an-issue
526 * @param {Object} issueData - the issue to create
527 * @param {Requestable.callback} [cb] - will receive the created issue
528 * @return {Promise} - the promise for the http request
529 */
530
531
532 _createClass(Issue, [{
533 key: 'createIssue',
534 value: function createIssue(issueData, cb) {
535 return this._request('POST', '/repos/' + this.__repository + '/issues', issueData, cb);
536 }
537
538 /**
539 * List the issues for the repository
540 * @see https://developer.github.com/v3/issues/#list-issues-for-a-repository
541 * @param {Object} options - filtering options
542 * @param {Requestable.callback} [cb] - will receive the array of issues
543 * @return {Promise} - the promise for the http request
544 */
545
546 }, {
547 key: 'listIssues',
548 value: function listIssues(options, cb) {
549 return this._requestAllPages('/repos/' + this.__repository + '/issues', options, cb);
550 }
551
552 /**
553 * List the events for an issue
554 * @see https://developer.github.com/v3/issues/events/#list-events-for-an-issue
555 * @param {number} issue - the issue to get events for
556 * @param {Requestable.callback} [cb] - will receive the list of events
557 * @return {Promise} - the promise for the http request
558 */
559
560 }, {
561 key: 'listIssueEvents',
562 value: function listIssueEvents(issue, cb) {
563 return this._request('GET', '/repos/' + this.__repository + '/issues/' + issue + '/events', null, cb);
564 }
565
566 /**
567 * List comments on an issue
568 * @see https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
569 * @param {number} issue - the id of the issue to get comments from
570 * @param {Requestable.callback} [cb] - will receive the comments
571 * @return {Promise} - the promise for the http request
572 */
573
574 }, {
575 key: 'listIssueComments',
576 value: function listIssueComments(issue, cb) {
577 return this._request('GET', '/repos/' + this.__repository + '/issues/' + issue + '/comments', null, cb);
578 }
579
580 /**
581 * Get a single comment on an issue
582 * @see https://developer.github.com/v3/issues/comments/#get-a-single-comment
583 * @param {number} id - the comment id to get
584 * @param {Requestable.callback} [cb] - will receive the comment
585 * @return {Promise} - the promise for the http request
586 */
587
588 }, {
589 key: 'getIssueComment',
590 value: function getIssueComment(id, cb) {
591 return this._request('GET', '/repos/' + this.__repository + '/issues/comments/' + id, null, cb);
592 }
593
594 /**
595 * Comment on an issue
596 * @see https://developer.github.com/v3/issues/comments/#create-a-comment
597 * @param {number} issue - the id of the issue to comment on
598 * @param {string} comment - the comment to add
599 * @param {Requestable.callback} [cb] - will receive the created comment
600 * @return {Promise} - the promise for the http request
601 */
602
603 }, {
604 key: 'createIssueComment',
605 value: function createIssueComment(issue, comment, cb) {
606 return this._request('POST', '/repos/' + this.__repository + '/issues/' + issue + '/comments', { body: comment }, cb);
607 }
608
609 /**
610 * Edit a comment on an issue
611 * @see https://developer.github.com/v3/issues/comments/#edit-a-comment
612 * @param {number} id - the comment id to edit
613 * @param {string} comment - the comment to edit
614 * @param {Requestable.callback} [cb] - will receive the edited comment
615 * @return {Promise} - the promise for the http request
616 */
617
618 }, {
619 key: 'editIssueComment',
620 value: function editIssueComment(id, comment, cb) {
621 return this._request('PATCH', '/repos/' + this.__repository + '/issues/comments/' + id, { body: comment }, cb);
622 }
623
624 /**
625 * Delete a comment on an issue
626 * @see https://developer.github.com/v3/issues/comments/#delete-a-comment
627 * @param {number} id - the comment id to delete
628 * @param {Requestable.callback} [cb] - will receive true if the request is successful
629 * @return {Promise} - the promise for the http request
630 */
631
632 }, {
633 key: 'deleteIssueComment',
634 value: function deleteIssueComment(id, cb) {
635 return this._request('DELETE', '/repos/' + this.__repository + '/issues/comments/' + id, null, cb);
636 }
637
638 /**
639 * Edit an issue
640 * @see https://developer.github.com/v3/issues/#edit-an-issue
641 * @param {number} issue - the issue number to edit
642 * @param {Object} issueData - the new issue data
643 * @param {Requestable.callback} [cb] - will receive the modified issue
644 * @return {Promise} - the promise for the http request
645 */
646
647 }, {
648 key: 'editIssue',
649 value: function editIssue(issue, issueData, cb) {
650 return this._request('PATCH', '/repos/' + this.__repository + '/issues/' + issue, issueData, cb);
651 }
652
653 /**
654 * Get a particular issue
655 * @see https://developer.github.com/v3/issues/#get-a-single-issue
656 * @param {number} issue - the issue number to fetch
657 * @param {Requestable.callback} [cb] - will receive the issue
658 * @return {Promise} - the promise for the http request
659 */
660
661 }, {
662 key: 'getIssue',
663 value: function getIssue(issue, cb) {
664 return this._request('GET', '/repos/' + this.__repository + '/issues/' + issue, null, cb);
665 }
666
667 /**
668 * List the milestones for the repository
669 * @see https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
670 * @param {Object} options - filtering options
671 * @param {Requestable.callback} [cb] - will receive the array of milestones
672 * @return {Promise} - the promise for the http request
673 */
674
675 }, {
676 key: 'listMilestones',
677 value: function listMilestones(options, cb) {
678 return this._request('GET', '/repos/' + this.__repository + '/milestones', options, cb);
679 }
680
681 /**
682 * Get a milestone
683 * @see https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
684 * @param {string} milestone - the id of the milestone to fetch
685 * @param {Requestable.callback} [cb] - will receive the milestone
686 * @return {Promise} - the promise for the http request
687 */
688
689 }, {
690 key: 'getMilestone',
691 value: function getMilestone(milestone, cb) {
692 return this._request('GET', '/repos/' + this.__repository + '/milestones/' + milestone, null, cb);
693 }
694
695 /**
696 * Create a new milestone
697 * @see https://developer.github.com/v3/issues/milestones/#create-a-milestone
698 * @param {Object} milestoneData - the milestone definition
699 * @param {Requestable.callback} [cb] - will receive the milestone
700 * @return {Promise} - the promise for the http request
701 */
702
703 }, {
704 key: 'createMilestone',
705 value: function createMilestone(milestoneData, cb) {
706 return this._request('POST', '/repos/' + this.__repository + '/milestones', milestoneData, cb);
707 }
708
709 /**
710 * Edit a milestone
711 * @see https://developer.github.com/v3/issues/milestones/#update-a-milestone
712 * @param {string} milestone - the id of the milestone to edit
713 * @param {Object} milestoneData - the updates to make to the milestone
714 * @param {Requestable.callback} [cb] - will receive the updated milestone
715 * @return {Promise} - the promise for the http request
716 */
717
718 }, {
719 key: 'editMilestone',
720 value: function editMilestone(milestone, milestoneData, cb) {
721 return this._request('PATCH', '/repos/' + this.__repository + '/milestones/' + milestone, milestoneData, cb);
722 }
723
724 /**
725 * Delete a milestone (this is distinct from closing a milestone)
726 * @see https://developer.github.com/v3/issues/milestones/#delete-a-milestone
727 * @param {string} milestone - the id of the milestone to delete
728 * @param {Requestable.callback} [cb] - will receive the status
729 * @return {Promise} - the promise for the http request
730 */
731
732 }, {
733 key: 'deleteMilestone',
734 value: function deleteMilestone(milestone, cb) {
735 return this._request('DELETE', '/repos/' + this.__repository + '/milestones/' + milestone, null, cb);
736 }
737
738 /**
739 * Create a new label
740 * @see https://developer.github.com/v3/issues/labels/#create-a-label
741 * @param {Object} labelData - the label definition
742 * @param {Requestable.callback} [cb] - will receive the object representing the label
743 * @return {Promise} - the promise for the http request
744 */
745
746 }, {
747 key: 'createLabel',
748 value: function createLabel(labelData, cb) {
749 return this._request('POST', '/repos/' + this.__repository + '/labels', labelData, cb);
750 }
751
752 /**
753 * List the labels for the repository
754 * @see https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
755 * @param {Object} options - filtering options
756 * @param {Requestable.callback} [cb] - will receive the array of labels
757 * @return {Promise} - the promise for the http request
758 */
759
760 }, {
761 key: 'listLabels',
762 value: function listLabels(options, cb) {
763 return this._request('GET', '/repos/' + this.__repository + '/labels', options, cb);
764 }
765
766 /**
767 * Get a label
768 * @see https://developer.github.com/v3/issues/labels/#get-a-single-label
769 * @param {string} label - the name of the label to fetch
770 * @param {Requestable.callback} [cb] - will receive the label
771 * @return {Promise} - the promise for the http request
772 */
773
774 }, {
775 key: 'getLabel',
776 value: function getLabel(label, cb) {
777 return this._request('GET', '/repos/' + this.__repository + '/labels/' + label, null, cb);
778 }
779
780 /**
781 * Edit a label
782 * @see https://developer.github.com/v3/issues/labels/#update-a-label
783 * @param {string} label - the name of the label to edit
784 * @param {Object} labelData - the updates to make to the label
785 * @param {Requestable.callback} [cb] - will receive the updated label
786 * @return {Promise} - the promise for the http request
787 */
788
789 }, {
790 key: 'editLabel',
791 value: function editLabel(label, labelData, cb) {
792 return this._request('PATCH', '/repos/' + this.__repository + '/labels/' + label, labelData, cb);
793 }
794
795 /**
796 * Delete a label
797 * @see https://developer.github.com/v3/issues/labels/#delete-a-label
798 * @param {string} label - the name of the label to delete
799 * @param {Requestable.callback} [cb] - will receive the status
800 * @return {Promise} - the promise for the http request
801 */
802
803 }, {
804 key: 'deleteLabel',
805 value: function deleteLabel(label, cb) {
806 return this._request('DELETE', '/repos/' + this.__repository + '/labels/' + label, null, cb);
807 }
808 }]);
809
810 return Issue;
811}(_Requestable3.default);
812
813module.exports = Issue;
814
815},{"./Requestable":9}],4:[function(require,module,exports){
816'use strict';
817
818var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
819
820var _Requestable2 = require('./Requestable');
821
822var _Requestable3 = _interopRequireDefault(_Requestable2);
823
824function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
825
826function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
827
828function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
829
830function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
831 * @file
832 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
833 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
834 * Github.js is freely distributable.
835 */
836
837/**
838 * Renders html from Markdown text
839 */
840var Markdown = function (_Requestable) {
841 _inherits(Markdown, _Requestable);
842
843 /**
844 * construct a Markdown
845 * @param {Requestable.auth} auth - the credentials to authenticate to GitHub
846 * @param {string} [apiBase] - the base Github API URL
847 * @return {Promise} - the promise for the http request
848 */
849 function Markdown(auth, apiBase) {
850 _classCallCheck(this, Markdown);
851
852 return _possibleConstructorReturn(this, (Markdown.__proto__ || Object.getPrototypeOf(Markdown)).call(this, auth, apiBase));
853 }
854
855 /**
856 * Render html from Markdown text.
857 * @see https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document
858 * @param {Object} options - conversion options
859 * @param {string} [options.text] - the markdown text to convert
860 * @param {string} [options.mode=markdown] - can be either `markdown` or `gfm`
861 * @param {string} [options.context] - repository name if mode is gfm
862 * @param {Requestable.callback} [cb] - will receive the converted html
863 * @return {Promise} - the promise for the http request
864 */
865
866
867 _createClass(Markdown, [{
868 key: 'render',
869 value: function render(options, cb) {
870 return this._request('POST', '/markdown', options, cb, true);
871 }
872 }]);
873
874 return Markdown;
875}(_Requestable3.default);
876
877module.exports = Markdown;
878
879},{"./Requestable":9}],5:[function(require,module,exports){
880'use strict';
881
882var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
883
884var _Requestable2 = require('./Requestable');
885
886var _Requestable3 = _interopRequireDefault(_Requestable2);
887
888function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
889
890function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
891
892function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
893
894function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
895 * @file
896 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
897 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
898 * Github.js is freely distributable.
899 */
900
901/**
902 * Organization encapsulates the functionality to create repositories in organizations
903 */
904var Organization = function (_Requestable) {
905 _inherits(Organization, _Requestable);
906
907 /**
908 * Create a new Organization
909 * @param {string} organization - the name of the organization
910 * @param {Requestable.auth} [auth] - information required to authenticate to Github
911 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
912 */
913 function Organization(organization, auth, apiBase) {
914 _classCallCheck(this, Organization);
915
916 var _this = _possibleConstructorReturn(this, (Organization.__proto__ || Object.getPrototypeOf(Organization)).call(this, auth, apiBase));
917
918 _this.__name = organization;
919 return _this;
920 }
921
922 /**
923 * Create a repository in an organization
924 * @see https://developer.github.com/v3/repos/#create
925 * @param {Object} options - the repository definition
926 * @param {Requestable.callback} [cb] - will receive the created repository
927 * @return {Promise} - the promise for the http request
928 */
929
930
931 _createClass(Organization, [{
932 key: 'createRepo',
933 value: function createRepo(options, cb) {
934 return this._request('POST', '/orgs/' + this.__name + '/repos', options, cb);
935 }
936
937 /**
938 * List the repositories in an organization
939 * @see https://developer.github.com/v3/repos/#list-organization-repositories
940 * @param {Requestable.callback} [cb] - will receive the list of repositories
941 * @return {Promise} - the promise for the http request
942 */
943
944 }, {
945 key: 'getRepos',
946 value: function getRepos(cb) {
947 var requestOptions = this._getOptionsWithDefaults({ direction: 'desc' });
948
949 return this._requestAllPages('/orgs/' + this.__name + '/repos', requestOptions, cb);
950 }
951
952 /**
953 * Query if the user is a member or not
954 * @param {string} username - the user in question
955 * @param {Requestable.callback} [cb] - will receive true if the user is a member
956 * @return {Promise} - the promise for the http request
957 */
958
959 }, {
960 key: 'isMember',
961 value: function isMember(username, cb) {
962 return this._request204or404('/orgs/' + this.__name + '/members/' + username, null, cb);
963 }
964
965 /**
966 * List the users who are members of the company
967 * @see https://developer.github.com/v3/orgs/members/#members-list
968 * @param {object} options - filtering options
969 * @param {string} [options.filter=all] - can be either `2fa_disabled` or `all`
970 * @param {string} [options.role=all] - can be one of: `all`, `admin`, or `member`
971 * @param {Requestable.callback} [cb] - will receive the list of users
972 * @return {Promise} - the promise for the http request
973 */
974
975 }, {
976 key: 'listMembers',
977 value: function listMembers(options, cb) {
978 return this._request('GET', '/orgs/' + this.__name + '/members', options, cb);
979 }
980
981 /**
982 * List the Teams in the Organization
983 * @see https://developer.github.com/v3/orgs/teams/#list-teams
984 * @param {Requestable.callback} [cb] - will receive the list of teams
985 * @return {Promise} - the promise for the http request
986 */
987
988 }, {
989 key: 'getTeams',
990 value: function getTeams(cb) {
991 return this._requestAllPages('/orgs/' + this.__name + '/teams', undefined, cb);
992 }
993
994 /**
995 * Create a team
996 * @see https://developer.github.com/v3/orgs/teams/#create-team
997 * @param {object} options - Team creation parameters
998 * @param {string} options.name - The name of the team
999 * @param {string} [options.description] - Team description
1000 * @param {string} [options.repo_names] - Repos to add the team to
1001 * @param {string} [options.privacy=secret] - The level of privacy the team should have. Can be either one
1002 * of: `secret`, or `closed`
1003 * @param {Requestable.callback} [cb] - will receive the created team
1004 * @return {Promise} - the promise for the http request
1005 */
1006
1007 }, {
1008 key: 'createTeam',
1009 value: function createTeam(options, cb) {
1010 return this._request('POST', '/orgs/' + this.__name + '/teams', options, cb);
1011 }
1012
1013 /**
1014 * Get information about all projects
1015 * @see https://developer.github.com/v3/projects/#list-organization-projects
1016 * @param {Requestable.callback} [cb] - will receive the list of projects
1017 * @return {Promise} - the promise for the http request
1018 */
1019
1020 }, {
1021 key: 'listProjects',
1022 value: function listProjects(cb) {
1023 return this._requestAllPages('/orgs/' + this.__name + '/projects', { AcceptHeader: 'inertia-preview' }, cb);
1024 }
1025
1026 /**
1027 * Create a new project
1028 * @see https://developer.github.com/v3/repos/projects/#create-a-project
1029 * @param {Object} options - the description of the project
1030 * @param {Requestable.callback} cb - will receive the newly created project
1031 * @return {Promise} - the promise for the http request
1032 */
1033
1034 }, {
1035 key: 'createProject',
1036 value: function createProject(options, cb) {
1037 options = options || {};
1038 options.AcceptHeader = 'inertia-preview';
1039 return this._request('POST', '/orgs/' + this.__name + '/projects', options, cb);
1040 }
1041 }]);
1042
1043 return Organization;
1044}(_Requestable3.default);
1045
1046module.exports = Organization;
1047
1048},{"./Requestable":9}],6:[function(require,module,exports){
1049'use strict';
1050
1051var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1052
1053var _Requestable2 = require('./Requestable');
1054
1055var _Requestable3 = _interopRequireDefault(_Requestable2);
1056
1057function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1058
1059function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
1060
1061function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1062
1063function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1064
1065function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
1066 * @file
1067 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
1068 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
1069 * Github.js is freely distributable.
1070 */
1071
1072/**
1073 * Project encapsulates the functionality to create, query, and modify cards and columns.
1074 */
1075var Project = function (_Requestable) {
1076 _inherits(Project, _Requestable);
1077
1078 /**
1079 * Create a Project.
1080 * @param {string} id - the id of the project
1081 * @param {Requestable.auth} [auth] - information required to authenticate to Github
1082 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
1083 */
1084 function Project(id, auth, apiBase) {
1085 _classCallCheck(this, Project);
1086
1087 var _this = _possibleConstructorReturn(this, (Project.__proto__ || Object.getPrototypeOf(Project)).call(this, auth, apiBase, 'inertia-preview'));
1088
1089 _this.__id = id;
1090 return _this;
1091 }
1092
1093 /**
1094 * Get information about a project
1095 * @see https://developer.github.com/v3/projects/#get-a-project
1096 * @param {Requestable.callback} cb - will receive the project information
1097 * @return {Promise} - the promise for the http request
1098 */
1099
1100
1101 _createClass(Project, [{
1102 key: 'getProject',
1103 value: function getProject(cb) {
1104 return this._request('GET', '/projects/' + this.__id, null, cb);
1105 }
1106
1107 /**
1108 * Edit a project
1109 * @see https://developer.github.com/v3/projects/#update-a-project
1110 * @param {Object} options - the description of the project
1111 * @param {Requestable.callback} cb - will receive the modified project
1112 * @return {Promise} - the promise for the http request
1113 */
1114
1115 }, {
1116 key: 'updateProject',
1117 value: function updateProject(options, cb) {
1118 return this._request('PATCH', '/projects/' + this.__id, options, cb);
1119 }
1120
1121 /**
1122 * Delete a project
1123 * @see https://developer.github.com/v3/projects/#delete-a-project
1124 * @param {Requestable.callback} cb - will receive true if the operation is successful
1125 * @return {Promise} - the promise for the http request
1126 */
1127
1128 }, {
1129 key: 'deleteProject',
1130 value: function deleteProject(cb) {
1131 return this._request('DELETE', '/projects/' + this.__id, null, cb);
1132 }
1133
1134 /**
1135 * Get information about all columns of a project
1136 * @see https://developer.github.com/v3/projects/columns/#list-project-columns
1137 * @param {Requestable.callback} [cb] - will receive the list of columns
1138 * @return {Promise} - the promise for the http request
1139 */
1140
1141 }, {
1142 key: 'listProjectColumns',
1143 value: function listProjectColumns(cb) {
1144 return this._requestAllPages('/projects/' + this.__id + '/columns', null, cb);
1145 }
1146
1147 /**
1148 * Get information about a column
1149 * @see https://developer.github.com/v3/projects/columns/#get-a-project-column
1150 * @param {string} colId - the id of the column
1151 * @param {Requestable.callback} cb - will receive the column information
1152 * @return {Promise} - the promise for the http request
1153 */
1154
1155 }, {
1156 key: 'getProjectColumn',
1157 value: function getProjectColumn(colId, cb) {
1158 return this._request('GET', '/projects/columns/' + colId, null, cb);
1159 }
1160
1161 /**
1162 * Create a new column
1163 * @see https://developer.github.com/v3/projects/columns/#create-a-project-column
1164 * @param {Object} options - the description of the column
1165 * @param {Requestable.callback} cb - will receive the newly created column
1166 * @return {Promise} - the promise for the http request
1167 */
1168
1169 }, {
1170 key: 'createProjectColumn',
1171 value: function createProjectColumn(options, cb) {
1172 return this._request('POST', '/projects/' + this.__id + '/columns', options, cb);
1173 }
1174
1175 /**
1176 * Edit a column
1177 * @see https://developer.github.com/v3/projects/columns/#update-a-project-column
1178 * @param {string} colId - the column id
1179 * @param {Object} options - the description of the column
1180 * @param {Requestable.callback} cb - will receive the modified column
1181 * @return {Promise} - the promise for the http request
1182 */
1183
1184 }, {
1185 key: 'updateProjectColumn',
1186 value: function updateProjectColumn(colId, options, cb) {
1187 return this._request('PATCH', '/projects/columns/' + colId, options, cb);
1188 }
1189
1190 /**
1191 * Delete a column
1192 * @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
1193 * @param {string} colId - the column to be deleted
1194 * @param {Requestable.callback} cb - will receive true if the operation is successful
1195 * @return {Promise} - the promise for the http request
1196 */
1197
1198 }, {
1199 key: 'deleteProjectColumn',
1200 value: function deleteProjectColumn(colId, cb) {
1201 return this._request('DELETE', '/projects/columns/' + colId, null, cb);
1202 }
1203
1204 /**
1205 * Move a column
1206 * @see https://developer.github.com/v3/projects/columns/#move-a-project-column
1207 * @param {string} colId - the column to be moved
1208 * @param {string} position - can be one of first, last, or after:<column-id>,
1209 * where <column-id> is the id value of a column in the same project.
1210 * @param {Requestable.callback} cb - will receive true if the operation is successful
1211 * @return {Promise} - the promise for the http request
1212 */
1213
1214 }, {
1215 key: 'moveProjectColumn',
1216 value: function moveProjectColumn(colId, position, cb) {
1217 return this._request('POST', '/projects/columns/' + colId + '/moves', { position: position }, cb);
1218 }
1219
1220 /**
1221 * Get information about all cards of a project
1222 * @see https://developer.github.com/v3/projects/cards/#list-project-cards
1223 * @param {Requestable.callback} [cb] - will receive the list of cards
1224 * @return {Promise} - the promise for the http request
1225 */
1226
1227 }, {
1228 key: 'listProjectCards',
1229 value: function listProjectCards(cb) {
1230 var _this2 = this;
1231
1232 return this.listProjectColumns().then(function (_ref) {
1233 var data = _ref.data;
1234
1235 return Promise.all(data.map(function (column) {
1236 return _this2._requestAllPages('/projects/columns/' + column.id + '/cards', null);
1237 }));
1238 }).then(function (cardsInColumns) {
1239 var cards = cardsInColumns.reduce(function (prev, _ref2) {
1240 var data = _ref2.data;
1241
1242 prev.push.apply(prev, _toConsumableArray(data));
1243 return prev;
1244 }, []);
1245 if (cb) {
1246 cb(null, cards);
1247 }
1248 return cards;
1249 }).catch(function (err) {
1250 if (cb) {
1251 cb(err);
1252 return;
1253 }
1254 throw err;
1255 });
1256 }
1257
1258 /**
1259 * Get information about all cards of a column
1260 * @see https://developer.github.com/v3/projects/cards/#list-project-cards
1261 * @param {string} colId - the id of the column
1262 * @param {Requestable.callback} [cb] - will receive the list of cards
1263 * @return {Promise} - the promise for the http request
1264 */
1265
1266 }, {
1267 key: 'listColumnCards',
1268 value: function listColumnCards(colId, cb) {
1269 return this._requestAllPages('/projects/columns/' + colId + '/cards', null, cb);
1270 }
1271
1272 /**
1273 * Get information about a card
1274 * @see https://developer.github.com/v3/projects/cards/#get-a-project-card
1275 * @param {string} cardId - the id of the card
1276 * @param {Requestable.callback} cb - will receive the card information
1277 * @return {Promise} - the promise for the http request
1278 */
1279
1280 }, {
1281 key: 'getProjectCard',
1282 value: function getProjectCard(cardId, cb) {
1283 return this._request('GET', '/projects/columns/cards/' + cardId, null, cb);
1284 }
1285
1286 /**
1287 * Create a new card
1288 * @see https://developer.github.com/v3/projects/cards/#create-a-project-card
1289 * @param {string} colId - the column id
1290 * @param {Object} options - the description of the card
1291 * @param {Requestable.callback} cb - will receive the newly created card
1292 * @return {Promise} - the promise for the http request
1293 */
1294
1295 }, {
1296 key: 'createProjectCard',
1297 value: function createProjectCard(colId, options, cb) {
1298 return this._request('POST', '/projects/columns/' + colId + '/cards', options, cb);
1299 }
1300
1301 /**
1302 * Edit a card
1303 * @see https://developer.github.com/v3/projects/cards/#update-a-project-card
1304 * @param {string} cardId - the card id
1305 * @param {Object} options - the description of the card
1306 * @param {Requestable.callback} cb - will receive the modified card
1307 * @return {Promise} - the promise for the http request
1308 */
1309
1310 }, {
1311 key: 'updateProjectCard',
1312 value: function updateProjectCard(cardId, options, cb) {
1313 return this._request('PATCH', '/projects/columns/cards/' + cardId, options, cb);
1314 }
1315
1316 /**
1317 * Delete a card
1318 * @see https://developer.github.com/v3/projects/cards/#delete-a-project-card
1319 * @param {string} cardId - the card to be deleted
1320 * @param {Requestable.callback} cb - will receive true if the operation is successful
1321 * @return {Promise} - the promise for the http request
1322 */
1323
1324 }, {
1325 key: 'deleteProjectCard',
1326 value: function deleteProjectCard(cardId, cb) {
1327 return this._request('DELETE', '/projects/columns/cards/' + cardId, null, cb);
1328 }
1329
1330 /**
1331 * Move a card
1332 * @see https://developer.github.com/v3/projects/cards/#move-a-project-card
1333 * @param {string} cardId - the card to be moved
1334 * @param {string} position - can be one of top, bottom, or after:<card-id>,
1335 * where <card-id> is the id value of a card in the same project.
1336 * @param {string} colId - the id value of a column in the same project.
1337 * @param {Requestable.callback} cb - will receive true if the operation is successful
1338 * @return {Promise} - the promise for the http request
1339 */
1340
1341 }, {
1342 key: 'moveProjectCard',
1343 value: function moveProjectCard(cardId, position, colId, cb) {
1344 return this._request('POST', '/projects/columns/cards/' + cardId + '/moves', { position: position, column_id: colId }, // eslint-disable-line camelcase
1345 cb);
1346 }
1347 }]);
1348
1349 return Project;
1350}(_Requestable3.default);
1351
1352module.exports = Project;
1353
1354},{"./Requestable":9}],7:[function(require,module,exports){
1355'use strict';
1356
1357var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1358
1359var _Requestable2 = require('./Requestable');
1360
1361var _Requestable3 = _interopRequireDefault(_Requestable2);
1362
1363function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1364
1365function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1366
1367function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1368
1369function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
1370 * @file
1371 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
1372 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
1373 * Github.js is freely distributable.
1374 */
1375
1376/**
1377 * RateLimit allows users to query their rate-limit status
1378 */
1379var RateLimit = function (_Requestable) {
1380 _inherits(RateLimit, _Requestable);
1381
1382 /**
1383 * construct a RateLimit
1384 * @param {Requestable.auth} auth - the credentials to authenticate to GitHub
1385 * @param {string} [apiBase] - the base Github API URL
1386 * @return {Promise} - the promise for the http request
1387 */
1388 function RateLimit(auth, apiBase) {
1389 _classCallCheck(this, RateLimit);
1390
1391 return _possibleConstructorReturn(this, (RateLimit.__proto__ || Object.getPrototypeOf(RateLimit)).call(this, auth, apiBase));
1392 }
1393
1394 /**
1395 * Query the current rate limit
1396 * @see https://developer.github.com/v3/rate_limit/
1397 * @param {Requestable.callback} [cb] - will receive the rate-limit data
1398 * @return {Promise} - the promise for the http request
1399 */
1400
1401
1402 _createClass(RateLimit, [{
1403 key: 'getRateLimit',
1404 value: function getRateLimit(cb) {
1405 return this._request('GET', '/rate_limit', null, cb);
1406 }
1407 }]);
1408
1409 return RateLimit;
1410}(_Requestable3.default);
1411
1412module.exports = RateLimit;
1413
1414},{"./Requestable":9}],8:[function(require,module,exports){
1415(function (Buffer){(function (){
1416'use strict';
1417
1418var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
1419
1420var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
1421
1422var _Requestable2 = require('./Requestable');
1423
1424var _Requestable3 = _interopRequireDefault(_Requestable2);
1425
1426var _utf = require('utf8');
1427
1428var _utf2 = _interopRequireDefault(_utf);
1429
1430var _jsBase = require('js-base64');
1431
1432var _debug = require('debug');
1433
1434var _debug2 = _interopRequireDefault(_debug);
1435
1436function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1437
1438function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1439
1440function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
1441
1442function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
1443 * @file
1444 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
1445 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
1446 * Github.js is freely distributable.
1447 */
1448
1449var log = (0, _debug2.default)('github:repository');
1450
1451/**
1452 * Repository encapsulates the functionality to create, query, and modify files.
1453 */
1454
1455var Repository = function (_Requestable) {
1456 _inherits(Repository, _Requestable);
1457
1458 /**
1459 * Create a Repository.
1460 * @param {string} fullname - the full name of the repository
1461 * @param {Requestable.auth} [auth] - information required to authenticate to Github
1462 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
1463 */
1464 function Repository(fullname, auth, apiBase) {
1465 _classCallCheck(this, Repository);
1466
1467 var _this = _possibleConstructorReturn(this, (Repository.__proto__ || Object.getPrototypeOf(Repository)).call(this, auth, apiBase));
1468
1469 _this.__fullname = fullname;
1470 _this.__currentTree = {
1471 branch: null,
1472 sha: null
1473 };
1474 return _this;
1475 }
1476
1477 /**
1478 * Get a reference
1479 * @see https://developer.github.com/v3/git/refs/#get-a-reference
1480 * @param {string} ref - the reference to get
1481 * @param {Requestable.callback} [cb] - will receive the reference's refSpec or a list of refSpecs that match `ref`
1482 * @return {Promise} - the promise for the http request
1483 */
1484
1485
1486 _createClass(Repository, [{
1487 key: 'getRef',
1488 value: function getRef(ref, cb) {
1489 return this._request('GET', '/repos/' + this.__fullname + '/git/refs/' + ref, null, cb);
1490 }
1491
1492 /**
1493 * Create a reference
1494 * @see https://developer.github.com/v3/git/refs/#create-a-reference
1495 * @param {Object} options - the object describing the ref
1496 * @param {Requestable.callback} [cb] - will receive the ref
1497 * @return {Promise} - the promise for the http request
1498 */
1499
1500 }, {
1501 key: 'createRef',
1502 value: function createRef(options, cb) {
1503 return this._request('POST', '/repos/' + this.__fullname + '/git/refs', options, cb);
1504 }
1505
1506 /**
1507 * Delete a reference
1508 * @see https://developer.github.com/v3/git/refs/#delete-a-reference
1509 * @param {string} ref - the name of the ref to delte
1510 * @param {Requestable.callback} [cb] - will receive true if the request is successful
1511 * @return {Promise} - the promise for the http request
1512 */
1513
1514 }, {
1515 key: 'deleteRef',
1516 value: function deleteRef(ref, cb) {
1517 return this._request('DELETE', '/repos/' + this.__fullname + '/git/refs/' + ref, null, cb);
1518 }
1519
1520 /**
1521 * Delete a repository
1522 * @see https://developer.github.com/v3/repos/#delete-a-repository
1523 * @param {Requestable.callback} [cb] - will receive true if the request is successful
1524 * @return {Promise} - the promise for the http request
1525 */
1526
1527 }, {
1528 key: 'deleteRepo',
1529 value: function deleteRepo(cb) {
1530 return this._request('DELETE', '/repos/' + this.__fullname, null, cb);
1531 }
1532
1533 /**
1534 * List the tags on a repository
1535 * @see https://developer.github.com/v3/repos/#list-tags
1536 * @param {Requestable.callback} [cb] - will receive the tag data
1537 * @return {Promise} - the promise for the http request
1538 */
1539
1540 }, {
1541 key: 'listTags',
1542 value: function listTags(cb) {
1543 return this._request('GET', '/repos/' + this.__fullname + '/tags', null, cb);
1544 }
1545
1546 /**
1547 * List the open pull requests on the repository
1548 * @see https://developer.github.com/v3/pulls/#list-pull-requests
1549 * @param {Object} options - options to filter the search
1550 * @param {Requestable.callback} [cb] - will receive the list of PRs
1551 * @return {Promise} - the promise for the http request
1552 */
1553
1554 }, {
1555 key: 'listPullRequests',
1556 value: function listPullRequests(options, cb) {
1557 options = options || {};
1558 return this._request('GET', '/repos/' + this.__fullname + '/pulls', options, cb);
1559 }
1560
1561 /**
1562 * Get information about a specific pull request
1563 * @see https://developer.github.com/v3/pulls/#get-a-single-pull-request
1564 * @param {number} number - the PR you wish to fetch
1565 * @param {Requestable.callback} [cb] - will receive the PR from the API
1566 * @return {Promise} - the promise for the http request
1567 */
1568
1569 }, {
1570 key: 'getPullRequest',
1571 value: function getPullRequest(number, cb) {
1572 return this._request('GET', '/repos/' + this.__fullname + '/pulls/' + number, null, cb);
1573 }
1574
1575 /**
1576 * List the files of a specific pull request
1577 * @see https://developer.github.com/v3/pulls/#list-pull-requests-files
1578 * @param {number|string} number - the PR you wish to fetch
1579 * @param {Requestable.callback} [cb] - will receive the list of files from the API
1580 * @return {Promise} - the promise for the http request
1581 */
1582
1583 }, {
1584 key: 'listPullRequestFiles',
1585 value: function listPullRequestFiles(number, cb) {
1586 return this._request('GET', '/repos/' + this.__fullname + '/pulls/' + number + '/files', null, cb);
1587 }
1588
1589 /**
1590 * Compare two branches/commits/repositories
1591 * @see https://developer.github.com/v3/repos/commits/#compare-two-commits
1592 * @param {string} base - the base commit
1593 * @param {string} head - the head commit
1594 * @param {Requestable.callback} cb - will receive the comparison
1595 * @return {Promise} - the promise for the http request
1596 */
1597
1598 }, {
1599 key: 'compareBranches',
1600 value: function compareBranches(base, head, cb) {
1601 return this._request('GET', '/repos/' + this.__fullname + '/compare/' + base + '...' + head, null, cb);
1602 }
1603
1604 /**
1605 * List all the branches for the repository
1606 * @see https://developer.github.com/v3/repos/#list-branches
1607 * @param {Requestable.callback} cb - will receive the list of branches
1608 * @return {Promise} - the promise for the http request
1609 */
1610
1611 }, {
1612 key: 'listBranches',
1613 value: function listBranches(cb) {
1614 return this._request('GET', '/repos/' + this.__fullname + '/branches', null, cb);
1615 }
1616
1617 /**
1618 * Get a raw blob from the repository
1619 * @see https://developer.github.com/v3/git/blobs/#get-a-blob
1620 * @param {string} sha - the sha of the blob to fetch
1621 * @param {Requestable.callback} cb - will receive the blob from the API
1622 * @return {Promise} - the promise for the http request
1623 */
1624
1625 }, {
1626 key: 'getBlob',
1627 value: function getBlob(sha, cb) {
1628 return this._request('GET', '/repos/' + this.__fullname + '/git/blobs/' + sha, null, cb, 'raw');
1629 }
1630
1631 /**
1632 * Get a single branch
1633 * @see https://developer.github.com/v3/repos/branches/#get-branch
1634 * @param {string} branch - the name of the branch to fetch
1635 * @param {Requestable.callback} cb - will receive the branch from the API
1636 * @returns {Promise} - the promise for the http request
1637 */
1638
1639 }, {
1640 key: 'getBranch',
1641 value: function getBranch(branch, cb) {
1642 return this._request('GET', '/repos/' + this.__fullname + '/branches/' + branch, null, cb);
1643 }
1644
1645 /**
1646 * Get a commit from the repository
1647 * @see https://developer.github.com/v3/repos/commits/#get-a-single-commit
1648 * @param {string} sha - the sha for the commit to fetch
1649 * @param {Requestable.callback} cb - will receive the commit data
1650 * @return {Promise} - the promise for the http request
1651 */
1652
1653 }, {
1654 key: 'getCommit',
1655 value: function getCommit(sha, cb) {
1656 return this._request('GET', '/repos/' + this.__fullname + '/git/commits/' + sha, null, cb);
1657 }
1658
1659 /**
1660 * List the commits on a repository, optionally filtering by path, author or time range
1661 * @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
1662 * @param {Object} [options] - the filtering options for commits
1663 * @param {string} [options.sha] - the SHA or branch to start from
1664 * @param {string} [options.path] - the path to search on
1665 * @param {string} [options.author] - the commit author
1666 * @param {(Date|string)} [options.since] - only commits after this date will be returned
1667 * @param {(Date|string)} [options.until] - only commits before this date will be returned
1668 * @param {Requestable.callback} cb - will receive the list of commits found matching the criteria
1669 * @return {Promise} - the promise for the http request
1670 */
1671
1672 }, {
1673 key: 'listCommits',
1674 value: function listCommits(options, cb) {
1675 options = options || {};
1676 if (typeof options === 'function') {
1677 cb = options;
1678 options = {};
1679 }
1680 options.since = this._dateToISO(options.since);
1681 options.until = this._dateToISO(options.until);
1682
1683 return this._request('GET', '/repos/' + this.__fullname + '/commits', options, cb);
1684 }
1685
1686 /**
1687 * List the commits on a pull request
1688 * @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
1689 * @param {number|string} number - the number of the pull request to list the commits
1690 * @param {Object} [options] - the filtering options for commits
1691 * @param {Requestable.callback} [cb] - will receive the commits information
1692 * @return {Promise} - the promise for the http request
1693 */
1694
1695 }, {
1696 key: 'listCommitsOnPR',
1697 value: function listCommitsOnPR(number, options, cb) {
1698 options = options || {};
1699 if (typeof options === 'function') {
1700 cb = options;
1701 options = {};
1702 }
1703 return this._request('GET', '/repos/' + this.__fullname + '/pulls/' + number + '/commits', options, cb);
1704 }
1705
1706 /**
1707 * Gets a single commit information for a repository
1708 * @see https://developer.github.com/v3/repos/commits/#get-a-single-commit
1709 * @param {string} ref - the reference for the commit-ish
1710 * @param {Requestable.callback} cb - will receive the commit information
1711 * @return {Promise} - the promise for the http request
1712 */
1713
1714 }, {
1715 key: 'getSingleCommit',
1716 value: function getSingleCommit(ref, cb) {
1717 ref = ref || '';
1718 return this._request('GET', '/repos/' + this.__fullname + '/commits/' + ref, null, cb);
1719 }
1720
1721 /**
1722 * Get tha sha for a particular object in the repository. This is a convenience function
1723 * @see https://developer.github.com/v3/repos/contents/#get-contents
1724 * @param {string} [branch] - the branch to look in, or the repository's default branch if omitted
1725 * @param {string} path - the path of the file or directory
1726 * @param {Requestable.callback} cb - will receive a description of the requested object, including a `SHA` property
1727 * @return {Promise} - the promise for the http request
1728 */
1729
1730 }, {
1731 key: 'getSha',
1732 value: function getSha(branch, path, cb) {
1733 branch = branch ? '?ref=' + branch : '';
1734 return this._request('GET', '/repos/' + this.__fullname + '/contents/' + path + branch, null, cb);
1735 }
1736
1737 /**
1738 * List the commit statuses for a particular sha, branch, or tag
1739 * @see https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
1740 * @param {string} sha - the sha, branch, or tag to get statuses for
1741 * @param {Requestable.callback} cb - will receive the list of statuses
1742 * @return {Promise} - the promise for the http request
1743 */
1744
1745 }, {
1746 key: 'listStatuses',
1747 value: function listStatuses(sha, cb) {
1748 return this._request('GET', '/repos/' + this.__fullname + '/commits/' + sha + '/statuses', null, cb);
1749 }
1750
1751 /**
1752 * Get the combined view of commit statuses for a particular sha, branch, or tag
1753 * @see https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
1754 * @param {string} sha - the sha, branch, or tag to get the combined status for
1755 * @param {Requestable.callback} cb - will receive the combined status
1756 * @returns {Promise} - the promise for the http request
1757 */
1758
1759 }, {
1760 key: 'getCombinedStatus',
1761 value: function getCombinedStatus(sha, cb) {
1762 return this._request('GET', '/repos/' + this.__fullname + '/commits/' + sha + '/status', null, cb);
1763 }
1764
1765 /**
1766 * Get a description of a git tree
1767 * @see https://developer.github.com/v3/git/trees/#get-a-tree
1768 * @param {string} treeSHA - the SHA of the tree to fetch
1769 * @param {Requestable.callback} cb - will receive the callback data
1770 * @return {Promise} - the promise for the http request
1771 */
1772
1773 }, {
1774 key: 'getTree',
1775 value: function getTree(treeSHA, cb) {
1776 return this._request('GET', '/repos/' + this.__fullname + '/git/trees/' + treeSHA, null, cb);
1777 }
1778
1779 /**
1780 * Create a blob
1781 * @see https://developer.github.com/v3/git/blobs/#create-a-blob
1782 * @param {(string|Buffer|Blob)} content - the content to add to the repository
1783 * @param {Requestable.callback} cb - will receive the details of the created blob
1784 * @return {Promise} - the promise for the http request
1785 */
1786
1787 }, {
1788 key: 'createBlob',
1789 value: function createBlob(content, cb) {
1790 var postBody = this._getContentObject(content);
1791
1792 log('sending content', postBody);
1793 return this._request('POST', '/repos/' + this.__fullname + '/git/blobs', postBody, cb);
1794 }
1795
1796 /**
1797 * Get the object that represents the provided content
1798 * @param {string|Buffer|Blob} content - the content to send to the server
1799 * @return {Object} the representation of `content` for the GitHub API
1800 */
1801
1802 }, {
1803 key: '_getContentObject',
1804 value: function _getContentObject(content) {
1805 if (typeof content === 'string') {
1806 log('contet is a string');
1807 return {
1808 content: _utf2.default.encode(content),
1809 encoding: 'utf-8'
1810 };
1811 } else if (typeof Buffer !== 'undefined' && content instanceof Buffer) {
1812 log('We appear to be in Node');
1813 return {
1814 content: content.toString('base64'),
1815 encoding: 'base64'
1816 };
1817 } else if (typeof Blob !== 'undefined' && content instanceof Blob) {
1818 log('We appear to be in the browser');
1819 return {
1820 content: _jsBase.Base64.encode(content),
1821 encoding: 'base64'
1822 };
1823 } else {
1824 // eslint-disable-line
1825 log('Not sure what this content is: ' + (typeof content === 'undefined' ? 'undefined' : _typeof(content)) + ', ' + JSON.stringify(content));
1826 throw new Error('Unknown content passed to postBlob. Must be string or Buffer (node) or Blob (web)');
1827 }
1828 }
1829
1830 /**
1831 * Update a tree in Git
1832 * @see https://developer.github.com/v3/git/trees/#create-a-tree
1833 * @param {string} baseTreeSHA - the SHA of the tree to update
1834 * @param {string} path - the path for the new file
1835 * @param {string} blobSHA - the SHA for the blob to put at `path`
1836 * @param {Requestable.callback} cb - will receive the new tree that is created
1837 * @return {Promise} - the promise for the http request
1838 * @deprecated use {@link Repository#createTree} instead
1839 */
1840
1841 }, {
1842 key: 'updateTree',
1843 value: function updateTree(baseTreeSHA, path, blobSHA, cb) {
1844 var newTree = {
1845 base_tree: baseTreeSHA, // eslint-disable-line
1846 tree: [{
1847 path: path,
1848 sha: blobSHA,
1849 mode: '100644',
1850 type: 'blob'
1851 }]
1852 };
1853
1854 return this._request('POST', '/repos/' + this.__fullname + '/git/trees', newTree, cb);
1855 }
1856
1857 /**
1858 * Create a new tree in git
1859 * @see https://developer.github.com/v3/git/trees/#create-a-tree
1860 * @param {Object} tree - the tree to create
1861 * @param {string} baseSHA - the root sha of the tree
1862 * @param {Requestable.callback} cb - will receive the new tree that is created
1863 * @return {Promise} - the promise for the http request
1864 */
1865
1866 }, {
1867 key: 'createTree',
1868 value: function createTree(tree, baseSHA, cb) {
1869 return this._request('POST', '/repos/' + this.__fullname + '/git/trees', {
1870 tree: tree,
1871 base_tree: baseSHA // eslint-disable-line camelcase
1872 }, cb);
1873 }
1874
1875 /**
1876 * Add a commit to the repository
1877 * @see https://developer.github.com/v3/git/commits/#create-a-commit
1878 * @param {string} parent - the SHA of the parent commit
1879 * @param {string} tree - the SHA of the tree for this commit
1880 * @param {string} message - the commit message
1881 * @param {Object} [options] - commit options
1882 * @param {Object} [options.author] - the author of the commit
1883 * @param {Object} [options.commiter] - the committer
1884 * @param {Requestable.callback} cb - will receive the commit that is created
1885 * @return {Promise} - the promise for the http request
1886 */
1887
1888 }, {
1889 key: 'commit',
1890 value: function commit(parent, tree, message, options, cb) {
1891 var _this2 = this;
1892
1893 if (typeof options === 'function') {
1894 cb = options;
1895 options = {};
1896 }
1897
1898 var data = {
1899 message: message,
1900 tree: tree,
1901 parents: [parent]
1902 };
1903
1904 data = Object.assign({}, options, data);
1905
1906 return this._request('POST', '/repos/' + this.__fullname + '/git/commits', data, cb).then(function (response) {
1907 _this2.__currentTree.sha = response.data.sha; // Update latest commit
1908 return response;
1909 });
1910 }
1911
1912 /**
1913 * Update a ref
1914 * @see https://developer.github.com/v3/git/refs/#update-a-reference
1915 * @param {string} ref - the ref to update
1916 * @param {string} commitSHA - the SHA to point the reference to
1917 * @param {boolean} force - indicates whether to force or ensure a fast-forward update
1918 * @param {Requestable.callback} cb - will receive the updated ref back
1919 * @return {Promise} - the promise for the http request
1920 */
1921
1922 }, {
1923 key: 'updateHead',
1924 value: function updateHead(ref, commitSHA, force, cb) {
1925 return this._request('PATCH', '/repos/' + this.__fullname + '/git/refs/' + ref, {
1926 sha: commitSHA,
1927 force: force
1928 }, cb);
1929 }
1930
1931 /**
1932 * Update commit status
1933 * @see https://developer.github.com/v3/repos/statuses/
1934 * @param {string} commitSHA - the SHA of the commit that should be updated
1935 * @param {object} options - Commit status parameters
1936 * @param {string} options.state - The state of the status. Can be one of: pending, success, error, or failure.
1937 * @param {string} [options.target_url] - The target URL to associate with this status.
1938 * @param {string} [options.description] - A short description of the status.
1939 * @param {string} [options.context] - A string label to differentiate this status among CI systems.
1940 * @param {Requestable.callback} cb - will receive the updated commit back
1941 * @return {Promise} - the promise for the http request
1942 */
1943
1944 }, {
1945 key: 'updateStatus',
1946 value: function updateStatus(commitSHA, options, cb) {
1947 return this._request('POST', '/repos/' + this.__fullname + '/statuses/' + commitSHA, options, cb);
1948 }
1949
1950 /**
1951 * Update repository information
1952 * @see https://developer.github.com/v3/repos/#edit
1953 * @param {object} options - New parameters that will be set to the repository
1954 * @param {string} options.name - Name of the repository
1955 * @param {string} [options.description] - A short description of the repository
1956 * @param {string} [options.homepage] - A URL with more information about the repository
1957 * @param {boolean} [options.private] - Either true to make the repository private, or false to make it public.
1958 * @param {boolean} [options.has_issues] - Either true to enable issues for this repository, false to disable them.
1959 * @param {boolean} [options.has_wiki] - Either true to enable the wiki for this repository, false to disable it.
1960 * @param {boolean} [options.has_downloads] - Either true to enable downloads, false to disable them.
1961 * @param {string} [options.default_branch] - Updates the default branch for this repository.
1962 * @param {Requestable.callback} cb - will receive the updated repository back
1963 * @return {Promise} - the promise for the http request
1964 */
1965
1966 }, {
1967 key: 'updateRepository',
1968 value: function updateRepository(options, cb) {
1969 return this._request('PATCH', '/repos/' + this.__fullname, options, cb);
1970 }
1971
1972 /**
1973 * Get information about the repository
1974 * @see https://developer.github.com/v3/repos/#get
1975 * @param {Requestable.callback} cb - will receive the information about the repository
1976 * @return {Promise} - the promise for the http request
1977 */
1978
1979 }, {
1980 key: 'getDetails',
1981 value: function getDetails(cb) {
1982 return this._request('GET', '/repos/' + this.__fullname, null, cb);
1983 }
1984
1985 /**
1986 * List the contributors to the repository
1987 * @see https://developer.github.com/v3/repos/#list-contributors
1988 * @param {Requestable.callback} cb - will receive the list of contributors
1989 * @return {Promise} - the promise for the http request
1990 */
1991
1992 }, {
1993 key: 'getContributors',
1994 value: function getContributors(cb) {
1995 return this._request('GET', '/repos/' + this.__fullname + '/contributors', null, cb);
1996 }
1997
1998 /**
1999 * List the contributor stats to the repository
2000 * @see https://developer.github.com/v3/repos/#list-contributors
2001 * @param {Requestable.callback} cb - will receive the list of contributors
2002 * @return {Promise} - the promise for the http request
2003 */
2004
2005 }, {
2006 key: 'getContributorStats',
2007 value: function getContributorStats(cb) {
2008 return this._request('GET', '/repos/' + this.__fullname + '/stats/contributors', null, cb);
2009 }
2010
2011 /**
2012 * List the users who are collaborators on the repository. The currently authenticated user must have
2013 * push access to use this method
2014 * @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
2015 * @param {Requestable.callback} cb - will receive the list of collaborators
2016 * @return {Promise} - the promise for the http request
2017 */
2018
2019 }, {
2020 key: 'getCollaborators',
2021 value: function getCollaborators(cb) {
2022 return this._request('GET', '/repos/' + this.__fullname + '/collaborators', null, cb);
2023 }
2024
2025 /**
2026 * Check if a user is a collaborator on the repository
2027 * @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
2028 * @param {string} username - the user to check
2029 * @param {Requestable.callback} cb - will receive true if the user is a collaborator and false if they are not
2030 * @return {Promise} - the promise for the http request {Boolean} [description]
2031 */
2032
2033 }, {
2034 key: 'isCollaborator',
2035 value: function isCollaborator(username, cb) {
2036 return this._request('GET', '/repos/' + this.__fullname + '/collaborators/' + username, null, cb);
2037 }
2038
2039 /**
2040 * Get the contents of a repository
2041 * @see https://developer.github.com/v3/repos/contents/#get-contents
2042 * @param {string} ref - the ref to check
2043 * @param {string} path - the path containing the content to fetch
2044 * @param {boolean} raw - `true` if the results should be returned raw instead of GitHub's normalized format
2045 * @param {Requestable.callback} cb - will receive the fetched data
2046 * @return {Promise} - the promise for the http request
2047 */
2048
2049 }, {
2050 key: 'getContents',
2051 value: function getContents(ref, path, raw, cb) {
2052 path = path ? '' + encodeURI(path) : '';
2053 return this._request('GET', '/repos/' + this.__fullname + '/contents/' + path, {
2054 ref: ref
2055 }, cb, raw);
2056 }
2057
2058 /**
2059 * Get the README of a repository
2060 * @see https://developer.github.com/v3/repos/contents/#get-the-readme
2061 * @param {string} ref - the ref to check
2062 * @param {boolean} raw - `true` if the results should be returned raw instead of GitHub's normalized format
2063 * @param {Requestable.callback} cb - will receive the fetched data
2064 * @return {Promise} - the promise for the http request
2065 */
2066
2067 }, {
2068 key: 'getReadme',
2069 value: function getReadme(ref, raw, cb) {
2070 return this._request('GET', '/repos/' + this.__fullname + '/readme', {
2071 ref: ref
2072 }, cb, raw);
2073 }
2074
2075 /**
2076 * Fork a repository
2077 * @see https://developer.github.com/v3/repos/forks/#create-a-fork
2078 * @param {Requestable.callback} cb - will receive the information about the newly created fork
2079 * @return {Promise} - the promise for the http request
2080 */
2081
2082 }, {
2083 key: 'fork',
2084 value: function fork(cb) {
2085 return this._request('POST', '/repos/' + this.__fullname + '/forks', null, cb);
2086 }
2087
2088 /**
2089 * Fork a repository to an organization
2090 * @see https://developer.github.com/v3/repos/forks/#create-a-fork
2091 * @param {String} org - organization where you'd like to create the fork.
2092 * @param {Requestable.callback} cb - will receive the information about the newly created fork
2093 * @return {Promise} - the promise for the http request
2094 *
2095 */
2096
2097 }, {
2098 key: 'forkToOrg',
2099 value: function forkToOrg(org, cb) {
2100 return this._request('POST', '/repos/' + this.__fullname + '/forks?organization=' + org, null, cb);
2101 }
2102
2103 /**
2104 * List a repository's forks
2105 * @see https://developer.github.com/v3/repos/forks/#list-forks
2106 * @param {Requestable.callback} cb - will receive the list of repositories forked from this one
2107 * @return {Promise} - the promise for the http request
2108 */
2109
2110 }, {
2111 key: 'listForks',
2112 value: function listForks(cb) {
2113 return this._request('GET', '/repos/' + this.__fullname + '/forks', null, cb);
2114 }
2115
2116 /**
2117 * Create a new branch from an existing branch.
2118 * @param {string} [oldBranch=master] - the name of the existing branch
2119 * @param {string} newBranch - the name of the new branch
2120 * @param {Requestable.callback} cb - will receive the commit data for the head of the new branch
2121 * @return {Promise} - the promise for the http request
2122 */
2123
2124 }, {
2125 key: 'createBranch',
2126 value: function createBranch(oldBranch, newBranch, cb) {
2127 var _this3 = this;
2128
2129 if (typeof newBranch === 'function') {
2130 cb = newBranch;
2131 newBranch = oldBranch;
2132 oldBranch = 'master';
2133 }
2134
2135 return this.getRef('heads/' + oldBranch).then(function (response) {
2136 var sha = response.data.object.sha;
2137 return _this3.createRef({
2138 sha: sha,
2139 ref: 'refs/heads/' + newBranch
2140 }, cb);
2141 });
2142 }
2143
2144 /**
2145 * Create a new pull request
2146 * @see https://developer.github.com/v3/pulls/#create-a-pull-request
2147 * @param {Object} options - the pull request description
2148 * @param {Requestable.callback} cb - will receive the new pull request
2149 * @return {Promise} - the promise for the http request
2150 */
2151
2152 }, {
2153 key: 'createPullRequest',
2154 value: function createPullRequest(options, cb) {
2155 return this._request('POST', '/repos/' + this.__fullname + '/pulls', options, cb);
2156 }
2157
2158 /**
2159 * Update a pull request
2160 * @see https://developer.github.com/v3/pulls/#update-a-pull-request
2161 * @param {number|string} number - the number of the pull request to update
2162 * @param {Object} options - the pull request description
2163 * @param {Requestable.callback} [cb] - will receive the pull request information
2164 * @return {Promise} - the promise for the http request
2165 */
2166
2167 }, {
2168 key: 'updatePullRequest',
2169 value: function updatePullRequest(number, options, cb) {
2170 return this._request('PATCH', '/repos/' + this.__fullname + '/pulls/' + number, options, cb);
2171 }
2172
2173 /**
2174 * List the hooks for the repository
2175 * @see https://developer.github.com/v3/repos/hooks/#list-hooks
2176 * @param {Requestable.callback} cb - will receive the list of hooks
2177 * @return {Promise} - the promise for the http request
2178 */
2179
2180 }, {
2181 key: 'listHooks',
2182 value: function listHooks(cb) {
2183 return this._request('GET', '/repos/' + this.__fullname + '/hooks', null, cb);
2184 }
2185
2186 /**
2187 * Get a hook for the repository
2188 * @see https://developer.github.com/v3/repos/hooks/#get-single-hook
2189 * @param {number} id - the id of the webook
2190 * @param {Requestable.callback} cb - will receive the details of the webook
2191 * @return {Promise} - the promise for the http request
2192 */
2193
2194 }, {
2195 key: 'getHook',
2196 value: function getHook(id, cb) {
2197 return this._request('GET', '/repos/' + this.__fullname + '/hooks/' + id, null, cb);
2198 }
2199
2200 /**
2201 * Add a new hook to the repository
2202 * @see https://developer.github.com/v3/repos/hooks/#create-a-hook
2203 * @param {Object} options - the configuration describing the new hook
2204 * @param {Requestable.callback} cb - will receive the new webhook
2205 * @return {Promise} - the promise for the http request
2206 */
2207
2208 }, {
2209 key: 'createHook',
2210 value: function createHook(options, cb) {
2211 return this._request('POST', '/repos/' + this.__fullname + '/hooks', options, cb);
2212 }
2213
2214 /**
2215 * Edit an existing webhook
2216 * @see https://developer.github.com/v3/repos/hooks/#edit-a-hook
2217 * @param {number} id - the id of the webhook
2218 * @param {Object} options - the new description of the webhook
2219 * @param {Requestable.callback} cb - will receive the updated webhook
2220 * @return {Promise} - the promise for the http request
2221 */
2222
2223 }, {
2224 key: 'updateHook',
2225 value: function updateHook(id, options, cb) {
2226 return this._request('PATCH', '/repos/' + this.__fullname + '/hooks/' + id, options, cb);
2227 }
2228
2229 /**
2230 * Delete a webhook
2231 * @see https://developer.github.com/v3/repos/hooks/#delete-a-hook
2232 * @param {number} id - the id of the webhook to be deleted
2233 * @param {Requestable.callback} cb - will receive true if the call is successful
2234 * @return {Promise} - the promise for the http request
2235 */
2236
2237 }, {
2238 key: 'deleteHook',
2239 value: function deleteHook(id, cb) {
2240 return this._request('DELETE', '/repos/' + this.__fullname + '/hooks/' + id, null, cb);
2241 }
2242
2243 /**
2244 * List the deploy keys for the repository
2245 * @see https://developer.github.com/v3/repos/keys/#list-deploy-keys
2246 * @param {Requestable.callback} cb - will receive the list of deploy keys
2247 * @return {Promise} - the promise for the http request
2248 */
2249
2250 }, {
2251 key: 'listKeys',
2252 value: function listKeys(cb) {
2253 return this._request('GET', '/repos/' + this.__fullname + '/keys', null, cb);
2254 }
2255
2256 /**
2257 * Get a deploy key for the repository
2258 * @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
2259 * @param {number} id - the id of the deploy key
2260 * @param {Requestable.callback} cb - will receive the details of the deploy key
2261 * @return {Promise} - the promise for the http request
2262 */
2263
2264 }, {
2265 key: 'getKey',
2266 value: function getKey(id, cb) {
2267 return this._request('GET', '/repos/' + this.__fullname + '/keys/' + id, null, cb);
2268 }
2269
2270 /**
2271 * Add a new deploy key to the repository
2272 * @see https://developer.github.com/v3/repos/keys/#add-a-new-deploy-key
2273 * @param {Object} options - the configuration describing the new deploy key
2274 * @param {Requestable.callback} cb - will receive the new deploy key
2275 * @return {Promise} - the promise for the http request
2276 */
2277
2278 }, {
2279 key: 'createKey',
2280 value: function createKey(options, cb) {
2281 return this._request('POST', '/repos/' + this.__fullname + '/keys', options, cb);
2282 }
2283
2284 /**
2285 * Delete a deploy key
2286 * @see https://developer.github.com/v3/repos/keys/#remove-a-deploy-key
2287 * @param {number} id - the id of the deploy key to be deleted
2288 * @param {Requestable.callback} cb - will receive true if the call is successful
2289 * @return {Promise} - the promise for the http request
2290 */
2291
2292 }, {
2293 key: 'deleteKey',
2294 value: function deleteKey(id, cb) {
2295 return this._request('DELETE', '/repos/' + this.__fullname + '/keys/' + id, null, cb);
2296 }
2297
2298 /**
2299 * Delete a file from a branch
2300 * @see https://developer.github.com/v3/repos/contents/#delete-a-file
2301 * @param {string} branch - the branch to delete from, or the default branch if not specified
2302 * @param {string} path - the path of the file to remove
2303 * @param {Requestable.callback} cb - will receive the commit in which the delete occurred
2304 * @return {Promise} - the promise for the http request
2305 */
2306
2307 }, {
2308 key: 'deleteFile',
2309 value: function deleteFile(branch, path, cb) {
2310 var _this4 = this;
2311
2312 return this.getSha(branch, path).then(function (response) {
2313 var deleteCommit = {
2314 message: 'Delete the file at \'' + path + '\'',
2315 sha: response.data.sha,
2316 branch: branch
2317 };
2318 return _this4._request('DELETE', '/repos/' + _this4.__fullname + '/contents/' + path, deleteCommit, cb);
2319 });
2320 }
2321
2322 /**
2323 * Change all references in a repo from oldPath to new_path
2324 * @param {string} branch - the branch to carry out the reference change, or the default branch if not specified
2325 * @param {string} oldPath - original path
2326 * @param {string} newPath - new reference path
2327 * @param {Requestable.callback} cb - will receive the commit in which the move occurred
2328 * @return {Promise} - the promise for the http request
2329 */
2330
2331 }, {
2332 key: 'move',
2333 value: function move(branch, oldPath, newPath, cb) {
2334 var _this5 = this;
2335
2336 var oldSha = void 0;
2337 return this.getRef('heads/' + branch).then(function (_ref) {
2338 var object = _ref.data.object;
2339 return _this5.getTree(object.sha + '?recursive=true');
2340 }).then(function (_ref2) {
2341 var _ref2$data = _ref2.data,
2342 tree = _ref2$data.tree,
2343 sha = _ref2$data.sha;
2344
2345 oldSha = sha;
2346 var newTree = tree.map(function (ref) {
2347 if (ref.path === oldPath) {
2348 ref.path = newPath;
2349 }
2350 if (ref.type === 'tree') {
2351 delete ref.sha;
2352 }
2353 return ref;
2354 });
2355 return _this5.createTree(newTree);
2356 }).then(function (_ref3) {
2357 var tree = _ref3.data;
2358 return _this5.commit(oldSha, tree.sha, 'Renamed \'' + oldPath + '\' to \'' + newPath + '\'');
2359 }).then(function (_ref4) {
2360 var commit = _ref4.data;
2361 return _this5.updateHead('heads/' + branch, commit.sha, true, cb);
2362 });
2363 }
2364
2365 /**
2366 * Write a file to the repository
2367 * @see https://developer.github.com/v3/repos/contents/#update-a-file
2368 * @param {string} branch - the name of the branch
2369 * @param {string} path - the path for the file
2370 * @param {string} content - the contents of the file
2371 * @param {string} message - the commit message
2372 * @param {Object} [options] - commit options
2373 * @param {Object} [options.author] - the author of the commit
2374 * @param {Object} [options.commiter] - the committer
2375 * @param {boolean} [options.encode] - true if the content should be base64 encoded
2376 * @param {Requestable.callback} cb - will receive the new commit
2377 * @return {Promise} - the promise for the http request
2378 */
2379
2380 }, {
2381 key: 'writeFile',
2382 value: function writeFile(branch, path, content, message, options, cb) {
2383 var _this6 = this;
2384
2385 options = options || {};
2386 if (typeof options === 'function') {
2387 cb = options;
2388 options = {};
2389 }
2390 var filePath = path ? encodeURI(path) : '';
2391 var shouldEncode = options.encode !== false;
2392 var commit = {
2393 branch: branch,
2394 message: message,
2395 author: options.author,
2396 committer: options.committer,
2397 content: shouldEncode ? _jsBase.Base64.encode(content) : content
2398 };
2399
2400 return this.getSha(branch, filePath).then(function (response) {
2401 commit.sha = response.data.sha;
2402 return _this6._request('PUT', '/repos/' + _this6.__fullname + '/contents/' + filePath, commit, cb);
2403 }, function () {
2404 return _this6._request('PUT', '/repos/' + _this6.__fullname + '/contents/' + filePath, commit, cb);
2405 });
2406 }
2407
2408 /**
2409 * Check if a repository is starred by you
2410 * @see https://developer.github.com/v3/activity/starring/#check-if-you-are-starring-a-repository
2411 * @param {Requestable.callback} cb - will receive true if the repository is starred and false if the repository
2412 * is not starred
2413 * @return {Promise} - the promise for the http request {Boolean} [description]
2414 */
2415
2416 }, {
2417 key: 'isStarred',
2418 value: function isStarred(cb) {
2419 return this._request204or404('/user/starred/' + this.__fullname, null, cb);
2420 }
2421
2422 /**
2423 * Star a repository
2424 * @see https://developer.github.com/v3/activity/starring/#star-a-repository
2425 * @param {Requestable.callback} cb - will receive true if the repository is starred
2426 * @return {Promise} - the promise for the http request
2427 */
2428
2429 }, {
2430 key: 'star',
2431 value: function star(cb) {
2432 return this._request('PUT', '/user/starred/' + this.__fullname, null, cb);
2433 }
2434
2435 /**
2436 * Unstar a repository
2437 * @see https://developer.github.com/v3/activity/starring/#unstar-a-repository
2438 * @param {Requestable.callback} cb - will receive true if the repository is unstarred
2439 * @return {Promise} - the promise for the http request
2440 */
2441
2442 }, {
2443 key: 'unstar',
2444 value: function unstar(cb) {
2445 return this._request('DELETE', '/user/starred/' + this.__fullname, null, cb);
2446 }
2447
2448 /**
2449 * Create a new release
2450 * @see https://developer.github.com/v3/repos/releases/#create-a-release
2451 * @param {Object} options - the description of the release
2452 * @param {Requestable.callback} cb - will receive the newly created release
2453 * @return {Promise} - the promise for the http request
2454 */
2455
2456 }, {
2457 key: 'createRelease',
2458 value: function createRelease(options, cb) {
2459 return this._request('POST', '/repos/' + this.__fullname + '/releases', options, cb);
2460 }
2461
2462 /**
2463 * Edit a release
2464 * @see https://developer.github.com/v3/repos/releases/#edit-a-release
2465 * @param {string} id - the id of the release
2466 * @param {Object} options - the description of the release
2467 * @param {Requestable.callback} cb - will receive the modified release
2468 * @return {Promise} - the promise for the http request
2469 */
2470
2471 }, {
2472 key: 'updateRelease',
2473 value: function updateRelease(id, options, cb) {
2474 return this._request('PATCH', '/repos/' + this.__fullname + '/releases/' + id, options, cb);
2475 }
2476
2477 /**
2478 * Get information about all releases
2479 * @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
2480 * @param {Requestable.callback} cb - will receive the release information
2481 * @return {Promise} - the promise for the http request
2482 */
2483
2484 }, {
2485 key: 'listReleases',
2486 value: function listReleases(cb) {
2487 return this._request('GET', '/repos/' + this.__fullname + '/releases', null, cb);
2488 }
2489
2490 /**
2491 * Get information about a release
2492 * @see https://developer.github.com/v3/repos/releases/#get-a-single-release
2493 * @param {string} id - the id of the release
2494 * @param {Requestable.callback} cb - will receive the release information
2495 * @return {Promise} - the promise for the http request
2496 */
2497
2498 }, {
2499 key: 'getRelease',
2500 value: function getRelease(id, cb) {
2501 return this._request('GET', '/repos/' + this.__fullname + '/releases/' + id, null, cb);
2502 }
2503
2504 /**
2505 * Delete a release
2506 * @see https://developer.github.com/v3/repos/releases/#delete-a-release
2507 * @param {string} id - the release to be deleted
2508 * @param {Requestable.callback} cb - will receive true if the operation is successful
2509 * @return {Promise} - the promise for the http request
2510 */
2511
2512 }, {
2513 key: 'deleteRelease',
2514 value: function deleteRelease(id, cb) {
2515 return this._request('DELETE', '/repos/' + this.__fullname + '/releases/' + id, null, cb);
2516 }
2517
2518 /**
2519 * Merge a pull request
2520 * @see https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
2521 * @param {number|string} number - the number of the pull request to merge
2522 * @param {Object} options - the merge options for the pull request
2523 * @param {Requestable.callback} [cb] - will receive the merge information if the operation is successful
2524 * @return {Promise} - the promise for the http request
2525 */
2526
2527 }, {
2528 key: 'mergePullRequest',
2529 value: function mergePullRequest(number, options, cb) {
2530 return this._request('PUT', '/repos/' + this.__fullname + '/pulls/' + number + '/merge', options, cb);
2531 }
2532
2533 /**
2534 * Get information about all projects
2535 * @see https://developer.github.com/v3/projects/#list-repository-projects
2536 * @param {Requestable.callback} [cb] - will receive the list of projects
2537 * @return {Promise} - the promise for the http request
2538 */
2539
2540 }, {
2541 key: 'listProjects',
2542 value: function listProjects(cb) {
2543 return this._requestAllPages('/repos/' + this.__fullname + '/projects', { AcceptHeader: 'inertia-preview' }, cb);
2544 }
2545
2546 /**
2547 * Create a new project
2548 * @see https://developer.github.com/v3/projects/#create-a-repository-project
2549 * @param {Object} options - the description of the project
2550 * @param {Requestable.callback} cb - will receive the newly created project
2551 * @return {Promise} - the promise for the http request
2552 */
2553
2554 }, {
2555 key: 'createProject',
2556 value: function createProject(options, cb) {
2557 options = options || {};
2558 options.AcceptHeader = 'inertia-preview';
2559 return this._request('POST', '/repos/' + this.__fullname + '/projects', options, cb);
2560 }
2561 }]);
2562
2563 return Repository;
2564}(_Requestable3.default);
2565
2566module.exports = Repository;
2567
2568}).call(this)}).call(this,require("buffer").Buffer)
2569
2570},{"./Requestable":9,"buffer":41,"debug":42,"js-base64":46,"utf8":49}],9:[function(require,module,exports){
2571'use strict';
2572
2573var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2574
2575var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2576
2577var _axios = require('axios');
2578
2579var _axios2 = _interopRequireDefault(_axios);
2580
2581var _debug = require('debug');
2582
2583var _debug2 = _interopRequireDefault(_debug);
2584
2585var _jsBase = require('js-base64');
2586
2587function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2588
2589function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
2590
2591function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2592
2593function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2594
2595function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
2596 * @file
2597 * @copyright 2016 Yahoo Inc.
2598 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
2599 * Github.js is freely distributable.
2600 */
2601
2602var log = (0, _debug2.default)('github:request');
2603
2604/**
2605 * The error structure returned when a network call fails
2606 */
2607
2608var ResponseError = function (_Error) {
2609 _inherits(ResponseError, _Error);
2610
2611 /**
2612 * Construct a new ResponseError
2613 * @param {string} message - an message to return instead of the the default error message
2614 * @param {string} path - the requested path
2615 * @param {Object} response - the object returned by Axios
2616 */
2617 function ResponseError(message, path, response) {
2618 _classCallCheck(this, ResponseError);
2619
2620 var _this = _possibleConstructorReturn(this, (ResponseError.__proto__ || Object.getPrototypeOf(ResponseError)).call(this, message));
2621
2622 _this.path = path;
2623 _this.request = response.config;
2624 _this.response = (response || {}).response || response;
2625 _this.status = response.status;
2626 return _this;
2627 }
2628
2629 return ResponseError;
2630}(Error);
2631
2632/**
2633 * Requestable wraps the logic for making http requests to the API
2634 */
2635
2636
2637var Requestable = function () {
2638 /**
2639 * Either a username and password or an oauth token for Github
2640 * @typedef {Object} Requestable.auth
2641 * @prop {string} [username] - the Github username
2642 * @prop {string} [password] - the user's password
2643 * @prop {token} [token] - an OAuth token
2644 */
2645 /**
2646 * Initialize the http internals.
2647 * @param {Requestable.auth} [auth] - the credentials to authenticate to Github. If auth is
2648 * not provided request will be made unauthenticated
2649 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
2650 * @param {string} [AcceptHeader=v3] - the accept header for the requests
2651 */
2652 function Requestable(auth, apiBase, AcceptHeader) {
2653 _classCallCheck(this, Requestable);
2654
2655 this.__apiBase = apiBase || 'https://api.github.com';
2656 this.__auth = {
2657 token: auth.token,
2658 username: auth.username,
2659 password: auth.password
2660 };
2661 this.__AcceptHeader = AcceptHeader || 'v3';
2662
2663 if (auth.token) {
2664 this.__authorizationHeader = 'token ' + auth.token;
2665 } else if (auth.username && auth.password) {
2666 this.__authorizationHeader = 'Basic ' + _jsBase.Base64.encode(auth.username + ':' + auth.password);
2667 }
2668 }
2669
2670 /**
2671 * Compute the URL to use to make a request.
2672 * @private
2673 * @param {string} path - either a URL relative to the API base or an absolute URL
2674 * @return {string} - the URL to use
2675 */
2676
2677
2678 _createClass(Requestable, [{
2679 key: '__getURL',
2680 value: function __getURL(path) {
2681 var url = path;
2682
2683 if (path.indexOf('//') === -1) {
2684 url = this.__apiBase + path;
2685 }
2686
2687 var newCacheBuster = 'timestamp=' + new Date().getTime();
2688 return url.replace(/(timestamp=\d+)/, newCacheBuster);
2689 }
2690
2691 /**
2692 * Compute the headers required for an API request.
2693 * @private
2694 * @param {boolean} raw - if the request should be treated as JSON or as a raw request
2695 * @param {string} AcceptHeader - the accept header for the request
2696 * @return {Object} - the headers to use in the request
2697 */
2698
2699 }, {
2700 key: '__getRequestHeaders',
2701 value: function __getRequestHeaders(raw, AcceptHeader) {
2702 var headers = {
2703 'Content-Type': 'application/json;charset=UTF-8',
2704 'Accept': 'application/vnd.github.' + (AcceptHeader || this.__AcceptHeader)
2705 };
2706
2707 if (raw) {
2708 headers.Accept += '.raw';
2709 }
2710 headers.Accept += '+json';
2711
2712 if (this.__authorizationHeader) {
2713 headers.Authorization = this.__authorizationHeader;
2714 }
2715
2716 return headers;
2717 }
2718
2719 /**
2720 * Sets the default options for API requests
2721 * @protected
2722 * @param {Object} [requestOptions={}] - the current options for the request
2723 * @return {Object} - the options to pass to the request
2724 */
2725
2726 }, {
2727 key: '_getOptionsWithDefaults',
2728 value: function _getOptionsWithDefaults() {
2729 var requestOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2730
2731 if (!(requestOptions.visibility || requestOptions.affiliation)) {
2732 requestOptions.type = requestOptions.type || 'all';
2733 }
2734 requestOptions.sort = requestOptions.sort || 'updated';
2735 requestOptions.per_page = requestOptions.per_page || '100'; // eslint-disable-line
2736
2737 return requestOptions;
2738 }
2739
2740 /**
2741 * if a `Date` is passed to this function it will be converted to an ISO string
2742 * @param {*} date - the object to attempt to coerce into an ISO date string
2743 * @return {string} - the ISO representation of `date` or whatever was passed in if it was not a date
2744 */
2745
2746 }, {
2747 key: '_dateToISO',
2748 value: function _dateToISO(date) {
2749 if (date && date instanceof Date) {
2750 date = date.toISOString();
2751 }
2752
2753 return date;
2754 }
2755
2756 /**
2757 * A function that receives the result of the API request.
2758 * @callback Requestable.callback
2759 * @param {Requestable.Error} error - the error returned by the API or `null`
2760 * @param {(Object|true)} result - the data returned by the API or `true` if the API returns `204 No Content`
2761 * @param {Object} request - the raw {@linkcode https://github.com/mzabriskie/axios#response-schema Response}
2762 */
2763 /**
2764 * Make a request.
2765 * @param {string} method - the method for the request (GET, PUT, POST, DELETE)
2766 * @param {string} path - the path for the request
2767 * @param {*} [data] - the data to send to the server. For HTTP methods that don't have a body the data
2768 * will be sent as query parameters
2769 * @param {Requestable.callback} [cb] - the callback for the request
2770 * @param {boolean} [raw=false] - if the request should be sent as raw. If this is a falsy value then the
2771 * request will be made as JSON
2772 * @return {Promise} - the Promise for the http request
2773 */
2774
2775 }, {
2776 key: '_request',
2777 value: function _request(method, path, data, cb, raw) {
2778 var url = this.__getURL(path);
2779
2780 var AcceptHeader = (data || {}).AcceptHeader;
2781 if (AcceptHeader) {
2782 delete data.AcceptHeader;
2783 }
2784 var headers = this.__getRequestHeaders(raw, AcceptHeader);
2785
2786 var queryParams = {};
2787
2788 var shouldUseDataAsParams = data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && methodHasNoBody(method);
2789 if (shouldUseDataAsParams) {
2790 queryParams = data;
2791 data = undefined;
2792 }
2793
2794 var config = {
2795 url: url,
2796 method: method,
2797 headers: headers,
2798 params: queryParams,
2799 data: data,
2800 responseType: raw ? 'text' : 'json'
2801 };
2802
2803 log(config.method + ' to ' + config.url);
2804 var requestPromise = (0, _axios2.default)(config).catch(callbackErrorOrThrow(cb, path));
2805
2806 if (cb) {
2807 requestPromise.then(function (response) {
2808 if (response.data && Object.keys(response.data).length > 0) {
2809 // When data has results
2810 cb(null, response.data, response);
2811 } else if (config.method !== 'GET' && Object.keys(response.data).length < 1) {
2812 // True when successful submit a request and receive a empty object
2813 cb(null, response.status < 300, response);
2814 } else {
2815 cb(null, response.data, response);
2816 }
2817 });
2818 }
2819
2820 return requestPromise;
2821 }
2822
2823 /**
2824 * Make a request to an endpoint the returns 204 when true and 404 when false
2825 * @param {string} path - the path to request
2826 * @param {Object} data - any query parameters for the request
2827 * @param {Requestable.callback} cb - the callback that will receive `true` or `false`
2828 * @param {method} [method=GET] - HTTP Method to use
2829 * @return {Promise} - the promise for the http request
2830 */
2831
2832 }, {
2833 key: '_request204or404',
2834 value: function _request204or404(path, data, cb) {
2835 var method = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'GET';
2836
2837 return this._request(method, path, data).then(function success(response) {
2838 if (cb) {
2839 cb(null, true, response);
2840 }
2841 return true;
2842 }, function failure(response) {
2843 if (response.response.status === 404) {
2844 if (cb) {
2845 cb(null, false, response);
2846 }
2847 return false;
2848 }
2849
2850 if (cb) {
2851 cb(response);
2852 }
2853 throw response;
2854 });
2855 }
2856
2857 /**
2858 * Make a request and fetch all the available data. Github will paginate responses so for queries
2859 * that might span multiple pages this method is preferred to {@link Requestable#request}
2860 * @param {string} path - the path to request
2861 * @param {Object} options - the query parameters to include
2862 * @param {Requestable.callback} [cb] - the function to receive the data. The returned data will always be an array.
2863 * @param {Object[]} results - the partial results. This argument is intended for internal use only.
2864 * @return {Promise} - a promise which will resolve when all pages have been fetched
2865 * @deprecated This will be folded into {@link Requestable#_request} in the 2.0 release.
2866 */
2867
2868 }, {
2869 key: '_requestAllPages',
2870 value: function _requestAllPages(path, options, cb, results) {
2871 var _this2 = this;
2872
2873 results = results || [];
2874
2875 return this._request('GET', path, options).then(function (response) {
2876 var _results;
2877
2878 var thisGroup = void 0;
2879 if (response.data instanceof Array) {
2880 thisGroup = response.data;
2881 } else if (response.data.items instanceof Array) {
2882 thisGroup = response.data.items;
2883 } else {
2884 var message = 'cannot figure out how to append ' + response.data + ' to the result set';
2885 throw new ResponseError(message, path, response);
2886 }
2887 (_results = results).push.apply(_results, _toConsumableArray(thisGroup));
2888
2889 var nextUrl = getNextPage(response.headers.link);
2890 if (nextUrl) {
2891 if (!options) {
2892 options = {};
2893 }
2894 options.page = parseInt(nextUrl.match(/([&\?]page=[0-9]*)/g).shift().split('=').pop());
2895 if (!(options && typeof options.page !== 'number')) {
2896 log('getting next page: ' + nextUrl);
2897 return _this2._requestAllPages(nextUrl, options, cb, results);
2898 }
2899 }
2900
2901 if (cb) {
2902 cb(null, results, response);
2903 }
2904
2905 response.data = results;
2906 return response;
2907 }).catch(callbackErrorOrThrow(cb, path));
2908 }
2909 }]);
2910
2911 return Requestable;
2912}();
2913
2914module.exports = Requestable;
2915
2916// ////////////////////////// //
2917// Private helper functions //
2918// ////////////////////////// //
2919var METHODS_WITH_NO_BODY = ['GET', 'HEAD', 'DELETE'];
2920function methodHasNoBody(method) {
2921 return METHODS_WITH_NO_BODY.indexOf(method) !== -1;
2922}
2923
2924function getNextPage() {
2925 var linksHeader = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
2926
2927 var links = linksHeader.split(/\s*,\s*/); // splits and strips the urls
2928 return links.reduce(function (nextUrl, link) {
2929 if (link.search(/rel="next"/) !== -1) {
2930 return (link.match(/<(.*)>/) || [])[1];
2931 }
2932
2933 return nextUrl;
2934 }, undefined);
2935}
2936
2937function callbackErrorOrThrow(cb, path) {
2938 return function handler(object) {
2939 var error = void 0;
2940 if (object.hasOwnProperty('config')) {
2941 var _object$response = object.response,
2942 status = _object$response.status,
2943 statusText = _object$response.statusText,
2944 _object$config = object.config,
2945 method = _object$config.method,
2946 url = _object$config.url;
2947
2948 var message = status + ' error making request ' + method + ' ' + url + ': "' + statusText + '"';
2949 error = new ResponseError(message, path, object);
2950 log(message + ' ' + JSON.stringify(object.data));
2951 } else {
2952 error = object;
2953 }
2954 if (cb) {
2955 log('going to error callback');
2956 cb(error);
2957 } else {
2958 log('throwing error');
2959 throw error;
2960 }
2961 };
2962}
2963
2964},{"axios":13,"debug":42,"js-base64":46}],10:[function(require,module,exports){
2965'use strict';
2966
2967var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
2968
2969var _Requestable2 = require('./Requestable');
2970
2971var _Requestable3 = _interopRequireDefault(_Requestable2);
2972
2973var _debug = require('debug');
2974
2975var _debug2 = _interopRequireDefault(_debug);
2976
2977function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2978
2979function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2980
2981function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
2982
2983function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
2984 * @file
2985 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
2986 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
2987 * Github.js is freely distributable.
2988 */
2989
2990var log = (0, _debug2.default)('github:search');
2991
2992/**
2993 * Wrap the Search API
2994 */
2995
2996var Search = function (_Requestable) {
2997 _inherits(Search, _Requestable);
2998
2999 /**
3000 * Create a Search
3001 * @param {Object} defaults - defaults for the search
3002 * @param {Requestable.auth} [auth] - information required to authenticate to Github
3003 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
3004 */
3005 function Search(defaults, auth, apiBase) {
3006 _classCallCheck(this, Search);
3007
3008 var _this = _possibleConstructorReturn(this, (Search.__proto__ || Object.getPrototypeOf(Search)).call(this, auth, apiBase));
3009
3010 _this.__defaults = _this._getOptionsWithDefaults(defaults);
3011 return _this;
3012 }
3013
3014 /**
3015 * Available search options
3016 * @see https://developer.github.com/v3/search/#parameters
3017 * @typedef {Object} Search.Params
3018 * @param {string} q - the query to make
3019 * @param {string} sort - the sort field, one of `stars`, `forks`, or `updated`.
3020 * Default is [best match](https://developer.github.com/v3/search/#ranking-search-results)
3021 * @param {string} order - the ordering, either `asc` or `desc`
3022 */
3023 /**
3024 * Perform a search on the GitHub API
3025 * @private
3026 * @param {string} path - the scope of the search
3027 * @param {Search.Params} [withOptions] - additional parameters for the search
3028 * @param {Requestable.callback} [cb] - will receive the results of the search
3029 * @return {Promise} - the promise for the http request
3030 */
3031
3032
3033 _createClass(Search, [{
3034 key: '_search',
3035 value: function _search(path) {
3036 var _this2 = this;
3037
3038 var withOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3039 var cb = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
3040
3041 var requestOptions = {};
3042 Object.keys(this.__defaults).forEach(function (prop) {
3043 requestOptions[prop] = _this2.__defaults[prop];
3044 });
3045 Object.keys(withOptions).forEach(function (prop) {
3046 requestOptions[prop] = withOptions[prop];
3047 });
3048
3049 log('searching ' + path + ' with options:', requestOptions);
3050 return this._requestAllPages('/search/' + path, requestOptions, cb);
3051 }
3052
3053 /**
3054 * Search for repositories
3055 * @see https://developer.github.com/v3/search/#search-repositories
3056 * @param {Search.Params} [options] - additional parameters for the search
3057 * @param {Requestable.callback} [cb] - will receive the results of the search
3058 * @return {Promise} - the promise for the http request
3059 */
3060
3061 }, {
3062 key: 'forRepositories',
3063 value: function forRepositories(options, cb) {
3064 return this._search('repositories', options, cb);
3065 }
3066
3067 /**
3068 * Search for code
3069 * @see https://developer.github.com/v3/search/#search-code
3070 * @param {Search.Params} [options] - additional parameters for the search
3071 * @param {Requestable.callback} [cb] - will receive the results of the search
3072 * @return {Promise} - the promise for the http request
3073 */
3074
3075 }, {
3076 key: 'forCode',
3077 value: function forCode(options, cb) {
3078 return this._search('code', options, cb);
3079 }
3080
3081 /**
3082 * Search for issues
3083 * @see https://developer.github.com/v3/search/#search-issues
3084 * @param {Search.Params} [options] - additional parameters for the search
3085 * @param {Requestable.callback} [cb] - will receive the results of the search
3086 * @return {Promise} - the promise for the http request
3087 */
3088
3089 }, {
3090 key: 'forIssues',
3091 value: function forIssues(options, cb) {
3092 return this._search('issues', options, cb);
3093 }
3094
3095 /**
3096 * Search for users
3097 * @see https://developer.github.com/v3/search/#search-users
3098 * @param {Search.Params} [options] - additional parameters for the search
3099 * @param {Requestable.callback} [cb] - will receive the results of the search
3100 * @return {Promise} - the promise for the http request
3101 */
3102
3103 }, {
3104 key: 'forUsers',
3105 value: function forUsers(options, cb) {
3106 return this._search('users', options, cb);
3107 }
3108 }]);
3109
3110 return Search;
3111}(_Requestable3.default);
3112
3113module.exports = Search;
3114
3115},{"./Requestable":9,"debug":42}],11:[function(require,module,exports){
3116'use strict';
3117
3118var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3119
3120var _Requestable2 = require('./Requestable');
3121
3122var _Requestable3 = _interopRequireDefault(_Requestable2);
3123
3124var _debug = require('debug');
3125
3126var _debug2 = _interopRequireDefault(_debug);
3127
3128function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3129
3130function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3131
3132function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
3133
3134function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
3135 * @file
3136 * @copyright 2016 Matt Smith (Development Seed)
3137 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
3138 * Github.js is freely distributable.
3139 */
3140
3141var log = (0, _debug2.default)('github:team');
3142
3143/**
3144 * A Team allows scoping of API requests to a particular Github Organization Team.
3145 */
3146
3147var Team = function (_Requestable) {
3148 _inherits(Team, _Requestable);
3149
3150 /**
3151 * Create a Team.
3152 * @param {string} [teamId] - the id for the team
3153 * @param {Requestable.auth} [auth] - information required to authenticate to Github
3154 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
3155 */
3156 function Team(teamId, auth, apiBase) {
3157 _classCallCheck(this, Team);
3158
3159 var _this = _possibleConstructorReturn(this, (Team.__proto__ || Object.getPrototypeOf(Team)).call(this, auth, apiBase));
3160
3161 _this.__teamId = teamId;
3162 return _this;
3163 }
3164
3165 /**
3166 * Get Team information
3167 * @see https://developer.github.com/v3/orgs/teams/#get-team
3168 * @param {Requestable.callback} [cb] - will receive the team
3169 * @return {Promise} - the promise for the http request
3170 */
3171
3172
3173 _createClass(Team, [{
3174 key: 'getTeam',
3175 value: function getTeam(cb) {
3176 log('Fetching Team ' + this.__teamId);
3177 return this._request('Get', '/teams/' + this.__teamId, undefined, cb);
3178 }
3179
3180 /**
3181 * List the Team's repositories
3182 * @see https://developer.github.com/v3/orgs/teams/#list-team-repos
3183 * @param {Requestable.callback} [cb] - will receive the list of repositories
3184 * @return {Promise} - the promise for the http request
3185 */
3186
3187 }, {
3188 key: 'listRepos',
3189 value: function listRepos(cb) {
3190 log('Fetching repositories for Team ' + this.__teamId);
3191 return this._requestAllPages('/teams/' + this.__teamId + '/repos', undefined, cb);
3192 }
3193
3194 /**
3195 * Edit Team information
3196 * @see https://developer.github.com/v3/orgs/teams/#edit-team
3197 * @param {object} options - Parameters for team edit
3198 * @param {string} options.name - The name of the team
3199 * @param {string} [options.description] - Team description
3200 * @param {string} [options.repo_names] - Repos to add the team to
3201 * @param {string} [options.privacy=secret] - The level of privacy the team should have. Can be either one
3202 * of: `secret`, or `closed`
3203 * @param {Requestable.callback} [cb] - will receive the updated team
3204 * @return {Promise} - the promise for the http request
3205 */
3206
3207 }, {
3208 key: 'editTeam',
3209 value: function editTeam(options, cb) {
3210 log('Editing Team ' + this.__teamId);
3211 return this._request('PATCH', '/teams/' + this.__teamId, options, cb);
3212 }
3213
3214 /**
3215 * List the users who are members of the Team
3216 * @see https://developer.github.com/v3/orgs/teams/#list-team-members
3217 * @param {object} options - Parameters for listing team users
3218 * @param {string} [options.role=all] - can be one of: `all`, `maintainer`, or `member`
3219 * @param {Requestable.callback} [cb] - will receive the list of users
3220 * @return {Promise} - the promise for the http request
3221 */
3222
3223 }, {
3224 key: 'listMembers',
3225 value: function listMembers(options, cb) {
3226 log('Getting members of Team ' + this.__teamId);
3227 return this._requestAllPages('/teams/' + this.__teamId + '/members', options, cb);
3228 }
3229
3230 /**
3231 * Get Team membership status for a user
3232 * @see https://developer.github.com/v3/orgs/teams/#get-team-membership
3233 * @param {string} username - can be one of: `all`, `maintainer`, or `member`
3234 * @param {Requestable.callback} [cb] - will receive the membership status of a user
3235 * @return {Promise} - the promise for the http request
3236 */
3237
3238 }, {
3239 key: 'getMembership',
3240 value: function getMembership(username, cb) {
3241 log('Getting membership of user ' + username + ' in Team ' + this.__teamId);
3242 return this._request('GET', '/teams/' + this.__teamId + '/memberships/' + username, undefined, cb);
3243 }
3244
3245 /**
3246 * Add a member to the Team
3247 * @see https://developer.github.com/v3/orgs/teams/#add-team-membership
3248 * @param {string} username - can be one of: `all`, `maintainer`, or `member`
3249 * @param {object} options - Parameters for adding a team member
3250 * @param {string} [options.role=member] - The role that this user should have in the team. Can be one
3251 * of: `member`, or `maintainer`
3252 * @param {Requestable.callback} [cb] - will receive the membership status of added user
3253 * @return {Promise} - the promise for the http request
3254 */
3255
3256 }, {
3257 key: 'addMembership',
3258 value: function addMembership(username, options, cb) {
3259 log('Adding user ' + username + ' to Team ' + this.__teamId);
3260 return this._request('PUT', '/teams/' + this.__teamId + '/memberships/' + username, options, cb);
3261 }
3262
3263 /**
3264 * Get repo management status for team
3265 * @see https://developer.github.com/v3/orgs/teams/#remove-team-membership
3266 * @param {string} owner - Organization name
3267 * @param {string} repo - Repo name
3268 * @param {Requestable.callback} [cb] - will receive the membership status of added user
3269 * @return {Promise} - the promise for the http request
3270 */
3271
3272 }, {
3273 key: 'isManagedRepo',
3274 value: function isManagedRepo(owner, repo, cb) {
3275 log('Getting repo management by Team ' + this.__teamId + ' for repo ' + owner + '/' + repo);
3276 return this._request204or404('/teams/' + this.__teamId + '/repos/' + owner + '/' + repo, undefined, cb);
3277 }
3278
3279 /**
3280 * Add or Update repo management status for team
3281 * @see https://developer.github.com/v3/orgs/teams/#add-or-update-team-repository
3282 * @param {string} owner - Organization name
3283 * @param {string} repo - Repo name
3284 * @param {object} options - Parameters for adding or updating repo management for the team
3285 * @param {string} [options.permission] - The permission to grant the team on this repository. Can be one
3286 * of: `pull`, `push`, or `admin`
3287 * @param {Requestable.callback} [cb] - will receive the membership status of added user
3288 * @return {Promise} - the promise for the http request
3289 */
3290
3291 }, {
3292 key: 'manageRepo',
3293 value: function manageRepo(owner, repo, options, cb) {
3294 log('Adding or Updating repo management by Team ' + this.__teamId + ' for repo ' + owner + '/' + repo);
3295 return this._request204or404('/teams/' + this.__teamId + '/repos/' + owner + '/' + repo, options, cb, 'PUT');
3296 }
3297
3298 /**
3299 * Remove repo management status for team
3300 * @see https://developer.github.com/v3/orgs/teams/#remove-team-repository
3301 * @param {string} owner - Organization name
3302 * @param {string} repo - Repo name
3303 * @param {Requestable.callback} [cb] - will receive the membership status of added user
3304 * @return {Promise} - the promise for the http request
3305 */
3306
3307 }, {
3308 key: 'unmanageRepo',
3309 value: function unmanageRepo(owner, repo, cb) {
3310 log('Remove repo management by Team ' + this.__teamId + ' for repo ' + owner + '/' + repo);
3311 return this._request204or404('/teams/' + this.__teamId + '/repos/' + owner + '/' + repo, undefined, cb, 'DELETE');
3312 }
3313
3314 /**
3315 * Delete Team
3316 * @see https://developer.github.com/v3/orgs/teams/#delete-team
3317 * @param {Requestable.callback} [cb] - will receive the list of repositories
3318 * @return {Promise} - the promise for the http request
3319 */
3320
3321 }, {
3322 key: 'deleteTeam',
3323 value: function deleteTeam(cb) {
3324 log('Deleting Team ' + this.__teamId);
3325 return this._request204or404('/teams/' + this.__teamId, undefined, cb, 'DELETE');
3326 }
3327 }]);
3328
3329 return Team;
3330}(_Requestable3.default);
3331
3332module.exports = Team;
3333
3334},{"./Requestable":9,"debug":42}],12:[function(require,module,exports){
3335'use strict';
3336
3337var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3338
3339var _Requestable2 = require('./Requestable');
3340
3341var _Requestable3 = _interopRequireDefault(_Requestable2);
3342
3343var _debug = require('debug');
3344
3345var _debug2 = _interopRequireDefault(_debug);
3346
3347function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
3348
3349function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3350
3351function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
3352
3353function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
3354 * @file
3355 * @copyright 2013 Michael Aufreiter (Development Seed) and 2016 Yahoo Inc.
3356 * @license Licensed under {@link https://spdx.org/licenses/BSD-3-Clause-Clear.html BSD-3-Clause-Clear}.
3357 * Github.js is freely distributable.
3358 */
3359
3360var log = (0, _debug2.default)('github:user');
3361
3362/**
3363 * A User allows scoping of API requests to a particular Github user.
3364 */
3365
3366var User = function (_Requestable) {
3367 _inherits(User, _Requestable);
3368
3369 /**
3370 * Create a User.
3371 * @param {string} [username] - the user to use for user-scoped queries
3372 * @param {Requestable.auth} [auth] - information required to authenticate to Github
3373 * @param {string} [apiBase=https://api.github.com] - the base Github API URL
3374 */
3375 function User(username, auth, apiBase) {
3376 _classCallCheck(this, User);
3377
3378 var _this = _possibleConstructorReturn(this, (User.__proto__ || Object.getPrototypeOf(User)).call(this, auth, apiBase));
3379
3380 _this.__user = username;
3381 return _this;
3382 }
3383
3384 /**
3385 * Get the url for the request. (dependent on if we're requesting for the authenticated user or not)
3386 * @private
3387 * @param {string} endpoint - the endpoint being requested
3388 * @return {string} - the resolved endpoint
3389 */
3390
3391
3392 _createClass(User, [{
3393 key: '__getScopedUrl',
3394 value: function __getScopedUrl(endpoint) {
3395 if (this.__user) {
3396 return endpoint ? '/users/' + this.__user + '/' + endpoint : '/users/' + this.__user;
3397 } else {
3398 // eslint-disable-line
3399 switch (endpoint) {
3400 case '':
3401 return '/user';
3402
3403 case 'notifications':
3404 case 'gists':
3405 return '/' + endpoint;
3406
3407 default:
3408 return '/user/' + endpoint;
3409 }
3410 }
3411 }
3412
3413 /**
3414 * List the user's repositories
3415 * @see https://developer.github.com/v3/repos/#list-user-repositories
3416 * @param {Object} [options={}] - any options to refine the search
3417 * @param {Requestable.callback} [cb] - will receive the list of repositories
3418 * @return {Promise} - the promise for the http request
3419 */
3420
3421 }, {
3422 key: 'listRepos',
3423 value: function listRepos(options, cb) {
3424 if (typeof options === 'function') {
3425 cb = options;
3426 options = {};
3427 }
3428
3429 options = this._getOptionsWithDefaults(options);
3430
3431 log('Fetching repositories with options: ' + JSON.stringify(options));
3432 return this._requestAllPages(this.__getScopedUrl('repos'), options, cb);
3433 }
3434
3435 /**
3436 * List the orgs that the user belongs to
3437 * @see https://developer.github.com/v3/orgs/#list-user-organizations
3438 * @param {Requestable.callback} [cb] - will receive the list of organizations
3439 * @return {Promise} - the promise for the http request
3440 */
3441
3442 }, {
3443 key: 'listOrgs',
3444 value: function listOrgs(cb) {
3445 return this._request('GET', this.__getScopedUrl('orgs'), null, cb);
3446 }
3447
3448 /**
3449 * List followers of a user
3450 * @see https://developer.github.com/v3/users/followers/#list-followers-of-a-user
3451 * @param {Requestable.callback} [cb] - will receive the list of followers
3452 * @return {Promise} - the promise for the http request
3453 */
3454
3455 }, {
3456 key: 'listFollowers',
3457 value: function listFollowers(cb) {
3458 return this._request('GET', this.__getScopedUrl('followers'), null, cb);
3459 }
3460
3461 /**
3462 * List users followed by another user
3463 * @see https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
3464 * @param {Requestable.callback} [cb] - will receive the list of who a user is following
3465 * @return {Promise} - the promise for the http request
3466 */
3467
3468 }, {
3469 key: 'listFollowing',
3470 value: function listFollowing(cb) {
3471 return this._request('GET', this.__getScopedUrl('following'), null, cb);
3472 }
3473
3474 /**
3475 * List the user's gists
3476 * @see https://developer.github.com/v3/gists/#list-a-users-gists
3477 * @param {Requestable.callback} [cb] - will receive the list of gists
3478 * @return {Promise} - the promise for the http request
3479 */
3480
3481 }, {
3482 key: 'listGists',
3483 value: function listGists(cb) {
3484 return this._request('GET', this.__getScopedUrl('gists'), null, cb);
3485 }
3486
3487 /**
3488 * List the user's notifications
3489 * @see https://developer.github.com/v3/activity/notifications/#list-your-notifications
3490 * @param {Object} [options={}] - any options to refine the search
3491 * @param {Requestable.callback} [cb] - will receive the list of repositories
3492 * @return {Promise} - the promise for the http request
3493 */
3494
3495 }, {
3496 key: 'listNotifications',
3497 value: function listNotifications(options, cb) {
3498 options = options || {};
3499 if (typeof options === 'function') {
3500 cb = options;
3501 options = {};
3502 }
3503
3504 options.since = this._dateToISO(options.since);
3505 options.before = this._dateToISO(options.before);
3506
3507 return this._request('GET', this.__getScopedUrl('notifications'), options, cb);
3508 }
3509
3510 /**
3511 * Show the user's profile
3512 * @see https://developer.github.com/v3/users/#get-a-single-user
3513 * @param {Requestable.callback} [cb] - will receive the user's information
3514 * @return {Promise} - the promise for the http request
3515 */
3516
3517 }, {
3518 key: 'getProfile',
3519 value: function getProfile(cb) {
3520 return this._request('GET', this.__getScopedUrl(''), null, cb);
3521 }
3522
3523 /**
3524 * Gets the list of starred repositories for the user
3525 * @see https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
3526 * @param {Requestable.callback} [cb] - will receive the list of starred repositories
3527 * @return {Promise} - the promise for the http request
3528 */
3529
3530 }, {
3531 key: 'listStarredRepos',
3532 value: function listStarredRepos(cb) {
3533 var requestOptions = this._getOptionsWithDefaults();
3534 return this._requestAllPages(this.__getScopedUrl('starred'), requestOptions, cb);
3535 }
3536
3537 /**
3538 * Gets the list of starred gists for the user
3539 * @see https://developer.github.com/v3/gists/#list-starred-gists
3540 * @param {Object} [options={}] - any options to refine the search
3541 * @param {Requestable.callback} [cb] - will receive the list of gists
3542 * @return {Promise} - the promise for the http request
3543 */
3544
3545 }, {
3546 key: 'listStarredGists',
3547 value: function listStarredGists(options, cb) {
3548 options = options || {};
3549 if (typeof options === 'function') {
3550 cb = options;
3551 options = {};
3552 }
3553 options.since = this._dateToISO(options.since);
3554 return this._request('GET', '/gists/starred', options, cb);
3555 }
3556
3557 /**
3558 * List email addresses for a user
3559 * @see https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user
3560 * @param {Requestable.callback} [cb] - will receive the list of emails
3561 * @return {Promise} - the promise for the http request
3562 */
3563
3564 }, {
3565 key: 'getEmails',
3566 value: function getEmails(cb) {
3567 return this._request('GET', '/user/emails', null, cb);
3568 }
3569
3570 /**
3571 * Have the authenticated user follow this user
3572 * @see https://developer.github.com/v3/users/followers/#follow-a-user
3573 * @param {string} username - the user to follow
3574 * @param {Requestable.callback} [cb] - will receive true if the request succeeds
3575 * @return {Promise} - the promise for the http request
3576 */
3577
3578 }, {
3579 key: 'follow',
3580 value: function follow(username, cb) {
3581 return this._request('PUT', '/user/following/' + username, null, cb);
3582 }
3583
3584 /**
3585 * Have the currently authenticated user unfollow this user
3586 * @see https://developer.github.com/v3/users/followers/#follow-a-user
3587 * @param {string} username - the user to unfollow
3588 * @param {Requestable.callback} [cb] - receives true if the request succeeds
3589 * @return {Promise} - the promise for the http request
3590 */
3591
3592 }, {
3593 key: 'unfollow',
3594 value: function unfollow(username, cb) {
3595 return this._request('DELETE', '/user/following/' + username, null, cb);
3596 }
3597
3598 /**
3599 * Create a new repository for the currently authenticated user
3600 * @see https://developer.github.com/v3/repos/#create
3601 * @param {object} options - the repository definition
3602 * @param {Requestable.callback} [cb] - will receive the API response
3603 * @return {Promise} - the promise for the http request
3604 */
3605
3606 }, {
3607 key: 'createRepo',
3608 value: function createRepo(options, cb) {
3609 return this._request('POST', '/user/repos', options, cb);
3610 }
3611 }]);
3612
3613 return User;
3614}(_Requestable3.default);
3615
3616module.exports = User;
3617
3618},{"./Requestable":9,"debug":42}],13:[function(require,module,exports){
3619module.exports = require('./lib/axios');
3620},{"./lib/axios":15}],14:[function(require,module,exports){
3621'use strict';
3622
3623var utils = require('./../utils');
3624var settle = require('./../core/settle');
3625var cookies = require('./../helpers/cookies');
3626var buildURL = require('./../helpers/buildURL');
3627var buildFullPath = require('../core/buildFullPath');
3628var parseHeaders = require('./../helpers/parseHeaders');
3629var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
3630var createError = require('../core/createError');
3631
3632module.exports = function xhrAdapter(config) {
3633 return new Promise(function dispatchXhrRequest(resolve, reject) {
3634 var requestData = config.data;
3635 var requestHeaders = config.headers;
3636
3637 if (utils.isFormData(requestData)) {
3638 delete requestHeaders['Content-Type']; // Let the browser set it
3639 }
3640
3641 var request = new XMLHttpRequest();
3642
3643 // HTTP basic authentication
3644 if (config.auth) {
3645 var username = config.auth.username || '';
3646 var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
3647 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
3648 }
3649
3650 var fullPath = buildFullPath(config.baseURL, config.url);
3651 request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
3652
3653 // Set the request timeout in MS
3654 request.timeout = config.timeout;
3655
3656 // Listen for ready state
3657 request.onreadystatechange = function handleLoad() {
3658 if (!request || request.readyState !== 4) {
3659 return;
3660 }
3661
3662 // The request errored out and we didn't get a response, this will be
3663 // handled by onerror instead
3664 // With one exception: request that using file: protocol, most browsers
3665 // will return status as 0 even though it's a successful request
3666 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
3667 return;
3668 }
3669
3670 // Prepare the response
3671 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
3672 var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
3673 var response = {
3674 data: responseData,
3675 status: request.status,
3676 statusText: request.statusText,
3677 headers: responseHeaders,
3678 config: config,
3679 request: request
3680 };
3681
3682 settle(resolve, reject, response);
3683
3684 // Clean up request
3685 request = null;
3686 };
3687
3688 // Handle browser request cancellation (as opposed to a manual cancellation)
3689 request.onabort = function handleAbort() {
3690 if (!request) {
3691 return;
3692 }
3693
3694 reject(createError('Request aborted', config, 'ECONNABORTED', request));
3695
3696 // Clean up request
3697 request = null;
3698 };
3699
3700 // Handle low level network errors
3701 request.onerror = function handleError() {
3702 // Real errors are hidden from us by the browser
3703 // onerror should only fire if it's a network error
3704 reject(createError('Network Error', config, null, request));
3705
3706 // Clean up request
3707 request = null;
3708 };
3709
3710 // Handle timeout
3711 request.ontimeout = function handleTimeout() {
3712 var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded';
3713 if (config.timeoutErrorMessage) {
3714 timeoutErrorMessage = config.timeoutErrorMessage;
3715 }
3716 reject(createError(timeoutErrorMessage, config, 'ECONNABORTED',
3717 request));
3718
3719 // Clean up request
3720 request = null;
3721 };
3722
3723 // Add xsrf header
3724 // This is only done if running in a standard browser environment.
3725 // Specifically not if we're in a web worker, or react-native.
3726 if (utils.isStandardBrowserEnv()) {
3727 // Add xsrf header
3728 var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
3729 cookies.read(config.xsrfCookieName) :
3730 undefined;
3731
3732 if (xsrfValue) {
3733 requestHeaders[config.xsrfHeaderName] = xsrfValue;
3734 }
3735 }
3736
3737 // Add headers to the request
3738 if ('setRequestHeader' in request) {
3739 utils.forEach(requestHeaders, function setRequestHeader(val, key) {
3740 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
3741 // Remove Content-Type if data is undefined
3742 delete requestHeaders[key];
3743 } else {
3744 // Otherwise add header to the request
3745 request.setRequestHeader(key, val);
3746 }
3747 });
3748 }
3749
3750 // Add withCredentials to request if needed
3751 if (!utils.isUndefined(config.withCredentials)) {
3752 request.withCredentials = !!config.withCredentials;
3753 }
3754
3755 // Add responseType to request if needed
3756 if (config.responseType) {
3757 try {
3758 request.responseType = config.responseType;
3759 } catch (e) {
3760 // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
3761 // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
3762 if (config.responseType !== 'json') {
3763 throw e;
3764 }
3765 }
3766 }
3767
3768 // Handle progress if needed
3769 if (typeof config.onDownloadProgress === 'function') {
3770 request.addEventListener('progress', config.onDownloadProgress);
3771 }
3772
3773 // Not all browsers support upload events
3774 if (typeof config.onUploadProgress === 'function' && request.upload) {
3775 request.upload.addEventListener('progress', config.onUploadProgress);
3776 }
3777
3778 if (config.cancelToken) {
3779 // Handle cancellation
3780 config.cancelToken.promise.then(function onCanceled(cancel) {
3781 if (!request) {
3782 return;
3783 }
3784
3785 request.abort();
3786 reject(cancel);
3787 // Clean up request
3788 request = null;
3789 });
3790 }
3791
3792 if (!requestData) {
3793 requestData = null;
3794 }
3795
3796 // Send the request
3797 request.send(requestData);
3798 });
3799};
3800
3801},{"../core/buildFullPath":21,"../core/createError":22,"./../core/settle":26,"./../helpers/buildURL":30,"./../helpers/cookies":32,"./../helpers/isURLSameOrigin":35,"./../helpers/parseHeaders":37,"./../utils":39}],15:[function(require,module,exports){
3802'use strict';
3803
3804var utils = require('./utils');
3805var bind = require('./helpers/bind');
3806var Axios = require('./core/Axios');
3807var mergeConfig = require('./core/mergeConfig');
3808var defaults = require('./defaults');
3809
3810/**
3811 * Create an instance of Axios
3812 *
3813 * @param {Object} defaultConfig The default config for the instance
3814 * @return {Axios} A new instance of Axios
3815 */
3816function createInstance(defaultConfig) {
3817 var context = new Axios(defaultConfig);
3818 var instance = bind(Axios.prototype.request, context);
3819
3820 // Copy axios.prototype to instance
3821 utils.extend(instance, Axios.prototype, context);
3822
3823 // Copy context to instance
3824 utils.extend(instance, context);
3825
3826 return instance;
3827}
3828
3829// Create the default instance to be exported
3830var axios = createInstance(defaults);
3831
3832// Expose Axios class to allow class inheritance
3833axios.Axios = Axios;
3834
3835// Factory for creating new instances
3836axios.create = function create(instanceConfig) {
3837 return createInstance(mergeConfig(axios.defaults, instanceConfig));
3838};
3839
3840// Expose Cancel & CancelToken
3841axios.Cancel = require('./cancel/Cancel');
3842axios.CancelToken = require('./cancel/CancelToken');
3843axios.isCancel = require('./cancel/isCancel');
3844
3845// Expose all/spread
3846axios.all = function all(promises) {
3847 return Promise.all(promises);
3848};
3849axios.spread = require('./helpers/spread');
3850
3851// Expose isAxiosError
3852axios.isAxiosError = require('./helpers/isAxiosError');
3853
3854module.exports = axios;
3855
3856// Allow use of default import syntax in TypeScript
3857module.exports.default = axios;
3858
3859},{"./cancel/Cancel":16,"./cancel/CancelToken":17,"./cancel/isCancel":18,"./core/Axios":19,"./core/mergeConfig":25,"./defaults":28,"./helpers/bind":29,"./helpers/isAxiosError":34,"./helpers/spread":38,"./utils":39}],16:[function(require,module,exports){
3860'use strict';
3861
3862/**
3863 * A `Cancel` is an object that is thrown when an operation is canceled.
3864 *
3865 * @class
3866 * @param {string=} message The message.
3867 */
3868function Cancel(message) {
3869 this.message = message;
3870}
3871
3872Cancel.prototype.toString = function toString() {
3873 return 'Cancel' + (this.message ? ': ' + this.message : '');
3874};
3875
3876Cancel.prototype.__CANCEL__ = true;
3877
3878module.exports = Cancel;
3879
3880},{}],17:[function(require,module,exports){
3881'use strict';
3882
3883var Cancel = require('./Cancel');
3884
3885/**
3886 * A `CancelToken` is an object that can be used to request cancellation of an operation.
3887 *
3888 * @class
3889 * @param {Function} executor The executor function.
3890 */
3891function CancelToken(executor) {
3892 if (typeof executor !== 'function') {
3893 throw new TypeError('executor must be a function.');
3894 }
3895
3896 var resolvePromise;
3897 this.promise = new Promise(function promiseExecutor(resolve) {
3898 resolvePromise = resolve;
3899 });
3900
3901 var token = this;
3902 executor(function cancel(message) {
3903 if (token.reason) {
3904 // Cancellation has already been requested
3905 return;
3906 }
3907
3908 token.reason = new Cancel(message);
3909 resolvePromise(token.reason);
3910 });
3911}
3912
3913/**
3914 * Throws a `Cancel` if cancellation has been requested.
3915 */
3916CancelToken.prototype.throwIfRequested = function throwIfRequested() {
3917 if (this.reason) {
3918 throw this.reason;
3919 }
3920};
3921
3922/**
3923 * Returns an object that contains a new `CancelToken` and a function that, when called,
3924 * cancels the `CancelToken`.
3925 */
3926CancelToken.source = function source() {
3927 var cancel;
3928 var token = new CancelToken(function executor(c) {
3929 cancel = c;
3930 });
3931 return {
3932 token: token,
3933 cancel: cancel
3934 };
3935};
3936
3937module.exports = CancelToken;
3938
3939},{"./Cancel":16}],18:[function(require,module,exports){
3940'use strict';
3941
3942module.exports = function isCancel(value) {
3943 return !!(value && value.__CANCEL__);
3944};
3945
3946},{}],19:[function(require,module,exports){
3947'use strict';
3948
3949var utils = require('./../utils');
3950var buildURL = require('../helpers/buildURL');
3951var InterceptorManager = require('./InterceptorManager');
3952var dispatchRequest = require('./dispatchRequest');
3953var mergeConfig = require('./mergeConfig');
3954
3955/**
3956 * Create a new instance of Axios
3957 *
3958 * @param {Object} instanceConfig The default config for the instance
3959 */
3960function Axios(instanceConfig) {
3961 this.defaults = instanceConfig;
3962 this.interceptors = {
3963 request: new InterceptorManager(),
3964 response: new InterceptorManager()
3965 };
3966}
3967
3968/**
3969 * Dispatch a request
3970 *
3971 * @param {Object} config The config specific for this request (merged with this.defaults)
3972 */
3973Axios.prototype.request = function request(config) {
3974 /*eslint no-param-reassign:0*/
3975 // Allow for axios('example/url'[, config]) a la fetch API
3976 if (typeof config === 'string') {
3977 config = arguments[1] || {};
3978 config.url = arguments[0];
3979 } else {
3980 config = config || {};
3981 }
3982
3983 config = mergeConfig(this.defaults, config);
3984
3985 // Set config.method
3986 if (config.method) {
3987 config.method = config.method.toLowerCase();
3988 } else if (this.defaults.method) {
3989 config.method = this.defaults.method.toLowerCase();
3990 } else {
3991 config.method = 'get';
3992 }
3993
3994 // Hook up interceptors middleware
3995 var chain = [dispatchRequest, undefined];
3996 var promise = Promise.resolve(config);
3997
3998 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3999 chain.unshift(interceptor.fulfilled, interceptor.rejected);
4000 });
4001
4002 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
4003 chain.push(interceptor.fulfilled, interceptor.rejected);
4004 });
4005
4006 while (chain.length) {
4007 promise = promise.then(chain.shift(), chain.shift());
4008 }
4009
4010 return promise;
4011};
4012
4013Axios.prototype.getUri = function getUri(config) {
4014 config = mergeConfig(this.defaults, config);
4015 return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
4016};
4017
4018// Provide aliases for supported request methods
4019utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
4020 /*eslint func-names:0*/
4021 Axios.prototype[method] = function(url, config) {
4022 return this.request(mergeConfig(config || {}, {
4023 method: method,
4024 url: url,
4025 data: (config || {}).data
4026 }));
4027 };
4028});
4029
4030utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4031 /*eslint func-names:0*/
4032 Axios.prototype[method] = function(url, data, config) {
4033 return this.request(mergeConfig(config || {}, {
4034 method: method,
4035 url: url,
4036 data: data
4037 }));
4038 };
4039});
4040
4041module.exports = Axios;
4042
4043},{"../helpers/buildURL":30,"./../utils":39,"./InterceptorManager":20,"./dispatchRequest":23,"./mergeConfig":25}],20:[function(require,module,exports){
4044'use strict';
4045
4046var utils = require('./../utils');
4047
4048function InterceptorManager() {
4049 this.handlers = [];
4050}
4051
4052/**
4053 * Add a new interceptor to the stack
4054 *
4055 * @param {Function} fulfilled The function to handle `then` for a `Promise`
4056 * @param {Function} rejected The function to handle `reject` for a `Promise`
4057 *
4058 * @return {Number} An ID used to remove interceptor later
4059 */
4060InterceptorManager.prototype.use = function use(fulfilled, rejected) {
4061 this.handlers.push({
4062 fulfilled: fulfilled,
4063 rejected: rejected
4064 });
4065 return this.handlers.length - 1;
4066};
4067
4068/**
4069 * Remove an interceptor from the stack
4070 *
4071 * @param {Number} id The ID that was returned by `use`
4072 */
4073InterceptorManager.prototype.eject = function eject(id) {
4074 if (this.handlers[id]) {
4075 this.handlers[id] = null;
4076 }
4077};
4078
4079/**
4080 * Iterate over all the registered interceptors
4081 *
4082 * This method is particularly useful for skipping over any
4083 * interceptors that may have become `null` calling `eject`.
4084 *
4085 * @param {Function} fn The function to call for each interceptor
4086 */
4087InterceptorManager.prototype.forEach = function forEach(fn) {
4088 utils.forEach(this.handlers, function forEachHandler(h) {
4089 if (h !== null) {
4090 fn(h);
4091 }
4092 });
4093};
4094
4095module.exports = InterceptorManager;
4096
4097},{"./../utils":39}],21:[function(require,module,exports){
4098'use strict';
4099
4100var isAbsoluteURL = require('../helpers/isAbsoluteURL');
4101var combineURLs = require('../helpers/combineURLs');
4102
4103/**
4104 * Creates a new URL by combining the baseURL with the requestedURL,
4105 * only when the requestedURL is not already an absolute URL.
4106 * If the requestURL is absolute, this function returns the requestedURL untouched.
4107 *
4108 * @param {string} baseURL The base URL
4109 * @param {string} requestedURL Absolute or relative URL to combine
4110 * @returns {string} The combined full path
4111 */
4112module.exports = function buildFullPath(baseURL, requestedURL) {
4113 if (baseURL && !isAbsoluteURL(requestedURL)) {
4114 return combineURLs(baseURL, requestedURL);
4115 }
4116 return requestedURL;
4117};
4118
4119},{"../helpers/combineURLs":31,"../helpers/isAbsoluteURL":33}],22:[function(require,module,exports){
4120'use strict';
4121
4122var enhanceError = require('./enhanceError');
4123
4124/**
4125 * Create an Error with the specified message, config, error code, request and response.
4126 *
4127 * @param {string} message The error message.
4128 * @param {Object} config The config.
4129 * @param {string} [code] The error code (for example, 'ECONNABORTED').
4130 * @param {Object} [request] The request.
4131 * @param {Object} [response] The response.
4132 * @returns {Error} The created error.
4133 */
4134module.exports = function createError(message, config, code, request, response) {
4135 var error = new Error(message);
4136 return enhanceError(error, config, code, request, response);
4137};
4138
4139},{"./enhanceError":24}],23:[function(require,module,exports){
4140'use strict';
4141
4142var utils = require('./../utils');
4143var transformData = require('./transformData');
4144var isCancel = require('../cancel/isCancel');
4145var defaults = require('../defaults');
4146
4147/**
4148 * Throws a `Cancel` if cancellation has been requested.
4149 */
4150function throwIfCancellationRequested(config) {
4151 if (config.cancelToken) {
4152 config.cancelToken.throwIfRequested();
4153 }
4154}
4155
4156/**
4157 * Dispatch a request to the server using the configured adapter.
4158 *
4159 * @param {object} config The config that is to be used for the request
4160 * @returns {Promise} The Promise to be fulfilled
4161 */
4162module.exports = function dispatchRequest(config) {
4163 throwIfCancellationRequested(config);
4164
4165 // Ensure headers exist
4166 config.headers = config.headers || {};
4167
4168 // Transform request data
4169 config.data = transformData(
4170 config.data,
4171 config.headers,
4172 config.transformRequest
4173 );
4174
4175 // Flatten headers
4176 config.headers = utils.merge(
4177 config.headers.common || {},
4178 config.headers[config.method] || {},
4179 config.headers
4180 );
4181
4182 utils.forEach(
4183 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
4184 function cleanHeaderConfig(method) {
4185 delete config.headers[method];
4186 }
4187 );
4188
4189 var adapter = config.adapter || defaults.adapter;
4190
4191 return adapter(config).then(function onAdapterResolution(response) {
4192 throwIfCancellationRequested(config);
4193
4194 // Transform response data
4195 response.data = transformData(
4196 response.data,
4197 response.headers,
4198 config.transformResponse
4199 );
4200
4201 return response;
4202 }, function onAdapterRejection(reason) {
4203 if (!isCancel(reason)) {
4204 throwIfCancellationRequested(config);
4205
4206 // Transform response data
4207 if (reason && reason.response) {
4208 reason.response.data = transformData(
4209 reason.response.data,
4210 reason.response.headers,
4211 config.transformResponse
4212 );
4213 }
4214 }
4215
4216 return Promise.reject(reason);
4217 });
4218};
4219
4220},{"../cancel/isCancel":18,"../defaults":28,"./../utils":39,"./transformData":27}],24:[function(require,module,exports){
4221'use strict';
4222
4223/**
4224 * Update an Error with the specified config, error code, and response.
4225 *
4226 * @param {Error} error The error to update.
4227 * @param {Object} config The config.
4228 * @param {string} [code] The error code (for example, 'ECONNABORTED').
4229 * @param {Object} [request] The request.
4230 * @param {Object} [response] The response.
4231 * @returns {Error} The error.
4232 */
4233module.exports = function enhanceError(error, config, code, request, response) {
4234 error.config = config;
4235 if (code) {
4236 error.code = code;
4237 }
4238
4239 error.request = request;
4240 error.response = response;
4241 error.isAxiosError = true;
4242
4243 error.toJSON = function toJSON() {
4244 return {
4245 // Standard
4246 message: this.message,
4247 name: this.name,
4248 // Microsoft
4249 description: this.description,
4250 number: this.number,
4251 // Mozilla
4252 fileName: this.fileName,
4253 lineNumber: this.lineNumber,
4254 columnNumber: this.columnNumber,
4255 stack: this.stack,
4256 // Axios
4257 config: this.config,
4258 code: this.code
4259 };
4260 };
4261 return error;
4262};
4263
4264},{}],25:[function(require,module,exports){
4265'use strict';
4266
4267var utils = require('../utils');
4268
4269/**
4270 * Config-specific merge-function which creates a new config-object
4271 * by merging two configuration objects together.
4272 *
4273 * @param {Object} config1
4274 * @param {Object} config2
4275 * @returns {Object} New object resulting from merging config2 to config1
4276 */
4277module.exports = function mergeConfig(config1, config2) {
4278 // eslint-disable-next-line no-param-reassign
4279 config2 = config2 || {};
4280 var config = {};
4281
4282 var valueFromConfig2Keys = ['url', 'method', 'data'];
4283 var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
4284 var defaultToConfig2Keys = [
4285 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
4286 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
4287 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
4288 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
4289 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
4290 ];
4291 var directMergeKeys = ['validateStatus'];
4292
4293 function getMergedValue(target, source) {
4294 if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
4295 return utils.merge(target, source);
4296 } else if (utils.isPlainObject(source)) {
4297 return utils.merge({}, source);
4298 } else if (utils.isArray(source)) {
4299 return source.slice();
4300 }
4301 return source;
4302 }
4303
4304 function mergeDeepProperties(prop) {
4305 if (!utils.isUndefined(config2[prop])) {
4306 config[prop] = getMergedValue(config1[prop], config2[prop]);
4307 } else if (!utils.isUndefined(config1[prop])) {
4308 config[prop] = getMergedValue(undefined, config1[prop]);
4309 }
4310 }
4311
4312 utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
4313 if (!utils.isUndefined(config2[prop])) {
4314 config[prop] = getMergedValue(undefined, config2[prop]);
4315 }
4316 });
4317
4318 utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
4319
4320 utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
4321 if (!utils.isUndefined(config2[prop])) {
4322 config[prop] = getMergedValue(undefined, config2[prop]);
4323 } else if (!utils.isUndefined(config1[prop])) {
4324 config[prop] = getMergedValue(undefined, config1[prop]);
4325 }
4326 });
4327
4328 utils.forEach(directMergeKeys, function merge(prop) {
4329 if (prop in config2) {
4330 config[prop] = getMergedValue(config1[prop], config2[prop]);
4331 } else if (prop in config1) {
4332 config[prop] = getMergedValue(undefined, config1[prop]);
4333 }
4334 });
4335
4336 var axiosKeys = valueFromConfig2Keys
4337 .concat(mergeDeepPropertiesKeys)
4338 .concat(defaultToConfig2Keys)
4339 .concat(directMergeKeys);
4340
4341 var otherKeys = Object
4342 .keys(config1)
4343 .concat(Object.keys(config2))
4344 .filter(function filterAxiosKeys(key) {
4345 return axiosKeys.indexOf(key) === -1;
4346 });
4347
4348 utils.forEach(otherKeys, mergeDeepProperties);
4349
4350 return config;
4351};
4352
4353},{"../utils":39}],26:[function(require,module,exports){
4354'use strict';
4355
4356var createError = require('./createError');
4357
4358/**
4359 * Resolve or reject a Promise based on response status.
4360 *
4361 * @param {Function} resolve A function that resolves the promise.
4362 * @param {Function} reject A function that rejects the promise.
4363 * @param {object} response The response.
4364 */
4365module.exports = function settle(resolve, reject, response) {
4366 var validateStatus = response.config.validateStatus;
4367 if (!response.status || !validateStatus || validateStatus(response.status)) {
4368 resolve(response);
4369 } else {
4370 reject(createError(
4371 'Request failed with status code ' + response.status,
4372 response.config,
4373 null,
4374 response.request,
4375 response
4376 ));
4377 }
4378};
4379
4380},{"./createError":22}],27:[function(require,module,exports){
4381'use strict';
4382
4383var utils = require('./../utils');
4384
4385/**
4386 * Transform the data for a request or a response
4387 *
4388 * @param {Object|String} data The data to be transformed
4389 * @param {Array} headers The headers for the request or response
4390 * @param {Array|Function} fns A single function or Array of functions
4391 * @returns {*} The resulting transformed data
4392 */
4393module.exports = function transformData(data, headers, fns) {
4394 /*eslint no-param-reassign:0*/
4395 utils.forEach(fns, function transform(fn) {
4396 data = fn(data, headers);
4397 });
4398
4399 return data;
4400};
4401
4402},{"./../utils":39}],28:[function(require,module,exports){
4403(function (process){(function (){
4404'use strict';
4405
4406var utils = require('./utils');
4407var normalizeHeaderName = require('./helpers/normalizeHeaderName');
4408
4409var DEFAULT_CONTENT_TYPE = {
4410 'Content-Type': 'application/x-www-form-urlencoded'
4411};
4412
4413function setContentTypeIfUnset(headers, value) {
4414 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
4415 headers['Content-Type'] = value;
4416 }
4417}
4418
4419function getDefaultAdapter() {
4420 var adapter;
4421 if (typeof XMLHttpRequest !== 'undefined') {
4422 // For browsers use XHR adapter
4423 adapter = require('./adapters/xhr');
4424 } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
4425 // For node use HTTP adapter
4426 adapter = require('./adapters/http');
4427 }
4428 return adapter;
4429}
4430
4431var defaults = {
4432 adapter: getDefaultAdapter(),
4433
4434 transformRequest: [function transformRequest(data, headers) {
4435 normalizeHeaderName(headers, 'Accept');
4436 normalizeHeaderName(headers, 'Content-Type');
4437 if (utils.isFormData(data) ||
4438 utils.isArrayBuffer(data) ||
4439 utils.isBuffer(data) ||
4440 utils.isStream(data) ||
4441 utils.isFile(data) ||
4442 utils.isBlob(data)
4443 ) {
4444 return data;
4445 }
4446 if (utils.isArrayBufferView(data)) {
4447 return data.buffer;
4448 }
4449 if (utils.isURLSearchParams(data)) {
4450 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
4451 return data.toString();
4452 }
4453 if (utils.isObject(data)) {
4454 setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
4455 return JSON.stringify(data);
4456 }
4457 return data;
4458 }],
4459
4460 transformResponse: [function transformResponse(data) {
4461 /*eslint no-param-reassign:0*/
4462 if (typeof data === 'string') {
4463 try {
4464 data = JSON.parse(data);
4465 } catch (e) { /* Ignore */ }
4466 }
4467 return data;
4468 }],
4469
4470 /**
4471 * A timeout in milliseconds to abort a request. If set to 0 (default) a
4472 * timeout is not created.
4473 */
4474 timeout: 0,
4475
4476 xsrfCookieName: 'XSRF-TOKEN',
4477 xsrfHeaderName: 'X-XSRF-TOKEN',
4478
4479 maxContentLength: -1,
4480 maxBodyLength: -1,
4481
4482 validateStatus: function validateStatus(status) {
4483 return status >= 200 && status < 300;
4484 }
4485};
4486
4487defaults.headers = {
4488 common: {
4489 'Accept': 'application/json, text/plain, */*'
4490 }
4491};
4492
4493utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
4494 defaults.headers[method] = {};
4495});
4496
4497utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
4498 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
4499});
4500
4501module.exports = defaults;
4502
4503}).call(this)}).call(this,require('_process'))
4504
4505},{"./adapters/http":14,"./adapters/xhr":14,"./helpers/normalizeHeaderName":36,"./utils":39,"_process":48}],29:[function(require,module,exports){
4506'use strict';
4507
4508module.exports = function bind(fn, thisArg) {
4509 return function wrap() {
4510 var args = new Array(arguments.length);
4511 for (var i = 0; i < args.length; i++) {
4512 args[i] = arguments[i];
4513 }
4514 return fn.apply(thisArg, args);
4515 };
4516};
4517
4518},{}],30:[function(require,module,exports){
4519'use strict';
4520
4521var utils = require('./../utils');
4522
4523function encode(val) {
4524 return encodeURIComponent(val).
4525 replace(/%3A/gi, ':').
4526 replace(/%24/g, '$').
4527 replace(/%2C/gi, ',').
4528 replace(/%20/g, '+').
4529 replace(/%5B/gi, '[').
4530 replace(/%5D/gi, ']');
4531}
4532
4533/**
4534 * Build a URL by appending params to the end
4535 *
4536 * @param {string} url The base of the url (e.g., http://www.google.com)
4537 * @param {object} [params] The params to be appended
4538 * @returns {string} The formatted url
4539 */
4540module.exports = function buildURL(url, params, paramsSerializer) {
4541 /*eslint no-param-reassign:0*/
4542 if (!params) {
4543 return url;
4544 }
4545
4546 var serializedParams;
4547 if (paramsSerializer) {
4548 serializedParams = paramsSerializer(params);
4549 } else if (utils.isURLSearchParams(params)) {
4550 serializedParams = params.toString();
4551 } else {
4552 var parts = [];
4553
4554 utils.forEach(params, function serialize(val, key) {
4555 if (val === null || typeof val === 'undefined') {
4556 return;
4557 }
4558
4559 if (utils.isArray(val)) {
4560 key = key + '[]';
4561 } else {
4562 val = [val];
4563 }
4564
4565 utils.forEach(val, function parseValue(v) {
4566 if (utils.isDate(v)) {
4567 v = v.toISOString();
4568 } else if (utils.isObject(v)) {
4569 v = JSON.stringify(v);
4570 }
4571 parts.push(encode(key) + '=' + encode(v));
4572 });
4573 });
4574
4575 serializedParams = parts.join('&');
4576 }
4577
4578 if (serializedParams) {
4579 var hashmarkIndex = url.indexOf('#');
4580 if (hashmarkIndex !== -1) {
4581 url = url.slice(0, hashmarkIndex);
4582 }
4583
4584 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
4585 }
4586
4587 return url;
4588};
4589
4590},{"./../utils":39}],31:[function(require,module,exports){
4591'use strict';
4592
4593/**
4594 * Creates a new URL by combining the specified URLs
4595 *
4596 * @param {string} baseURL The base URL
4597 * @param {string} relativeURL The relative URL
4598 * @returns {string} The combined URL
4599 */
4600module.exports = function combineURLs(baseURL, relativeURL) {
4601 return relativeURL
4602 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
4603 : baseURL;
4604};
4605
4606},{}],32:[function(require,module,exports){
4607'use strict';
4608
4609var utils = require('./../utils');
4610
4611module.exports = (
4612 utils.isStandardBrowserEnv() ?
4613
4614 // Standard browser envs support document.cookie
4615 (function standardBrowserEnv() {
4616 return {
4617 write: function write(name, value, expires, path, domain, secure) {
4618 var cookie = [];
4619 cookie.push(name + '=' + encodeURIComponent(value));
4620
4621 if (utils.isNumber(expires)) {
4622 cookie.push('expires=' + new Date(expires).toGMTString());
4623 }
4624
4625 if (utils.isString(path)) {
4626 cookie.push('path=' + path);
4627 }
4628
4629 if (utils.isString(domain)) {
4630 cookie.push('domain=' + domain);
4631 }
4632
4633 if (secure === true) {
4634 cookie.push('secure');
4635 }
4636
4637 document.cookie = cookie.join('; ');
4638 },
4639
4640 read: function read(name) {
4641 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
4642 return (match ? decodeURIComponent(match[3]) : null);
4643 },
4644
4645 remove: function remove(name) {
4646 this.write(name, '', Date.now() - 86400000);
4647 }
4648 };
4649 })() :
4650
4651 // Non standard browser env (web workers, react-native) lack needed support.
4652 (function nonStandardBrowserEnv() {
4653 return {
4654 write: function write() {},
4655 read: function read() { return null; },
4656 remove: function remove() {}
4657 };
4658 })()
4659);
4660
4661},{"./../utils":39}],33:[function(require,module,exports){
4662'use strict';
4663
4664/**
4665 * Determines whether the specified URL is absolute
4666 *
4667 * @param {string} url The URL to test
4668 * @returns {boolean} True if the specified URL is absolute, otherwise false
4669 */
4670module.exports = function isAbsoluteURL(url) {
4671 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
4672 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
4673 // by any combination of letters, digits, plus, period, or hyphen.
4674 return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
4675};
4676
4677},{}],34:[function(require,module,exports){
4678'use strict';
4679
4680/**
4681 * Determines whether the payload is an error thrown by Axios
4682 *
4683 * @param {*} payload The value to test
4684 * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
4685 */
4686module.exports = function isAxiosError(payload) {
4687 return (typeof payload === 'object') && (payload.isAxiosError === true);
4688};
4689
4690},{}],35:[function(require,module,exports){
4691'use strict';
4692
4693var utils = require('./../utils');
4694
4695module.exports = (
4696 utils.isStandardBrowserEnv() ?
4697
4698 // Standard browser envs have full support of the APIs needed to test
4699 // whether the request URL is of the same origin as current location.
4700 (function standardBrowserEnv() {
4701 var msie = /(msie|trident)/i.test(navigator.userAgent);
4702 var urlParsingNode = document.createElement('a');
4703 var originURL;
4704
4705 /**
4706 * Parse a URL to discover it's components
4707 *
4708 * @param {String} url The URL to be parsed
4709 * @returns {Object}
4710 */
4711 function resolveURL(url) {
4712 var href = url;
4713
4714 if (msie) {
4715 // IE needs attribute set twice to normalize properties
4716 urlParsingNode.setAttribute('href', href);
4717 href = urlParsingNode.href;
4718 }
4719
4720 urlParsingNode.setAttribute('href', href);
4721
4722 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
4723 return {
4724 href: urlParsingNode.href,
4725 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
4726 host: urlParsingNode.host,
4727 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
4728 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
4729 hostname: urlParsingNode.hostname,
4730 port: urlParsingNode.port,
4731 pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
4732 urlParsingNode.pathname :
4733 '/' + urlParsingNode.pathname
4734 };
4735 }
4736
4737 originURL = resolveURL(window.location.href);
4738
4739 /**
4740 * Determine if a URL shares the same origin as the current location
4741 *
4742 * @param {String} requestURL The URL to test
4743 * @returns {boolean} True if URL shares the same origin, otherwise false
4744 */
4745 return function isURLSameOrigin(requestURL) {
4746 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
4747 return (parsed.protocol === originURL.protocol &&
4748 parsed.host === originURL.host);
4749 };
4750 })() :
4751
4752 // Non standard browser envs (web workers, react-native) lack needed support.
4753 (function nonStandardBrowserEnv() {
4754 return function isURLSameOrigin() {
4755 return true;
4756 };
4757 })()
4758);
4759
4760},{"./../utils":39}],36:[function(require,module,exports){
4761'use strict';
4762
4763var utils = require('../utils');
4764
4765module.exports = function normalizeHeaderName(headers, normalizedName) {
4766 utils.forEach(headers, function processHeader(value, name) {
4767 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
4768 headers[normalizedName] = value;
4769 delete headers[name];
4770 }
4771 });
4772};
4773
4774},{"../utils":39}],37:[function(require,module,exports){
4775'use strict';
4776
4777var utils = require('./../utils');
4778
4779// Headers whose duplicates are ignored by node
4780// c.f. https://nodejs.org/api/http.html#http_message_headers
4781var ignoreDuplicateOf = [
4782 'age', 'authorization', 'content-length', 'content-type', 'etag',
4783 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
4784 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
4785 'referer', 'retry-after', 'user-agent'
4786];
4787
4788/**
4789 * Parse headers into an object
4790 *
4791 * ```
4792 * Date: Wed, 27 Aug 2014 08:58:49 GMT
4793 * Content-Type: application/json
4794 * Connection: keep-alive
4795 * Transfer-Encoding: chunked
4796 * ```
4797 *
4798 * @param {String} headers Headers needing to be parsed
4799 * @returns {Object} Headers parsed into an object
4800 */
4801module.exports = function parseHeaders(headers) {
4802 var parsed = {};
4803 var key;
4804 var val;
4805 var i;
4806
4807 if (!headers) { return parsed; }
4808
4809 utils.forEach(headers.split('\n'), function parser(line) {
4810 i = line.indexOf(':');
4811 key = utils.trim(line.substr(0, i)).toLowerCase();
4812 val = utils.trim(line.substr(i + 1));
4813
4814 if (key) {
4815 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
4816 return;
4817 }
4818 if (key === 'set-cookie') {
4819 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
4820 } else {
4821 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
4822 }
4823 }
4824 });
4825
4826 return parsed;
4827};
4828
4829},{"./../utils":39}],38:[function(require,module,exports){
4830'use strict';
4831
4832/**
4833 * Syntactic sugar for invoking a function and expanding an array for arguments.
4834 *
4835 * Common use case would be to use `Function.prototype.apply`.
4836 *
4837 * ```js
4838 * function f(x, y, z) {}
4839 * var args = [1, 2, 3];
4840 * f.apply(null, args);
4841 * ```
4842 *
4843 * With `spread` this example can be re-written.
4844 *
4845 * ```js
4846 * spread(function(x, y, z) {})([1, 2, 3]);
4847 * ```
4848 *
4849 * @param {Function} callback
4850 * @returns {Function}
4851 */
4852module.exports = function spread(callback) {
4853 return function wrap(arr) {
4854 return callback.apply(null, arr);
4855 };
4856};
4857
4858},{}],39:[function(require,module,exports){
4859'use strict';
4860
4861var bind = require('./helpers/bind');
4862
4863/*global toString:true*/
4864
4865// utils is a library of generic helper functions non-specific to axios
4866
4867var toString = Object.prototype.toString;
4868
4869/**
4870 * Determine if a value is an Array
4871 *
4872 * @param {Object} val The value to test
4873 * @returns {boolean} True if value is an Array, otherwise false
4874 */
4875function isArray(val) {
4876 return toString.call(val) === '[object Array]';
4877}
4878
4879/**
4880 * Determine if a value is undefined
4881 *
4882 * @param {Object} val The value to test
4883 * @returns {boolean} True if the value is undefined, otherwise false
4884 */
4885function isUndefined(val) {
4886 return typeof val === 'undefined';
4887}
4888
4889/**
4890 * Determine if a value is a Buffer
4891 *
4892 * @param {Object} val The value to test
4893 * @returns {boolean} True if value is a Buffer, otherwise false
4894 */
4895function isBuffer(val) {
4896 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
4897 && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
4898}
4899
4900/**
4901 * Determine if a value is an ArrayBuffer
4902 *
4903 * @param {Object} val The value to test
4904 * @returns {boolean} True if value is an ArrayBuffer, otherwise false
4905 */
4906function isArrayBuffer(val) {
4907 return toString.call(val) === '[object ArrayBuffer]';
4908}
4909
4910/**
4911 * Determine if a value is a FormData
4912 *
4913 * @param {Object} val The value to test
4914 * @returns {boolean} True if value is an FormData, otherwise false
4915 */
4916function isFormData(val) {
4917 return (typeof FormData !== 'undefined') && (val instanceof FormData);
4918}
4919
4920/**
4921 * Determine if a value is a view on an ArrayBuffer
4922 *
4923 * @param {Object} val The value to test
4924 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
4925 */
4926function isArrayBufferView(val) {
4927 var result;
4928 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
4929 result = ArrayBuffer.isView(val);
4930 } else {
4931 result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
4932 }
4933 return result;
4934}
4935
4936/**
4937 * Determine if a value is a String
4938 *
4939 * @param {Object} val The value to test
4940 * @returns {boolean} True if value is a String, otherwise false
4941 */
4942function isString(val) {
4943 return typeof val === 'string';
4944}
4945
4946/**
4947 * Determine if a value is a Number
4948 *
4949 * @param {Object} val The value to test
4950 * @returns {boolean} True if value is a Number, otherwise false
4951 */
4952function isNumber(val) {
4953 return typeof val === 'number';
4954}
4955
4956/**
4957 * Determine if a value is an Object
4958 *
4959 * @param {Object} val The value to test
4960 * @returns {boolean} True if value is an Object, otherwise false
4961 */
4962function isObject(val) {
4963 return val !== null && typeof val === 'object';
4964}
4965
4966/**
4967 * Determine if a value is a plain Object
4968 *
4969 * @param {Object} val The value to test
4970 * @return {boolean} True if value is a plain Object, otherwise false
4971 */
4972function isPlainObject(val) {
4973 if (toString.call(val) !== '[object Object]') {
4974 return false;
4975 }
4976
4977 var prototype = Object.getPrototypeOf(val);
4978 return prototype === null || prototype === Object.prototype;
4979}
4980
4981/**
4982 * Determine if a value is a Date
4983 *
4984 * @param {Object} val The value to test
4985 * @returns {boolean} True if value is a Date, otherwise false
4986 */
4987function isDate(val) {
4988 return toString.call(val) === '[object Date]';
4989}
4990
4991/**
4992 * Determine if a value is a File
4993 *
4994 * @param {Object} val The value to test
4995 * @returns {boolean} True if value is a File, otherwise false
4996 */
4997function isFile(val) {
4998 return toString.call(val) === '[object File]';
4999}
5000
5001/**
5002 * Determine if a value is a Blob
5003 *
5004 * @param {Object} val The value to test
5005 * @returns {boolean} True if value is a Blob, otherwise false
5006 */
5007function isBlob(val) {
5008 return toString.call(val) === '[object Blob]';
5009}
5010
5011/**
5012 * Determine if a value is a Function
5013 *
5014 * @param {Object} val The value to test
5015 * @returns {boolean} True if value is a Function, otherwise false
5016 */
5017function isFunction(val) {
5018 return toString.call(val) === '[object Function]';
5019}
5020
5021/**
5022 * Determine if a value is a Stream
5023 *
5024 * @param {Object} val The value to test
5025 * @returns {boolean} True if value is a Stream, otherwise false
5026 */
5027function isStream(val) {
5028 return isObject(val) && isFunction(val.pipe);
5029}
5030
5031/**
5032 * Determine if a value is a URLSearchParams object
5033 *
5034 * @param {Object} val The value to test
5035 * @returns {boolean} True if value is a URLSearchParams object, otherwise false
5036 */
5037function isURLSearchParams(val) {
5038 return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
5039}
5040
5041/**
5042 * Trim excess whitespace off the beginning and end of a string
5043 *
5044 * @param {String} str The String to trim
5045 * @returns {String} The String freed of excess whitespace
5046 */
5047function trim(str) {
5048 return str.replace(/^\s*/, '').replace(/\s*$/, '');
5049}
5050
5051/**
5052 * Determine if we're running in a standard browser environment
5053 *
5054 * This allows axios to run in a web worker, and react-native.
5055 * Both environments support XMLHttpRequest, but not fully standard globals.
5056 *
5057 * web workers:
5058 * typeof window -> undefined
5059 * typeof document -> undefined
5060 *
5061 * react-native:
5062 * navigator.product -> 'ReactNative'
5063 * nativescript
5064 * navigator.product -> 'NativeScript' or 'NS'
5065 */
5066function isStandardBrowserEnv() {
5067 if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
5068 navigator.product === 'NativeScript' ||
5069 navigator.product === 'NS')) {
5070 return false;
5071 }
5072 return (
5073 typeof window !== 'undefined' &&
5074 typeof document !== 'undefined'
5075 );
5076}
5077
5078/**
5079 * Iterate over an Array or an Object invoking a function for each item.
5080 *
5081 * If `obj` is an Array callback will be called passing
5082 * the value, index, and complete array for each item.
5083 *
5084 * If 'obj' is an Object callback will be called passing
5085 * the value, key, and complete object for each property.
5086 *
5087 * @param {Object|Array} obj The object to iterate
5088 * @param {Function} fn The callback to invoke for each item
5089 */
5090function forEach(obj, fn) {
5091 // Don't bother if no value provided
5092 if (obj === null || typeof obj === 'undefined') {
5093 return;
5094 }
5095
5096 // Force an array if not already something iterable
5097 if (typeof obj !== 'object') {
5098 /*eslint no-param-reassign:0*/
5099 obj = [obj];
5100 }
5101
5102 if (isArray(obj)) {
5103 // Iterate over array values
5104 for (var i = 0, l = obj.length; i < l; i++) {
5105 fn.call(null, obj[i], i, obj);
5106 }
5107 } else {
5108 // Iterate over object keys
5109 for (var key in obj) {
5110 if (Object.prototype.hasOwnProperty.call(obj, key)) {
5111 fn.call(null, obj[key], key, obj);
5112 }
5113 }
5114 }
5115}
5116
5117/**
5118 * Accepts varargs expecting each argument to be an object, then
5119 * immutably merges the properties of each object and returns result.
5120 *
5121 * When multiple objects contain the same key the later object in
5122 * the arguments list will take precedence.
5123 *
5124 * Example:
5125 *
5126 * ```js
5127 * var result = merge({foo: 123}, {foo: 456});
5128 * console.log(result.foo); // outputs 456
5129 * ```
5130 *
5131 * @param {Object} obj1 Object to merge
5132 * @returns {Object} Result of all merge properties
5133 */
5134function merge(/* obj1, obj2, obj3, ... */) {
5135 var result = {};
5136 function assignValue(val, key) {
5137 if (isPlainObject(result[key]) && isPlainObject(val)) {
5138 result[key] = merge(result[key], val);
5139 } else if (isPlainObject(val)) {
5140 result[key] = merge({}, val);
5141 } else if (isArray(val)) {
5142 result[key] = val.slice();
5143 } else {
5144 result[key] = val;
5145 }
5146 }
5147
5148 for (var i = 0, l = arguments.length; i < l; i++) {
5149 forEach(arguments[i], assignValue);
5150 }
5151 return result;
5152}
5153
5154/**
5155 * Extends object a by mutably adding to it the properties of object b.
5156 *
5157 * @param {Object} a The object to be extended
5158 * @param {Object} b The object to copy properties from
5159 * @param {Object} thisArg The object to bind function to
5160 * @return {Object} The resulting value of object a
5161 */
5162function extend(a, b, thisArg) {
5163 forEach(b, function assignValue(val, key) {
5164 if (thisArg && typeof val === 'function') {
5165 a[key] = bind(val, thisArg);
5166 } else {
5167 a[key] = val;
5168 }
5169 });
5170 return a;
5171}
5172
5173/**
5174 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
5175 *
5176 * @param {string} content with BOM
5177 * @return {string} content value without BOM
5178 */
5179function stripBOM(content) {
5180 if (content.charCodeAt(0) === 0xFEFF) {
5181 content = content.slice(1);
5182 }
5183 return content;
5184}
5185
5186module.exports = {
5187 isArray: isArray,
5188 isArrayBuffer: isArrayBuffer,
5189 isBuffer: isBuffer,
5190 isFormData: isFormData,
5191 isArrayBufferView: isArrayBufferView,
5192 isString: isString,
5193 isNumber: isNumber,
5194 isObject: isObject,
5195 isPlainObject: isPlainObject,
5196 isUndefined: isUndefined,
5197 isDate: isDate,
5198 isFile: isFile,
5199 isBlob: isBlob,
5200 isFunction: isFunction,
5201 isStream: isStream,
5202 isURLSearchParams: isURLSearchParams,
5203 isStandardBrowserEnv: isStandardBrowserEnv,
5204 forEach: forEach,
5205 merge: merge,
5206 extend: extend,
5207 trim: trim,
5208 stripBOM: stripBOM
5209};
5210
5211},{"./helpers/bind":29}],40:[function(require,module,exports){
5212'use strict'
5213
5214exports.byteLength = byteLength
5215exports.toByteArray = toByteArray
5216exports.fromByteArray = fromByteArray
5217
5218var lookup = []
5219var revLookup = []
5220var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
5221
5222var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
5223for (var i = 0, len = code.length; i < len; ++i) {
5224 lookup[i] = code[i]
5225 revLookup[code.charCodeAt(i)] = i
5226}
5227
5228// Support decoding URL-safe base64 strings, as Node.js does.
5229// See: https://en.wikipedia.org/wiki/Base64#URL_applications
5230revLookup['-'.charCodeAt(0)] = 62
5231revLookup['_'.charCodeAt(0)] = 63
5232
5233function getLens (b64) {
5234 var len = b64.length
5235
5236 if (len % 4 > 0) {
5237 throw new Error('Invalid string. Length must be a multiple of 4')
5238 }
5239
5240 // Trim off extra bytes after placeholder bytes are found
5241 // See: https://github.com/beatgammit/base64-js/issues/42
5242 var validLen = b64.indexOf('=')
5243 if (validLen === -1) validLen = len
5244
5245 var placeHoldersLen = validLen === len
5246 ? 0
5247 : 4 - (validLen % 4)
5248
5249 return [validLen, placeHoldersLen]
5250}
5251
5252// base64 is 4/3 + up to two characters of the original data
5253function byteLength (b64) {
5254 var lens = getLens(b64)
5255 var validLen = lens[0]
5256 var placeHoldersLen = lens[1]
5257 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
5258}
5259
5260function _byteLength (b64, validLen, placeHoldersLen) {
5261 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
5262}
5263
5264function toByteArray (b64) {
5265 var tmp
5266 var lens = getLens(b64)
5267 var validLen = lens[0]
5268 var placeHoldersLen = lens[1]
5269
5270 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
5271
5272 var curByte = 0
5273
5274 // if there are placeholders, only get up to the last complete 4 chars
5275 var len = placeHoldersLen > 0
5276 ? validLen - 4
5277 : validLen
5278
5279 var i
5280 for (i = 0; i < len; i += 4) {
5281 tmp =
5282 (revLookup[b64.charCodeAt(i)] << 18) |
5283 (revLookup[b64.charCodeAt(i + 1)] << 12) |
5284 (revLookup[b64.charCodeAt(i + 2)] << 6) |
5285 revLookup[b64.charCodeAt(i + 3)]
5286 arr[curByte++] = (tmp >> 16) & 0xFF
5287 arr[curByte++] = (tmp >> 8) & 0xFF
5288 arr[curByte++] = tmp & 0xFF
5289 }
5290
5291 if (placeHoldersLen === 2) {
5292 tmp =
5293 (revLookup[b64.charCodeAt(i)] << 2) |
5294 (revLookup[b64.charCodeAt(i + 1)] >> 4)
5295 arr[curByte++] = tmp & 0xFF
5296 }
5297
5298 if (placeHoldersLen === 1) {
5299 tmp =
5300 (revLookup[b64.charCodeAt(i)] << 10) |
5301 (revLookup[b64.charCodeAt(i + 1)] << 4) |
5302 (revLookup[b64.charCodeAt(i + 2)] >> 2)
5303 arr[curByte++] = (tmp >> 8) & 0xFF
5304 arr[curByte++] = tmp & 0xFF
5305 }
5306
5307 return arr
5308}
5309
5310function tripletToBase64 (num) {
5311 return lookup[num >> 18 & 0x3F] +
5312 lookup[num >> 12 & 0x3F] +
5313 lookup[num >> 6 & 0x3F] +
5314 lookup[num & 0x3F]
5315}
5316
5317function encodeChunk (uint8, start, end) {
5318 var tmp
5319 var output = []
5320 for (var i = start; i < end; i += 3) {
5321 tmp =
5322 ((uint8[i] << 16) & 0xFF0000) +
5323 ((uint8[i + 1] << 8) & 0xFF00) +
5324 (uint8[i + 2] & 0xFF)
5325 output.push(tripletToBase64(tmp))
5326 }
5327 return output.join('')
5328}
5329
5330function fromByteArray (uint8) {
5331 var tmp
5332 var len = uint8.length
5333 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
5334 var parts = []
5335 var maxChunkLength = 16383 // must be multiple of 3
5336
5337 // go through the array every three bytes, we'll deal with trailing stuff later
5338 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
5339 parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
5340 }
5341
5342 // pad the end with zeros, but make sure to not forget the extra bytes
5343 if (extraBytes === 1) {
5344 tmp = uint8[len - 1]
5345 parts.push(
5346 lookup[tmp >> 2] +
5347 lookup[(tmp << 4) & 0x3F] +
5348 '=='
5349 )
5350 } else if (extraBytes === 2) {
5351 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
5352 parts.push(
5353 lookup[tmp >> 10] +
5354 lookup[(tmp >> 4) & 0x3F] +
5355 lookup[(tmp << 2) & 0x3F] +
5356 '='
5357 )
5358 }
5359
5360 return parts.join('')
5361}
5362
5363},{}],41:[function(require,module,exports){
5364(function (global,Buffer){(function (){
5365/*!
5366 * The buffer module from node.js, for the browser.
5367 *
5368 * @author Feross Aboukhadijeh <http://feross.org>
5369 * @license MIT
5370 */
5371/* eslint-disable no-proto */
5372
5373'use strict'
5374
5375var base64 = require('base64-js')
5376var ieee754 = require('ieee754')
5377var isArray = require('isarray')
5378
5379exports.Buffer = Buffer
5380exports.SlowBuffer = SlowBuffer
5381exports.INSPECT_MAX_BYTES = 50
5382
5383/**
5384 * If `Buffer.TYPED_ARRAY_SUPPORT`:
5385 * === true Use Uint8Array implementation (fastest)
5386 * === false Use Object implementation (most compatible, even IE6)
5387 *
5388 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
5389 * Opera 11.6+, iOS 4.2+.
5390 *
5391 * Due to various browser bugs, sometimes the Object implementation will be used even
5392 * when the browser supports typed arrays.
5393 *
5394 * Note:
5395 *
5396 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
5397 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
5398 *
5399 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
5400 *
5401 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
5402 * incorrect length in some situations.
5403
5404 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
5405 * get the Object implementation, which is slower but behaves correctly.
5406 */
5407Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
5408 ? global.TYPED_ARRAY_SUPPORT
5409 : typedArraySupport()
5410
5411/*
5412 * Export kMaxLength after typed array support is determined.
5413 */
5414exports.kMaxLength = kMaxLength()
5415
5416function typedArraySupport () {
5417 try {
5418 var arr = new Uint8Array(1)
5419 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
5420 return arr.foo() === 42 && // typed array instances can be augmented
5421 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
5422 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
5423 } catch (e) {
5424 return false
5425 }
5426}
5427
5428function kMaxLength () {
5429 return Buffer.TYPED_ARRAY_SUPPORT
5430 ? 0x7fffffff
5431 : 0x3fffffff
5432}
5433
5434function createBuffer (that, length) {
5435 if (kMaxLength() < length) {
5436 throw new RangeError('Invalid typed array length')
5437 }
5438 if (Buffer.TYPED_ARRAY_SUPPORT) {
5439 // Return an augmented `Uint8Array` instance, for best performance
5440 that = new Uint8Array(length)
5441 that.__proto__ = Buffer.prototype
5442 } else {
5443 // Fallback: Return an object instance of the Buffer class
5444 if (that === null) {
5445 that = new Buffer(length)
5446 }
5447 that.length = length
5448 }
5449
5450 return that
5451}
5452
5453/**
5454 * The Buffer constructor returns instances of `Uint8Array` that have their
5455 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
5456 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
5457 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
5458 * returns a single octet.
5459 *
5460 * The `Uint8Array` prototype remains unmodified.
5461 */
5462
5463function Buffer (arg, encodingOrOffset, length) {
5464 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
5465 return new Buffer(arg, encodingOrOffset, length)
5466 }
5467
5468 // Common case.
5469 if (typeof arg === 'number') {
5470 if (typeof encodingOrOffset === 'string') {
5471 throw new Error(
5472 'If encoding is specified then the first argument must be a string'
5473 )
5474 }
5475 return allocUnsafe(this, arg)
5476 }
5477 return from(this, arg, encodingOrOffset, length)
5478}
5479
5480Buffer.poolSize = 8192 // not used by this implementation
5481
5482// TODO: Legacy, not needed anymore. Remove in next major version.
5483Buffer._augment = function (arr) {
5484 arr.__proto__ = Buffer.prototype
5485 return arr
5486}
5487
5488function from (that, value, encodingOrOffset, length) {
5489 if (typeof value === 'number') {
5490 throw new TypeError('"value" argument must not be a number')
5491 }
5492
5493 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
5494 return fromArrayBuffer(that, value, encodingOrOffset, length)
5495 }
5496
5497 if (typeof value === 'string') {
5498 return fromString(that, value, encodingOrOffset)
5499 }
5500
5501 return fromObject(that, value)
5502}
5503
5504/**
5505 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
5506 * if value is a number.
5507 * Buffer.from(str[, encoding])
5508 * Buffer.from(array)
5509 * Buffer.from(buffer)
5510 * Buffer.from(arrayBuffer[, byteOffset[, length]])
5511 **/
5512Buffer.from = function (value, encodingOrOffset, length) {
5513 return from(null, value, encodingOrOffset, length)
5514}
5515
5516if (Buffer.TYPED_ARRAY_SUPPORT) {
5517 Buffer.prototype.__proto__ = Uint8Array.prototype
5518 Buffer.__proto__ = Uint8Array
5519 if (typeof Symbol !== 'undefined' && Symbol.species &&
5520 Buffer[Symbol.species] === Buffer) {
5521 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
5522 Object.defineProperty(Buffer, Symbol.species, {
5523 value: null,
5524 configurable: true
5525 })
5526 }
5527}
5528
5529function assertSize (size) {
5530 if (typeof size !== 'number') {
5531 throw new TypeError('"size" argument must be a number')
5532 } else if (size < 0) {
5533 throw new RangeError('"size" argument must not be negative')
5534 }
5535}
5536
5537function alloc (that, size, fill, encoding) {
5538 assertSize(size)
5539 if (size <= 0) {
5540 return createBuffer(that, size)
5541 }
5542 if (fill !== undefined) {
5543 // Only pay attention to encoding if it's a string. This
5544 // prevents accidentally sending in a number that would
5545 // be interpretted as a start offset.
5546 return typeof encoding === 'string'
5547 ? createBuffer(that, size).fill(fill, encoding)
5548 : createBuffer(that, size).fill(fill)
5549 }
5550 return createBuffer(that, size)
5551}
5552
5553/**
5554 * Creates a new filled Buffer instance.
5555 * alloc(size[, fill[, encoding]])
5556 **/
5557Buffer.alloc = function (size, fill, encoding) {
5558 return alloc(null, size, fill, encoding)
5559}
5560
5561function allocUnsafe (that, size) {
5562 assertSize(size)
5563 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
5564 if (!Buffer.TYPED_ARRAY_SUPPORT) {
5565 for (var i = 0; i < size; ++i) {
5566 that[i] = 0
5567 }
5568 }
5569 return that
5570}
5571
5572/**
5573 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
5574 * */
5575Buffer.allocUnsafe = function (size) {
5576 return allocUnsafe(null, size)
5577}
5578/**
5579 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
5580 */
5581Buffer.allocUnsafeSlow = function (size) {
5582 return allocUnsafe(null, size)
5583}
5584
5585function fromString (that, string, encoding) {
5586 if (typeof encoding !== 'string' || encoding === '') {
5587 encoding = 'utf8'
5588 }
5589
5590 if (!Buffer.isEncoding(encoding)) {
5591 throw new TypeError('"encoding" must be a valid string encoding')
5592 }
5593
5594 var length = byteLength(string, encoding) | 0
5595 that = createBuffer(that, length)
5596
5597 var actual = that.write(string, encoding)
5598
5599 if (actual !== length) {
5600 // Writing a hex string, for example, that contains invalid characters will
5601 // cause everything after the first invalid character to be ignored. (e.g.
5602 // 'abxxcd' will be treated as 'ab')
5603 that = that.slice(0, actual)
5604 }
5605
5606 return that
5607}
5608
5609function fromArrayLike (that, array) {
5610 var length = array.length < 0 ? 0 : checked(array.length) | 0
5611 that = createBuffer(that, length)
5612 for (var i = 0; i < length; i += 1) {
5613 that[i] = array[i] & 255
5614 }
5615 return that
5616}
5617
5618function fromArrayBuffer (that, array, byteOffset, length) {
5619 array.byteLength // this throws if `array` is not a valid ArrayBuffer
5620
5621 if (byteOffset < 0 || array.byteLength < byteOffset) {
5622 throw new RangeError('\'offset\' is out of bounds')
5623 }
5624
5625 if (array.byteLength < byteOffset + (length || 0)) {
5626 throw new RangeError('\'length\' is out of bounds')
5627 }
5628
5629 if (byteOffset === undefined && length === undefined) {
5630 array = new Uint8Array(array)
5631 } else if (length === undefined) {
5632 array = new Uint8Array(array, byteOffset)
5633 } else {
5634 array = new Uint8Array(array, byteOffset, length)
5635 }
5636
5637 if (Buffer.TYPED_ARRAY_SUPPORT) {
5638 // Return an augmented `Uint8Array` instance, for best performance
5639 that = array
5640 that.__proto__ = Buffer.prototype
5641 } else {
5642 // Fallback: Return an object instance of the Buffer class
5643 that = fromArrayLike(that, array)
5644 }
5645 return that
5646}
5647
5648function fromObject (that, obj) {
5649 if (Buffer.isBuffer(obj)) {
5650 var len = checked(obj.length) | 0
5651 that = createBuffer(that, len)
5652
5653 if (that.length === 0) {
5654 return that
5655 }
5656
5657 obj.copy(that, 0, 0, len)
5658 return that
5659 }
5660
5661 if (obj) {
5662 if ((typeof ArrayBuffer !== 'undefined' &&
5663 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
5664 if (typeof obj.length !== 'number' || isnan(obj.length)) {
5665 return createBuffer(that, 0)
5666 }
5667 return fromArrayLike(that, obj)
5668 }
5669
5670 if (obj.type === 'Buffer' && isArray(obj.data)) {
5671 return fromArrayLike(that, obj.data)
5672 }
5673 }
5674
5675 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
5676}
5677
5678function checked (length) {
5679 // Note: cannot use `length < kMaxLength()` here because that fails when
5680 // length is NaN (which is otherwise coerced to zero.)
5681 if (length >= kMaxLength()) {
5682 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
5683 'size: 0x' + kMaxLength().toString(16) + ' bytes')
5684 }
5685 return length | 0
5686}
5687
5688function SlowBuffer (length) {
5689 if (+length != length) { // eslint-disable-line eqeqeq
5690 length = 0
5691 }
5692 return Buffer.alloc(+length)
5693}
5694
5695Buffer.isBuffer = function isBuffer (b) {
5696 return !!(b != null && b._isBuffer)
5697}
5698
5699Buffer.compare = function compare (a, b) {
5700 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
5701 throw new TypeError('Arguments must be Buffers')
5702 }
5703
5704 if (a === b) return 0
5705
5706 var x = a.length
5707 var y = b.length
5708
5709 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
5710 if (a[i] !== b[i]) {
5711 x = a[i]
5712 y = b[i]
5713 break
5714 }
5715 }
5716
5717 if (x < y) return -1
5718 if (y < x) return 1
5719 return 0
5720}
5721
5722Buffer.isEncoding = function isEncoding (encoding) {
5723 switch (String(encoding).toLowerCase()) {
5724 case 'hex':
5725 case 'utf8':
5726 case 'utf-8':
5727 case 'ascii':
5728 case 'latin1':
5729 case 'binary':
5730 case 'base64':
5731 case 'ucs2':
5732 case 'ucs-2':
5733 case 'utf16le':
5734 case 'utf-16le':
5735 return true
5736 default:
5737 return false
5738 }
5739}
5740
5741Buffer.concat = function concat (list, length) {
5742 if (!isArray(list)) {
5743 throw new TypeError('"list" argument must be an Array of Buffers')
5744 }
5745
5746 if (list.length === 0) {
5747 return Buffer.alloc(0)
5748 }
5749
5750 var i
5751 if (length === undefined) {
5752 length = 0
5753 for (i = 0; i < list.length; ++i) {
5754 length += list[i].length
5755 }
5756 }
5757
5758 var buffer = Buffer.allocUnsafe(length)
5759 var pos = 0
5760 for (i = 0; i < list.length; ++i) {
5761 var buf = list[i]
5762 if (!Buffer.isBuffer(buf)) {
5763 throw new TypeError('"list" argument must be an Array of Buffers')
5764 }
5765 buf.copy(buffer, pos)
5766 pos += buf.length
5767 }
5768 return buffer
5769}
5770
5771function byteLength (string, encoding) {
5772 if (Buffer.isBuffer(string)) {
5773 return string.length
5774 }
5775 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
5776 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
5777 return string.byteLength
5778 }
5779 if (typeof string !== 'string') {
5780 string = '' + string
5781 }
5782
5783 var len = string.length
5784 if (len === 0) return 0
5785
5786 // Use a for loop to avoid recursion
5787 var loweredCase = false
5788 for (;;) {
5789 switch (encoding) {
5790 case 'ascii':
5791 case 'latin1':
5792 case 'binary':
5793 return len
5794 case 'utf8':
5795 case 'utf-8':
5796 case undefined:
5797 return utf8ToBytes(string).length
5798 case 'ucs2':
5799 case 'ucs-2':
5800 case 'utf16le':
5801 case 'utf-16le':
5802 return len * 2
5803 case 'hex':
5804 return len >>> 1
5805 case 'base64':
5806 return base64ToBytes(string).length
5807 default:
5808 if (loweredCase) return utf8ToBytes(string).length // assume utf8
5809 encoding = ('' + encoding).toLowerCase()
5810 loweredCase = true
5811 }
5812 }
5813}
5814Buffer.byteLength = byteLength
5815
5816function slowToString (encoding, start, end) {
5817 var loweredCase = false
5818
5819 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
5820 // property of a typed array.
5821
5822 // This behaves neither like String nor Uint8Array in that we set start/end
5823 // to their upper/lower bounds if the value passed is out of range.
5824 // undefined is handled specially as per ECMA-262 6th Edition,
5825 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
5826 if (start === undefined || start < 0) {
5827 start = 0
5828 }
5829 // Return early if start > this.length. Done here to prevent potential uint32
5830 // coercion fail below.
5831 if (start > this.length) {
5832 return ''
5833 }
5834
5835 if (end === undefined || end > this.length) {
5836 end = this.length
5837 }
5838
5839 if (end <= 0) {
5840 return ''
5841 }
5842
5843 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
5844 end >>>= 0
5845 start >>>= 0
5846
5847 if (end <= start) {
5848 return ''
5849 }
5850
5851 if (!encoding) encoding = 'utf8'
5852
5853 while (true) {
5854 switch (encoding) {
5855 case 'hex':
5856 return hexSlice(this, start, end)
5857
5858 case 'utf8':
5859 case 'utf-8':
5860 return utf8Slice(this, start, end)
5861
5862 case 'ascii':
5863 return asciiSlice(this, start, end)
5864
5865 case 'latin1':
5866 case 'binary':
5867 return latin1Slice(this, start, end)
5868
5869 case 'base64':
5870 return base64Slice(this, start, end)
5871
5872 case 'ucs2':
5873 case 'ucs-2':
5874 case 'utf16le':
5875 case 'utf-16le':
5876 return utf16leSlice(this, start, end)
5877
5878 default:
5879 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
5880 encoding = (encoding + '').toLowerCase()
5881 loweredCase = true
5882 }
5883 }
5884}
5885
5886// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
5887// Buffer instances.
5888Buffer.prototype._isBuffer = true
5889
5890function swap (b, n, m) {
5891 var i = b[n]
5892 b[n] = b[m]
5893 b[m] = i
5894}
5895
5896Buffer.prototype.swap16 = function swap16 () {
5897 var len = this.length
5898 if (len % 2 !== 0) {
5899 throw new RangeError('Buffer size must be a multiple of 16-bits')
5900 }
5901 for (var i = 0; i < len; i += 2) {
5902 swap(this, i, i + 1)
5903 }
5904 return this
5905}
5906
5907Buffer.prototype.swap32 = function swap32 () {
5908 var len = this.length
5909 if (len % 4 !== 0) {
5910 throw new RangeError('Buffer size must be a multiple of 32-bits')
5911 }
5912 for (var i = 0; i < len; i += 4) {
5913 swap(this, i, i + 3)
5914 swap(this, i + 1, i + 2)
5915 }
5916 return this
5917}
5918
5919Buffer.prototype.swap64 = function swap64 () {
5920 var len = this.length
5921 if (len % 8 !== 0) {
5922 throw new RangeError('Buffer size must be a multiple of 64-bits')
5923 }
5924 for (var i = 0; i < len; i += 8) {
5925 swap(this, i, i + 7)
5926 swap(this, i + 1, i + 6)
5927 swap(this, i + 2, i + 5)
5928 swap(this, i + 3, i + 4)
5929 }
5930 return this
5931}
5932
5933Buffer.prototype.toString = function toString () {
5934 var length = this.length | 0
5935 if (length === 0) return ''
5936 if (arguments.length === 0) return utf8Slice(this, 0, length)
5937 return slowToString.apply(this, arguments)
5938}
5939
5940Buffer.prototype.equals = function equals (b) {
5941 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
5942 if (this === b) return true
5943 return Buffer.compare(this, b) === 0
5944}
5945
5946Buffer.prototype.inspect = function inspect () {
5947 var str = ''
5948 var max = exports.INSPECT_MAX_BYTES
5949 if (this.length > 0) {
5950 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
5951 if (this.length > max) str += ' ... '
5952 }
5953 return '<Buffer ' + str + '>'
5954}
5955
5956Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
5957 if (!Buffer.isBuffer(target)) {
5958 throw new TypeError('Argument must be a Buffer')
5959 }
5960
5961 if (start === undefined) {
5962 start = 0
5963 }
5964 if (end === undefined) {
5965 end = target ? target.length : 0
5966 }
5967 if (thisStart === undefined) {
5968 thisStart = 0
5969 }
5970 if (thisEnd === undefined) {
5971 thisEnd = this.length
5972 }
5973
5974 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
5975 throw new RangeError('out of range index')
5976 }
5977
5978 if (thisStart >= thisEnd && start >= end) {
5979 return 0
5980 }
5981 if (thisStart >= thisEnd) {
5982 return -1
5983 }
5984 if (start >= end) {
5985 return 1
5986 }
5987
5988 start >>>= 0
5989 end >>>= 0
5990 thisStart >>>= 0
5991 thisEnd >>>= 0
5992
5993 if (this === target) return 0
5994
5995 var x = thisEnd - thisStart
5996 var y = end - start
5997 var len = Math.min(x, y)
5998
5999 var thisCopy = this.slice(thisStart, thisEnd)
6000 var targetCopy = target.slice(start, end)
6001
6002 for (var i = 0; i < len; ++i) {
6003 if (thisCopy[i] !== targetCopy[i]) {
6004 x = thisCopy[i]
6005 y = targetCopy[i]
6006 break
6007 }
6008 }
6009
6010 if (x < y) return -1
6011 if (y < x) return 1
6012 return 0
6013}
6014
6015// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
6016// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
6017//
6018// Arguments:
6019// - buffer - a Buffer to search
6020// - val - a string, Buffer, or number
6021// - byteOffset - an index into `buffer`; will be clamped to an int32
6022// - encoding - an optional encoding, relevant is val is a string
6023// - dir - true for indexOf, false for lastIndexOf
6024function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
6025 // Empty buffer means no match
6026 if (buffer.length === 0) return -1
6027
6028 // Normalize byteOffset
6029 if (typeof byteOffset === 'string') {
6030 encoding = byteOffset
6031 byteOffset = 0
6032 } else if (byteOffset > 0x7fffffff) {
6033 byteOffset = 0x7fffffff
6034 } else if (byteOffset < -0x80000000) {
6035 byteOffset = -0x80000000
6036 }
6037 byteOffset = +byteOffset // Coerce to Number.
6038 if (isNaN(byteOffset)) {
6039 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
6040 byteOffset = dir ? 0 : (buffer.length - 1)
6041 }
6042
6043 // Normalize byteOffset: negative offsets start from the end of the buffer
6044 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
6045 if (byteOffset >= buffer.length) {
6046 if (dir) return -1
6047 else byteOffset = buffer.length - 1
6048 } else if (byteOffset < 0) {
6049 if (dir) byteOffset = 0
6050 else return -1
6051 }
6052
6053 // Normalize val
6054 if (typeof val === 'string') {
6055 val = Buffer.from(val, encoding)
6056 }
6057
6058 // Finally, search either indexOf (if dir is true) or lastIndexOf
6059 if (Buffer.isBuffer(val)) {
6060 // Special case: looking for empty string/buffer always fails
6061 if (val.length === 0) {
6062 return -1
6063 }
6064 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
6065 } else if (typeof val === 'number') {
6066 val = val & 0xFF // Search for a byte value [0-255]
6067 if (Buffer.TYPED_ARRAY_SUPPORT &&
6068 typeof Uint8Array.prototype.indexOf === 'function') {
6069 if (dir) {
6070 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
6071 } else {
6072 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
6073 }
6074 }
6075 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
6076 }
6077
6078 throw new TypeError('val must be string, number or Buffer')
6079}
6080
6081function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
6082 var indexSize = 1
6083 var arrLength = arr.length
6084 var valLength = val.length
6085
6086 if (encoding !== undefined) {
6087 encoding = String(encoding).toLowerCase()
6088 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
6089 encoding === 'utf16le' || encoding === 'utf-16le') {
6090 if (arr.length < 2 || val.length < 2) {
6091 return -1
6092 }
6093 indexSize = 2
6094 arrLength /= 2
6095 valLength /= 2
6096 byteOffset /= 2
6097 }
6098 }
6099
6100 function read (buf, i) {
6101 if (indexSize === 1) {
6102 return buf[i]
6103 } else {
6104 return buf.readUInt16BE(i * indexSize)
6105 }
6106 }
6107
6108 var i
6109 if (dir) {
6110 var foundIndex = -1
6111 for (i = byteOffset; i < arrLength; i++) {
6112 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
6113 if (foundIndex === -1) foundIndex = i
6114 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
6115 } else {
6116 if (foundIndex !== -1) i -= i - foundIndex
6117 foundIndex = -1
6118 }
6119 }
6120 } else {
6121 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
6122 for (i = byteOffset; i >= 0; i--) {
6123 var found = true
6124 for (var j = 0; j < valLength; j++) {
6125 if (read(arr, i + j) !== read(val, j)) {
6126 found = false
6127 break
6128 }
6129 }
6130 if (found) return i
6131 }
6132 }
6133
6134 return -1
6135}
6136
6137Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
6138 return this.indexOf(val, byteOffset, encoding) !== -1
6139}
6140
6141Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
6142 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
6143}
6144
6145Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
6146 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
6147}
6148
6149function hexWrite (buf, string, offset, length) {
6150 offset = Number(offset) || 0
6151 var remaining = buf.length - offset
6152 if (!length) {
6153 length = remaining
6154 } else {
6155 length = Number(length)
6156 if (length > remaining) {
6157 length = remaining
6158 }
6159 }
6160
6161 // must be an even number of digits
6162 var strLen = string.length
6163 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
6164
6165 if (length > strLen / 2) {
6166 length = strLen / 2
6167 }
6168 for (var i = 0; i < length; ++i) {
6169 var parsed = parseInt(string.substr(i * 2, 2), 16)
6170 if (isNaN(parsed)) return i
6171 buf[offset + i] = parsed
6172 }
6173 return i
6174}
6175
6176function utf8Write (buf, string, offset, length) {
6177 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
6178}
6179
6180function asciiWrite (buf, string, offset, length) {
6181 return blitBuffer(asciiToBytes(string), buf, offset, length)
6182}
6183
6184function latin1Write (buf, string, offset, length) {
6185 return asciiWrite(buf, string, offset, length)
6186}
6187
6188function base64Write (buf, string, offset, length) {
6189 return blitBuffer(base64ToBytes(string), buf, offset, length)
6190}
6191
6192function ucs2Write (buf, string, offset, length) {
6193 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
6194}
6195
6196Buffer.prototype.write = function write (string, offset, length, encoding) {
6197 // Buffer#write(string)
6198 if (offset === undefined) {
6199 encoding = 'utf8'
6200 length = this.length
6201 offset = 0
6202 // Buffer#write(string, encoding)
6203 } else if (length === undefined && typeof offset === 'string') {
6204 encoding = offset
6205 length = this.length
6206 offset = 0
6207 // Buffer#write(string, offset[, length][, encoding])
6208 } else if (isFinite(offset)) {
6209 offset = offset | 0
6210 if (isFinite(length)) {
6211 length = length | 0
6212 if (encoding === undefined) encoding = 'utf8'
6213 } else {
6214 encoding = length
6215 length = undefined
6216 }
6217 // legacy write(string, encoding, offset, length) - remove in v0.13
6218 } else {
6219 throw new Error(
6220 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
6221 )
6222 }
6223
6224 var remaining = this.length - offset
6225 if (length === undefined || length > remaining) length = remaining
6226
6227 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
6228 throw new RangeError('Attempt to write outside buffer bounds')
6229 }
6230
6231 if (!encoding) encoding = 'utf8'
6232
6233 var loweredCase = false
6234 for (;;) {
6235 switch (encoding) {
6236 case 'hex':
6237 return hexWrite(this, string, offset, length)
6238
6239 case 'utf8':
6240 case 'utf-8':
6241 return utf8Write(this, string, offset, length)
6242
6243 case 'ascii':
6244 return asciiWrite(this, string, offset, length)
6245
6246 case 'latin1':
6247 case 'binary':
6248 return latin1Write(this, string, offset, length)
6249
6250 case 'base64':
6251 // Warning: maxLength not taken into account in base64Write
6252 return base64Write(this, string, offset, length)
6253
6254 case 'ucs2':
6255 case 'ucs-2':
6256 case 'utf16le':
6257 case 'utf-16le':
6258 return ucs2Write(this, string, offset, length)
6259
6260 default:
6261 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
6262 encoding = ('' + encoding).toLowerCase()
6263 loweredCase = true
6264 }
6265 }
6266}
6267
6268Buffer.prototype.toJSON = function toJSON () {
6269 return {
6270 type: 'Buffer',
6271 data: Array.prototype.slice.call(this._arr || this, 0)
6272 }
6273}
6274
6275function base64Slice (buf, start, end) {
6276 if (start === 0 && end === buf.length) {
6277 return base64.fromByteArray(buf)
6278 } else {
6279 return base64.fromByteArray(buf.slice(start, end))
6280 }
6281}
6282
6283function utf8Slice (buf, start, end) {
6284 end = Math.min(buf.length, end)
6285 var res = []
6286
6287 var i = start
6288 while (i < end) {
6289 var firstByte = buf[i]
6290 var codePoint = null
6291 var bytesPerSequence = (firstByte > 0xEF) ? 4
6292 : (firstByte > 0xDF) ? 3
6293 : (firstByte > 0xBF) ? 2
6294 : 1
6295
6296 if (i + bytesPerSequence <= end) {
6297 var secondByte, thirdByte, fourthByte, tempCodePoint
6298
6299 switch (bytesPerSequence) {
6300 case 1:
6301 if (firstByte < 0x80) {
6302 codePoint = firstByte
6303 }
6304 break
6305 case 2:
6306 secondByte = buf[i + 1]
6307 if ((secondByte & 0xC0) === 0x80) {
6308 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
6309 if (tempCodePoint > 0x7F) {
6310 codePoint = tempCodePoint
6311 }
6312 }
6313 break
6314 case 3:
6315 secondByte = buf[i + 1]
6316 thirdByte = buf[i + 2]
6317 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
6318 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
6319 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
6320 codePoint = tempCodePoint
6321 }
6322 }
6323 break
6324 case 4:
6325 secondByte = buf[i + 1]
6326 thirdByte = buf[i + 2]
6327 fourthByte = buf[i + 3]
6328 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
6329 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
6330 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
6331 codePoint = tempCodePoint
6332 }
6333 }
6334 }
6335 }
6336
6337 if (codePoint === null) {
6338 // we did not generate a valid codePoint so insert a
6339 // replacement char (U+FFFD) and advance only 1 byte
6340 codePoint = 0xFFFD
6341 bytesPerSequence = 1
6342 } else if (codePoint > 0xFFFF) {
6343 // encode to utf16 (surrogate pair dance)
6344 codePoint -= 0x10000
6345 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
6346 codePoint = 0xDC00 | codePoint & 0x3FF
6347 }
6348
6349 res.push(codePoint)
6350 i += bytesPerSequence
6351 }
6352
6353 return decodeCodePointsArray(res)
6354}
6355
6356// Based on http://stackoverflow.com/a/22747272/680742, the browser with
6357// the lowest limit is Chrome, with 0x10000 args.
6358// We go 1 magnitude less, for safety
6359var MAX_ARGUMENTS_LENGTH = 0x1000
6360
6361function decodeCodePointsArray (codePoints) {
6362 var len = codePoints.length
6363 if (len <= MAX_ARGUMENTS_LENGTH) {
6364 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
6365 }
6366
6367 // Decode in chunks to avoid "call stack size exceeded".
6368 var res = ''
6369 var i = 0
6370 while (i < len) {
6371 res += String.fromCharCode.apply(
6372 String,
6373 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
6374 )
6375 }
6376 return res
6377}
6378
6379function asciiSlice (buf, start, end) {
6380 var ret = ''
6381 end = Math.min(buf.length, end)
6382
6383 for (var i = start; i < end; ++i) {
6384 ret += String.fromCharCode(buf[i] & 0x7F)
6385 }
6386 return ret
6387}
6388
6389function latin1Slice (buf, start, end) {
6390 var ret = ''
6391 end = Math.min(buf.length, end)
6392
6393 for (var i = start; i < end; ++i) {
6394 ret += String.fromCharCode(buf[i])
6395 }
6396 return ret
6397}
6398
6399function hexSlice (buf, start, end) {
6400 var len = buf.length
6401
6402 if (!start || start < 0) start = 0
6403 if (!end || end < 0 || end > len) end = len
6404
6405 var out = ''
6406 for (var i = start; i < end; ++i) {
6407 out += toHex(buf[i])
6408 }
6409 return out
6410}
6411
6412function utf16leSlice (buf, start, end) {
6413 var bytes = buf.slice(start, end)
6414 var res = ''
6415 for (var i = 0; i < bytes.length; i += 2) {
6416 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
6417 }
6418 return res
6419}
6420
6421Buffer.prototype.slice = function slice (start, end) {
6422 var len = this.length
6423 start = ~~start
6424 end = end === undefined ? len : ~~end
6425
6426 if (start < 0) {
6427 start += len
6428 if (start < 0) start = 0
6429 } else if (start > len) {
6430 start = len
6431 }
6432
6433 if (end < 0) {
6434 end += len
6435 if (end < 0) end = 0
6436 } else if (end > len) {
6437 end = len
6438 }
6439
6440 if (end < start) end = start
6441
6442 var newBuf
6443 if (Buffer.TYPED_ARRAY_SUPPORT) {
6444 newBuf = this.subarray(start, end)
6445 newBuf.__proto__ = Buffer.prototype
6446 } else {
6447 var sliceLen = end - start
6448 newBuf = new Buffer(sliceLen, undefined)
6449 for (var i = 0; i < sliceLen; ++i) {
6450 newBuf[i] = this[i + start]
6451 }
6452 }
6453
6454 return newBuf
6455}
6456
6457/*
6458 * Need to make sure that buffer isn't trying to write out of bounds.
6459 */
6460function checkOffset (offset, ext, length) {
6461 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
6462 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
6463}
6464
6465Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
6466 offset = offset | 0
6467 byteLength = byteLength | 0
6468 if (!noAssert) checkOffset(offset, byteLength, this.length)
6469
6470 var val = this[offset]
6471 var mul = 1
6472 var i = 0
6473 while (++i < byteLength && (mul *= 0x100)) {
6474 val += this[offset + i] * mul
6475 }
6476
6477 return val
6478}
6479
6480Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
6481 offset = offset | 0
6482 byteLength = byteLength | 0
6483 if (!noAssert) {
6484 checkOffset(offset, byteLength, this.length)
6485 }
6486
6487 var val = this[offset + --byteLength]
6488 var mul = 1
6489 while (byteLength > 0 && (mul *= 0x100)) {
6490 val += this[offset + --byteLength] * mul
6491 }
6492
6493 return val
6494}
6495
6496Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
6497 if (!noAssert) checkOffset(offset, 1, this.length)
6498 return this[offset]
6499}
6500
6501Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
6502 if (!noAssert) checkOffset(offset, 2, this.length)
6503 return this[offset] | (this[offset + 1] << 8)
6504}
6505
6506Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
6507 if (!noAssert) checkOffset(offset, 2, this.length)
6508 return (this[offset] << 8) | this[offset + 1]
6509}
6510
6511Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
6512 if (!noAssert) checkOffset(offset, 4, this.length)
6513
6514 return ((this[offset]) |
6515 (this[offset + 1] << 8) |
6516 (this[offset + 2] << 16)) +
6517 (this[offset + 3] * 0x1000000)
6518}
6519
6520Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
6521 if (!noAssert) checkOffset(offset, 4, this.length)
6522
6523 return (this[offset] * 0x1000000) +
6524 ((this[offset + 1] << 16) |
6525 (this[offset + 2] << 8) |
6526 this[offset + 3])
6527}
6528
6529Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
6530 offset = offset | 0
6531 byteLength = byteLength | 0
6532 if (!noAssert) checkOffset(offset, byteLength, this.length)
6533
6534 var val = this[offset]
6535 var mul = 1
6536 var i = 0
6537 while (++i < byteLength && (mul *= 0x100)) {
6538 val += this[offset + i] * mul
6539 }
6540 mul *= 0x80
6541
6542 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6543
6544 return val
6545}
6546
6547Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
6548 offset = offset | 0
6549 byteLength = byteLength | 0
6550 if (!noAssert) checkOffset(offset, byteLength, this.length)
6551
6552 var i = byteLength
6553 var mul = 1
6554 var val = this[offset + --i]
6555 while (i > 0 && (mul *= 0x100)) {
6556 val += this[offset + --i] * mul
6557 }
6558 mul *= 0x80
6559
6560 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6561
6562 return val
6563}
6564
6565Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
6566 if (!noAssert) checkOffset(offset, 1, this.length)
6567 if (!(this[offset] & 0x80)) return (this[offset])
6568 return ((0xff - this[offset] + 1) * -1)
6569}
6570
6571Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
6572 if (!noAssert) checkOffset(offset, 2, this.length)
6573 var val = this[offset] | (this[offset + 1] << 8)
6574 return (val & 0x8000) ? val | 0xFFFF0000 : val
6575}
6576
6577Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
6578 if (!noAssert) checkOffset(offset, 2, this.length)
6579 var val = this[offset + 1] | (this[offset] << 8)
6580 return (val & 0x8000) ? val | 0xFFFF0000 : val
6581}
6582
6583Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
6584 if (!noAssert) checkOffset(offset, 4, this.length)
6585
6586 return (this[offset]) |
6587 (this[offset + 1] << 8) |
6588 (this[offset + 2] << 16) |
6589 (this[offset + 3] << 24)
6590}
6591
6592Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
6593 if (!noAssert) checkOffset(offset, 4, this.length)
6594
6595 return (this[offset] << 24) |
6596 (this[offset + 1] << 16) |
6597 (this[offset + 2] << 8) |
6598 (this[offset + 3])
6599}
6600
6601Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
6602 if (!noAssert) checkOffset(offset, 4, this.length)
6603 return ieee754.read(this, offset, true, 23, 4)
6604}
6605
6606Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
6607 if (!noAssert) checkOffset(offset, 4, this.length)
6608 return ieee754.read(this, offset, false, 23, 4)
6609}
6610
6611Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
6612 if (!noAssert) checkOffset(offset, 8, this.length)
6613 return ieee754.read(this, offset, true, 52, 8)
6614}
6615
6616Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
6617 if (!noAssert) checkOffset(offset, 8, this.length)
6618 return ieee754.read(this, offset, false, 52, 8)
6619}
6620
6621function checkInt (buf, value, offset, ext, max, min) {
6622 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
6623 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
6624 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6625}
6626
6627Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
6628 value = +value
6629 offset = offset | 0
6630 byteLength = byteLength | 0
6631 if (!noAssert) {
6632 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6633 checkInt(this, value, offset, byteLength, maxBytes, 0)
6634 }
6635
6636 var mul = 1
6637 var i = 0
6638 this[offset] = value & 0xFF
6639 while (++i < byteLength && (mul *= 0x100)) {
6640 this[offset + i] = (value / mul) & 0xFF
6641 }
6642
6643 return offset + byteLength
6644}
6645
6646Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
6647 value = +value
6648 offset = offset | 0
6649 byteLength = byteLength | 0
6650 if (!noAssert) {
6651 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6652 checkInt(this, value, offset, byteLength, maxBytes, 0)
6653 }
6654
6655 var i = byteLength - 1
6656 var mul = 1
6657 this[offset + i] = value & 0xFF
6658 while (--i >= 0 && (mul *= 0x100)) {
6659 this[offset + i] = (value / mul) & 0xFF
6660 }
6661
6662 return offset + byteLength
6663}
6664
6665Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
6666 value = +value
6667 offset = offset | 0
6668 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
6669 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6670 this[offset] = (value & 0xff)
6671 return offset + 1
6672}
6673
6674function objectWriteUInt16 (buf, value, offset, littleEndian) {
6675 if (value < 0) value = 0xffff + value + 1
6676 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
6677 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
6678 (littleEndian ? i : 1 - i) * 8
6679 }
6680}
6681
6682Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
6683 value = +value
6684 offset = offset | 0
6685 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6686 if (Buffer.TYPED_ARRAY_SUPPORT) {
6687 this[offset] = (value & 0xff)
6688 this[offset + 1] = (value >>> 8)
6689 } else {
6690 objectWriteUInt16(this, value, offset, true)
6691 }
6692 return offset + 2
6693}
6694
6695Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
6696 value = +value
6697 offset = offset | 0
6698 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6699 if (Buffer.TYPED_ARRAY_SUPPORT) {
6700 this[offset] = (value >>> 8)
6701 this[offset + 1] = (value & 0xff)
6702 } else {
6703 objectWriteUInt16(this, value, offset, false)
6704 }
6705 return offset + 2
6706}
6707
6708function objectWriteUInt32 (buf, value, offset, littleEndian) {
6709 if (value < 0) value = 0xffffffff + value + 1
6710 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
6711 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
6712 }
6713}
6714
6715Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
6716 value = +value
6717 offset = offset | 0
6718 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6719 if (Buffer.TYPED_ARRAY_SUPPORT) {
6720 this[offset + 3] = (value >>> 24)
6721 this[offset + 2] = (value >>> 16)
6722 this[offset + 1] = (value >>> 8)
6723 this[offset] = (value & 0xff)
6724 } else {
6725 objectWriteUInt32(this, value, offset, true)
6726 }
6727 return offset + 4
6728}
6729
6730Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
6731 value = +value
6732 offset = offset | 0
6733 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6734 if (Buffer.TYPED_ARRAY_SUPPORT) {
6735 this[offset] = (value >>> 24)
6736 this[offset + 1] = (value >>> 16)
6737 this[offset + 2] = (value >>> 8)
6738 this[offset + 3] = (value & 0xff)
6739 } else {
6740 objectWriteUInt32(this, value, offset, false)
6741 }
6742 return offset + 4
6743}
6744
6745Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
6746 value = +value
6747 offset = offset | 0
6748 if (!noAssert) {
6749 var limit = Math.pow(2, 8 * byteLength - 1)
6750
6751 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6752 }
6753
6754 var i = 0
6755 var mul = 1
6756 var sub = 0
6757 this[offset] = value & 0xFF
6758 while (++i < byteLength && (mul *= 0x100)) {
6759 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
6760 sub = 1
6761 }
6762 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6763 }
6764
6765 return offset + byteLength
6766}
6767
6768Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
6769 value = +value
6770 offset = offset | 0
6771 if (!noAssert) {
6772 var limit = Math.pow(2, 8 * byteLength - 1)
6773
6774 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6775 }
6776
6777 var i = byteLength - 1
6778 var mul = 1
6779 var sub = 0
6780 this[offset + i] = value & 0xFF
6781 while (--i >= 0 && (mul *= 0x100)) {
6782 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
6783 sub = 1
6784 }
6785 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6786 }
6787
6788 return offset + byteLength
6789}
6790
6791Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
6792 value = +value
6793 offset = offset | 0
6794 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
6795 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6796 if (value < 0) value = 0xff + value + 1
6797 this[offset] = (value & 0xff)
6798 return offset + 1
6799}
6800
6801Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
6802 value = +value
6803 offset = offset | 0
6804 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6805 if (Buffer.TYPED_ARRAY_SUPPORT) {
6806 this[offset] = (value & 0xff)
6807 this[offset + 1] = (value >>> 8)
6808 } else {
6809 objectWriteUInt16(this, value, offset, true)
6810 }
6811 return offset + 2
6812}
6813
6814Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
6815 value = +value
6816 offset = offset | 0
6817 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6818 if (Buffer.TYPED_ARRAY_SUPPORT) {
6819 this[offset] = (value >>> 8)
6820 this[offset + 1] = (value & 0xff)
6821 } else {
6822 objectWriteUInt16(this, value, offset, false)
6823 }
6824 return offset + 2
6825}
6826
6827Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
6828 value = +value
6829 offset = offset | 0
6830 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
6831 if (Buffer.TYPED_ARRAY_SUPPORT) {
6832 this[offset] = (value & 0xff)
6833 this[offset + 1] = (value >>> 8)
6834 this[offset + 2] = (value >>> 16)
6835 this[offset + 3] = (value >>> 24)
6836 } else {
6837 objectWriteUInt32(this, value, offset, true)
6838 }
6839 return offset + 4
6840}
6841
6842Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
6843 value = +value
6844 offset = offset | 0
6845 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
6846 if (value < 0) value = 0xffffffff + value + 1
6847 if (Buffer.TYPED_ARRAY_SUPPORT) {
6848 this[offset] = (value >>> 24)
6849 this[offset + 1] = (value >>> 16)
6850 this[offset + 2] = (value >>> 8)
6851 this[offset + 3] = (value & 0xff)
6852 } else {
6853 objectWriteUInt32(this, value, offset, false)
6854 }
6855 return offset + 4
6856}
6857
6858function checkIEEE754 (buf, value, offset, ext, max, min) {
6859 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6860 if (offset < 0) throw new RangeError('Index out of range')
6861}
6862
6863function writeFloat (buf, value, offset, littleEndian, noAssert) {
6864 if (!noAssert) {
6865 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
6866 }
6867 ieee754.write(buf, value, offset, littleEndian, 23, 4)
6868 return offset + 4
6869}
6870
6871Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
6872 return writeFloat(this, value, offset, true, noAssert)
6873}
6874
6875Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
6876 return writeFloat(this, value, offset, false, noAssert)
6877}
6878
6879function writeDouble (buf, value, offset, littleEndian, noAssert) {
6880 if (!noAssert) {
6881 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
6882 }
6883 ieee754.write(buf, value, offset, littleEndian, 52, 8)
6884 return offset + 8
6885}
6886
6887Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
6888 return writeDouble(this, value, offset, true, noAssert)
6889}
6890
6891Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
6892 return writeDouble(this, value, offset, false, noAssert)
6893}
6894
6895// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
6896Buffer.prototype.copy = function copy (target, targetStart, start, end) {
6897 if (!start) start = 0
6898 if (!end && end !== 0) end = this.length
6899 if (targetStart >= target.length) targetStart = target.length
6900 if (!targetStart) targetStart = 0
6901 if (end > 0 && end < start) end = start
6902
6903 // Copy 0 bytes; we're done
6904 if (end === start) return 0
6905 if (target.length === 0 || this.length === 0) return 0
6906
6907 // Fatal error conditions
6908 if (targetStart < 0) {
6909 throw new RangeError('targetStart out of bounds')
6910 }
6911 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
6912 if (end < 0) throw new RangeError('sourceEnd out of bounds')
6913
6914 // Are we oob?
6915 if (end > this.length) end = this.length
6916 if (target.length - targetStart < end - start) {
6917 end = target.length - targetStart + start
6918 }
6919
6920 var len = end - start
6921 var i
6922
6923 if (this === target && start < targetStart && targetStart < end) {
6924 // descending copy from end
6925 for (i = len - 1; i >= 0; --i) {
6926 target[i + targetStart] = this[i + start]
6927 }
6928 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
6929 // ascending copy from start
6930 for (i = 0; i < len; ++i) {
6931 target[i + targetStart] = this[i + start]
6932 }
6933 } else {
6934 Uint8Array.prototype.set.call(
6935 target,
6936 this.subarray(start, start + len),
6937 targetStart
6938 )
6939 }
6940
6941 return len
6942}
6943
6944// Usage:
6945// buffer.fill(number[, offset[, end]])
6946// buffer.fill(buffer[, offset[, end]])
6947// buffer.fill(string[, offset[, end]][, encoding])
6948Buffer.prototype.fill = function fill (val, start, end, encoding) {
6949 // Handle string cases:
6950 if (typeof val === 'string') {
6951 if (typeof start === 'string') {
6952 encoding = start
6953 start = 0
6954 end = this.length
6955 } else if (typeof end === 'string') {
6956 encoding = end
6957 end = this.length
6958 }
6959 if (val.length === 1) {
6960 var code = val.charCodeAt(0)
6961 if (code < 256) {
6962 val = code
6963 }
6964 }
6965 if (encoding !== undefined && typeof encoding !== 'string') {
6966 throw new TypeError('encoding must be a string')
6967 }
6968 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
6969 throw new TypeError('Unknown encoding: ' + encoding)
6970 }
6971 } else if (typeof val === 'number') {
6972 val = val & 255
6973 }
6974
6975 // Invalid ranges are not set to a default, so can range check early.
6976 if (start < 0 || this.length < start || this.length < end) {
6977 throw new RangeError('Out of range index')
6978 }
6979
6980 if (end <= start) {
6981 return this
6982 }
6983
6984 start = start >>> 0
6985 end = end === undefined ? this.length : end >>> 0
6986
6987 if (!val) val = 0
6988
6989 var i
6990 if (typeof val === 'number') {
6991 for (i = start; i < end; ++i) {
6992 this[i] = val
6993 }
6994 } else {
6995 var bytes = Buffer.isBuffer(val)
6996 ? val
6997 : utf8ToBytes(new Buffer(val, encoding).toString())
6998 var len = bytes.length
6999 for (i = 0; i < end - start; ++i) {
7000 this[i + start] = bytes[i % len]
7001 }
7002 }
7003
7004 return this
7005}
7006
7007// HELPER FUNCTIONS
7008// ================
7009
7010var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
7011
7012function base64clean (str) {
7013 // Node strips out invalid characters like \n and \t from the string, base64-js does not
7014 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
7015 // Node converts strings with length < 2 to ''
7016 if (str.length < 2) return ''
7017 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
7018 while (str.length % 4 !== 0) {
7019 str = str + '='
7020 }
7021 return str
7022}
7023
7024function stringtrim (str) {
7025 if (str.trim) return str.trim()
7026 return str.replace(/^\s+|\s+$/g, '')
7027}
7028
7029function toHex (n) {
7030 if (n < 16) return '0' + n.toString(16)
7031 return n.toString(16)
7032}
7033
7034function utf8ToBytes (string, units) {
7035 units = units || Infinity
7036 var codePoint
7037 var length = string.length
7038 var leadSurrogate = null
7039 var bytes = []
7040
7041 for (var i = 0; i < length; ++i) {
7042 codePoint = string.charCodeAt(i)
7043
7044 // is surrogate component
7045 if (codePoint > 0xD7FF && codePoint < 0xE000) {
7046 // last char was a lead
7047 if (!leadSurrogate) {
7048 // no lead yet
7049 if (codePoint > 0xDBFF) {
7050 // unexpected trail
7051 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7052 continue
7053 } else if (i + 1 === length) {
7054 // unpaired lead
7055 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7056 continue
7057 }
7058
7059 // valid lead
7060 leadSurrogate = codePoint
7061
7062 continue
7063 }
7064
7065 // 2 leads in a row
7066 if (codePoint < 0xDC00) {
7067 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7068 leadSurrogate = codePoint
7069 continue
7070 }
7071
7072 // valid surrogate pair
7073 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
7074 } else if (leadSurrogate) {
7075 // valid bmp char, but last char was a lead
7076 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
7077 }
7078
7079 leadSurrogate = null
7080
7081 // encode utf8
7082 if (codePoint < 0x80) {
7083 if ((units -= 1) < 0) break
7084 bytes.push(codePoint)
7085 } else if (codePoint < 0x800) {
7086 if ((units -= 2) < 0) break
7087 bytes.push(
7088 codePoint >> 0x6 | 0xC0,
7089 codePoint & 0x3F | 0x80
7090 )
7091 } else if (codePoint < 0x10000) {
7092 if ((units -= 3) < 0) break
7093 bytes.push(
7094 codePoint >> 0xC | 0xE0,
7095 codePoint >> 0x6 & 0x3F | 0x80,
7096 codePoint & 0x3F | 0x80
7097 )
7098 } else if (codePoint < 0x110000) {
7099 if ((units -= 4) < 0) break
7100 bytes.push(
7101 codePoint >> 0x12 | 0xF0,
7102 codePoint >> 0xC & 0x3F | 0x80,
7103 codePoint >> 0x6 & 0x3F | 0x80,
7104 codePoint & 0x3F | 0x80
7105 )
7106 } else {
7107 throw new Error('Invalid code point')
7108 }
7109 }
7110
7111 return bytes
7112}
7113
7114function asciiToBytes (str) {
7115 var byteArray = []
7116 for (var i = 0; i < str.length; ++i) {
7117 // Node's code seems to be doing this and not & 0x7F..
7118 byteArray.push(str.charCodeAt(i) & 0xFF)
7119 }
7120 return byteArray
7121}
7122
7123function utf16leToBytes (str, units) {
7124 var c, hi, lo
7125 var byteArray = []
7126 for (var i = 0; i < str.length; ++i) {
7127 if ((units -= 2) < 0) break
7128
7129 c = str.charCodeAt(i)
7130 hi = c >> 8
7131 lo = c % 256
7132 byteArray.push(lo)
7133 byteArray.push(hi)
7134 }
7135
7136 return byteArray
7137}
7138
7139function base64ToBytes (str) {
7140 return base64.toByteArray(base64clean(str))
7141}
7142
7143function blitBuffer (src, dst, offset, length) {
7144 for (var i = 0; i < length; ++i) {
7145 if ((i + offset >= dst.length) || (i >= src.length)) break
7146 dst[i + offset] = src[i]
7147 }
7148 return i
7149}
7150
7151function isnan (val) {
7152 return val !== val // eslint-disable-line no-self-compare
7153}
7154
7155}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("buffer").Buffer)
7156
7157},{"base64-js":40,"buffer":41,"ieee754":44,"isarray":45}],42:[function(require,module,exports){
7158(function (process){(function (){
7159/**
7160 * This is the web browser implementation of `debug()`.
7161 *
7162 * Expose `debug()` as the module.
7163 */
7164
7165exports = module.exports = require('./debug');
7166exports.log = log;
7167exports.formatArgs = formatArgs;
7168exports.save = save;
7169exports.load = load;
7170exports.useColors = useColors;
7171exports.storage = 'undefined' != typeof chrome
7172 && 'undefined' != typeof chrome.storage
7173 ? chrome.storage.local
7174 : localstorage();
7175
7176/**
7177 * Colors.
7178 */
7179
7180exports.colors = [
7181 'lightseagreen',
7182 'forestgreen',
7183 'goldenrod',
7184 'dodgerblue',
7185 'darkorchid',
7186 'crimson'
7187];
7188
7189/**
7190 * Currently only WebKit-based Web Inspectors, Firefox >= v31,
7191 * and the Firebug extension (any Firefox version) are known
7192 * to support "%c" CSS customizations.
7193 *
7194 * TODO: add a `localStorage` variable to explicitly enable/disable colors
7195 */
7196
7197function useColors() {
7198 // NB: In an Electron preload script, document will be defined but not fully
7199 // initialized. Since we know we're in Chrome, we'll just detect this case
7200 // explicitly
7201 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
7202 return true;
7203 }
7204
7205 // is webkit? http://stackoverflow.com/a/16459606/376773
7206 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
7207 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
7208 // is firebug? http://stackoverflow.com/a/398120/376773
7209 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
7210 // is firefox >= v31?
7211 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
7212 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
7213 // double check webkit in userAgent just in case we are in a worker
7214 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
7215}
7216
7217/**
7218 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
7219 */
7220
7221exports.formatters.j = function(v) {
7222 try {
7223 return JSON.stringify(v);
7224 } catch (err) {
7225 return '[UnexpectedJSONParseError]: ' + err.message;
7226 }
7227};
7228
7229
7230/**
7231 * Colorize log arguments if enabled.
7232 *
7233 * @api public
7234 */
7235
7236function formatArgs(args) {
7237 var useColors = this.useColors;
7238
7239 args[0] = (useColors ? '%c' : '')
7240 + this.namespace
7241 + (useColors ? ' %c' : ' ')
7242 + args[0]
7243 + (useColors ? '%c ' : ' ')
7244 + '+' + exports.humanize(this.diff);
7245
7246 if (!useColors) return;
7247
7248 var c = 'color: ' + this.color;
7249 args.splice(1, 0, c, 'color: inherit')
7250
7251 // the final "%c" is somewhat tricky, because there could be other
7252 // arguments passed either before or after the %c, so we need to
7253 // figure out the correct index to insert the CSS into
7254 var index = 0;
7255 var lastC = 0;
7256 args[0].replace(/%[a-zA-Z%]/g, function(match) {
7257 if ('%%' === match) return;
7258 index++;
7259 if ('%c' === match) {
7260 // we only are interested in the *last* %c
7261 // (the user may have provided their own)
7262 lastC = index;
7263 }
7264 });
7265
7266 args.splice(lastC, 0, c);
7267}
7268
7269/**
7270 * Invokes `console.log()` when available.
7271 * No-op when `console.log` is not a "function".
7272 *
7273 * @api public
7274 */
7275
7276function log() {
7277 // this hackery is required for IE8/9, where
7278 // the `console.log` function doesn't have 'apply'
7279 return 'object' === typeof console
7280 && console.log
7281 && Function.prototype.apply.call(console.log, console, arguments);
7282}
7283
7284/**
7285 * Save `namespaces`.
7286 *
7287 * @param {String} namespaces
7288 * @api private
7289 */
7290
7291function save(namespaces) {
7292 try {
7293 if (null == namespaces) {
7294 exports.storage.removeItem('debug');
7295 } else {
7296 exports.storage.debug = namespaces;
7297 }
7298 } catch(e) {}
7299}
7300
7301/**
7302 * Load `namespaces`.
7303 *
7304 * @return {String} returns the previously persisted debug modes
7305 * @api private
7306 */
7307
7308function load() {
7309 var r;
7310 try {
7311 r = exports.storage.debug;
7312 } catch(e) {}
7313
7314 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
7315 if (!r && typeof process !== 'undefined' && 'env' in process) {
7316 r = process.env.DEBUG;
7317 }
7318
7319 return r;
7320}
7321
7322/**
7323 * Enable namespaces listed in `localStorage.debug` initially.
7324 */
7325
7326exports.enable(load());
7327
7328/**
7329 * Localstorage attempts to return the localstorage.
7330 *
7331 * This is necessary because safari throws
7332 * when a user disables cookies/localstorage
7333 * and you attempt to access it.
7334 *
7335 * @return {LocalStorage}
7336 * @api private
7337 */
7338
7339function localstorage() {
7340 try {
7341 return window.localStorage;
7342 } catch (e) {}
7343}
7344
7345}).call(this)}).call(this,require('_process'))
7346
7347},{"./debug":43,"_process":48}],43:[function(require,module,exports){
7348
7349/**
7350 * This is the common logic for both the Node.js and web browser
7351 * implementations of `debug()`.
7352 *
7353 * Expose `debug()` as the module.
7354 */
7355
7356exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
7357exports.coerce = coerce;
7358exports.disable = disable;
7359exports.enable = enable;
7360exports.enabled = enabled;
7361exports.humanize = require('ms');
7362
7363/**
7364 * The currently active debug mode names, and names to skip.
7365 */
7366
7367exports.names = [];
7368exports.skips = [];
7369
7370/**
7371 * Map of special "%n" handling functions, for the debug "format" argument.
7372 *
7373 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
7374 */
7375
7376exports.formatters = {};
7377
7378/**
7379 * Previous log timestamp.
7380 */
7381
7382var prevTime;
7383
7384/**
7385 * Select a color.
7386 * @param {String} namespace
7387 * @return {Number}
7388 * @api private
7389 */
7390
7391function selectColor(namespace) {
7392 var hash = 0, i;
7393
7394 for (i in namespace) {
7395 hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
7396 hash |= 0; // Convert to 32bit integer
7397 }
7398
7399 return exports.colors[Math.abs(hash) % exports.colors.length];
7400}
7401
7402/**
7403 * Create a debugger with the given `namespace`.
7404 *
7405 * @param {String} namespace
7406 * @return {Function}
7407 * @api public
7408 */
7409
7410function createDebug(namespace) {
7411
7412 function debug() {
7413 // disabled?
7414 if (!debug.enabled) return;
7415
7416 var self = debug;
7417
7418 // set `diff` timestamp
7419 var curr = +new Date();
7420 var ms = curr - (prevTime || curr);
7421 self.diff = ms;
7422 self.prev = prevTime;
7423 self.curr = curr;
7424 prevTime = curr;
7425
7426 // turn the `arguments` into a proper Array
7427 var args = new Array(arguments.length);
7428 for (var i = 0; i < args.length; i++) {
7429 args[i] = arguments[i];
7430 }
7431
7432 args[0] = exports.coerce(args[0]);
7433
7434 if ('string' !== typeof args[0]) {
7435 // anything else let's inspect with %O
7436 args.unshift('%O');
7437 }
7438
7439 // apply any `formatters` transformations
7440 var index = 0;
7441 args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
7442 // if we encounter an escaped % then don't increase the array index
7443 if (match === '%%') return match;
7444 index++;
7445 var formatter = exports.formatters[format];
7446 if ('function' === typeof formatter) {
7447 var val = args[index];
7448 match = formatter.call(self, val);
7449
7450 // now we need to remove `args[index]` since it's inlined in the `format`
7451 args.splice(index, 1);
7452 index--;
7453 }
7454 return match;
7455 });
7456
7457 // apply env-specific formatting (colors, etc.)
7458 exports.formatArgs.call(self, args);
7459
7460 var logFn = debug.log || exports.log || console.log.bind(console);
7461 logFn.apply(self, args);
7462 }
7463
7464 debug.namespace = namespace;
7465 debug.enabled = exports.enabled(namespace);
7466 debug.useColors = exports.useColors();
7467 debug.color = selectColor(namespace);
7468
7469 // env-specific initialization logic for debug instances
7470 if ('function' === typeof exports.init) {
7471 exports.init(debug);
7472 }
7473
7474 return debug;
7475}
7476
7477/**
7478 * Enables a debug mode by namespaces. This can include modes
7479 * separated by a colon and wildcards.
7480 *
7481 * @param {String} namespaces
7482 * @api public
7483 */
7484
7485function enable(namespaces) {
7486 exports.save(namespaces);
7487
7488 exports.names = [];
7489 exports.skips = [];
7490
7491 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
7492 var len = split.length;
7493
7494 for (var i = 0; i < len; i++) {
7495 if (!split[i]) continue; // ignore empty strings
7496 namespaces = split[i].replace(/\*/g, '.*?');
7497 if (namespaces[0] === '-') {
7498 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
7499 } else {
7500 exports.names.push(new RegExp('^' + namespaces + '$'));
7501 }
7502 }
7503}
7504
7505/**
7506 * Disable debug output.
7507 *
7508 * @api public
7509 */
7510
7511function disable() {
7512 exports.enable('');
7513}
7514
7515/**
7516 * Returns true if the given mode name is enabled, false otherwise.
7517 *
7518 * @param {String} name
7519 * @return {Boolean}
7520 * @api public
7521 */
7522
7523function enabled(name) {
7524 var i, len;
7525 for (i = 0, len = exports.skips.length; i < len; i++) {
7526 if (exports.skips[i].test(name)) {
7527 return false;
7528 }
7529 }
7530 for (i = 0, len = exports.names.length; i < len; i++) {
7531 if (exports.names[i].test(name)) {
7532 return true;
7533 }
7534 }
7535 return false;
7536}
7537
7538/**
7539 * Coerce `val`.
7540 *
7541 * @param {Mixed} val
7542 * @return {Mixed}
7543 * @api private
7544 */
7545
7546function coerce(val) {
7547 if (val instanceof Error) return val.stack || val.message;
7548 return val;
7549}
7550
7551},{"ms":47}],44:[function(require,module,exports){
7552/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
7553exports.read = function (buffer, offset, isLE, mLen, nBytes) {
7554 var e, m
7555 var eLen = (nBytes * 8) - mLen - 1
7556 var eMax = (1 << eLen) - 1
7557 var eBias = eMax >> 1
7558 var nBits = -7
7559 var i = isLE ? (nBytes - 1) : 0
7560 var d = isLE ? -1 : 1
7561 var s = buffer[offset + i]
7562
7563 i += d
7564
7565 e = s & ((1 << (-nBits)) - 1)
7566 s >>= (-nBits)
7567 nBits += eLen
7568 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
7569
7570 m = e & ((1 << (-nBits)) - 1)
7571 e >>= (-nBits)
7572 nBits += mLen
7573 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
7574
7575 if (e === 0) {
7576 e = 1 - eBias
7577 } else if (e === eMax) {
7578 return m ? NaN : ((s ? -1 : 1) * Infinity)
7579 } else {
7580 m = m + Math.pow(2, mLen)
7581 e = e - eBias
7582 }
7583 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
7584}
7585
7586exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
7587 var e, m, c
7588 var eLen = (nBytes * 8) - mLen - 1
7589 var eMax = (1 << eLen) - 1
7590 var eBias = eMax >> 1
7591 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
7592 var i = isLE ? 0 : (nBytes - 1)
7593 var d = isLE ? 1 : -1
7594 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
7595
7596 value = Math.abs(value)
7597
7598 if (isNaN(value) || value === Infinity) {
7599 m = isNaN(value) ? 1 : 0
7600 e = eMax
7601 } else {
7602 e = Math.floor(Math.log(value) / Math.LN2)
7603 if (value * (c = Math.pow(2, -e)) < 1) {
7604 e--
7605 c *= 2
7606 }
7607 if (e + eBias >= 1) {
7608 value += rt / c
7609 } else {
7610 value += rt * Math.pow(2, 1 - eBias)
7611 }
7612 if (value * c >= 2) {
7613 e++
7614 c /= 2
7615 }
7616
7617 if (e + eBias >= eMax) {
7618 m = 0
7619 e = eMax
7620 } else if (e + eBias >= 1) {
7621 m = ((value * c) - 1) * Math.pow(2, mLen)
7622 e = e + eBias
7623 } else {
7624 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
7625 e = 0
7626 }
7627 }
7628
7629 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
7630
7631 e = (e << mLen) | m
7632 eLen += mLen
7633 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
7634
7635 buffer[offset + i - d] |= s * 128
7636}
7637
7638},{}],45:[function(require,module,exports){
7639var toString = {}.toString;
7640
7641module.exports = Array.isArray || function (arr) {
7642 return toString.call(arr) == '[object Array]';
7643};
7644
7645},{}],46:[function(require,module,exports){
7646(function (global){(function (){
7647/*
7648 * base64.js
7649 *
7650 * Licensed under the BSD 3-Clause License.
7651 * http://opensource.org/licenses/BSD-3-Clause
7652 *
7653 * References:
7654 * http://en.wikipedia.org/wiki/Base64
7655 */
7656;(function (global, factory) {
7657 typeof exports === 'object' && typeof module !== 'undefined'
7658 ? module.exports = factory(global)
7659 : typeof define === 'function' && define.amd
7660 ? define(factory) : factory(global)
7661}((
7662 typeof self !== 'undefined' ? self
7663 : typeof window !== 'undefined' ? window
7664 : typeof global !== 'undefined' ? global
7665: this
7666), function(global) {
7667 'use strict';
7668 // existing version for noConflict()
7669 global = global || {};
7670 var _Base64 = global.Base64;
7671 var version = "2.6.4";
7672 // constants
7673 var b64chars
7674 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
7675 var b64tab = function(bin) {
7676 var t = {};
7677 for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
7678 return t;
7679 }(b64chars);
7680 var fromCharCode = String.fromCharCode;
7681 // encoder stuff
7682 var cb_utob = function(c) {
7683 if (c.length < 2) {
7684 var cc = c.charCodeAt(0);
7685 return cc < 0x80 ? c
7686 : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
7687 + fromCharCode(0x80 | (cc & 0x3f)))
7688 : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
7689 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
7690 + fromCharCode(0x80 | ( cc & 0x3f)));
7691 } else {
7692 var cc = 0x10000
7693 + (c.charCodeAt(0) - 0xD800) * 0x400
7694 + (c.charCodeAt(1) - 0xDC00);
7695 return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
7696 + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
7697 + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
7698 + fromCharCode(0x80 | ( cc & 0x3f)));
7699 }
7700 };
7701 var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
7702 var utob = function(u) {
7703 return u.replace(re_utob, cb_utob);
7704 };
7705 var cb_encode = function(ccc) {
7706 var padlen = [0, 2, 1][ccc.length % 3],
7707 ord = ccc.charCodeAt(0) << 16
7708 | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
7709 | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
7710 chars = [
7711 b64chars.charAt( ord >>> 18),
7712 b64chars.charAt((ord >>> 12) & 63),
7713 padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
7714 padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
7715 ];
7716 return chars.join('');
7717 };
7718 var btoa = global.btoa && typeof global.btoa == 'function'
7719 ? function(b){ return global.btoa(b) } : function(b) {
7720 if (b.match(/[^\x00-\xFF]/)) throw new RangeError(
7721 'The string contains invalid characters.'
7722 );
7723 return b.replace(/[\s\S]{1,3}/g, cb_encode);
7724 };
7725 var _encode = function(u) {
7726 return btoa(utob(String(u)));
7727 };
7728 var mkUriSafe = function (b64) {
7729 return b64.replace(/[+\/]/g, function(m0) {
7730 return m0 == '+' ? '-' : '_';
7731 }).replace(/=/g, '');
7732 };
7733 var encode = function(u, urisafe) {
7734 return urisafe ? mkUriSafe(_encode(u)) : _encode(u);
7735 };
7736 var encodeURI = function(u) { return encode(u, true) };
7737 var fromUint8Array;
7738 if (global.Uint8Array) fromUint8Array = function(a, urisafe) {
7739 // return btoa(fromCharCode.apply(null, a));
7740 var b64 = '';
7741 for (var i = 0, l = a.length; i < l; i += 3) {
7742 var a0 = a[i], a1 = a[i+1], a2 = a[i+2];
7743 var ord = a0 << 16 | a1 << 8 | a2;
7744 b64 += b64chars.charAt( ord >>> 18)
7745 + b64chars.charAt((ord >>> 12) & 63)
7746 + ( typeof a1 != 'undefined'
7747 ? b64chars.charAt((ord >>> 6) & 63) : '=')
7748 + ( typeof a2 != 'undefined'
7749 ? b64chars.charAt( ord & 63) : '=');
7750 }
7751 return urisafe ? mkUriSafe(b64) : b64;
7752 };
7753 // decoder stuff
7754 var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
7755 var cb_btou = function(cccc) {
7756 switch(cccc.length) {
7757 case 4:
7758 var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
7759 | ((0x3f & cccc.charCodeAt(1)) << 12)
7760 | ((0x3f & cccc.charCodeAt(2)) << 6)
7761 | (0x3f & cccc.charCodeAt(3)),
7762 offset = cp - 0x10000;
7763 return (fromCharCode((offset >>> 10) + 0xD800)
7764 + fromCharCode((offset & 0x3FF) + 0xDC00));
7765 case 3:
7766 return fromCharCode(
7767 ((0x0f & cccc.charCodeAt(0)) << 12)
7768 | ((0x3f & cccc.charCodeAt(1)) << 6)
7769 | (0x3f & cccc.charCodeAt(2))
7770 );
7771 default:
7772 return fromCharCode(
7773 ((0x1f & cccc.charCodeAt(0)) << 6)
7774 | (0x3f & cccc.charCodeAt(1))
7775 );
7776 }
7777 };
7778 var btou = function(b) {
7779 return b.replace(re_btou, cb_btou);
7780 };
7781 var cb_decode = function(cccc) {
7782 var len = cccc.length,
7783 padlen = len % 4,
7784 n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
7785 | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
7786 | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
7787 | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
7788 chars = [
7789 fromCharCode( n >>> 16),
7790 fromCharCode((n >>> 8) & 0xff),
7791 fromCharCode( n & 0xff)
7792 ];
7793 chars.length -= [0, 0, 2, 1][padlen];
7794 return chars.join('');
7795 };
7796 var _atob = global.atob && typeof global.atob == 'function'
7797 ? function(a){ return global.atob(a) } : function(a){
7798 return a.replace(/\S{1,4}/g, cb_decode);
7799 };
7800 var atob = function(a) {
7801 return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
7802 };
7803 var _decode = function(a) { return btou(_atob(a)) };
7804 var _fromURI = function(a) {
7805 return String(a).replace(/[-_]/g, function(m0) {
7806 return m0 == '-' ? '+' : '/'
7807 }).replace(/[^A-Za-z0-9\+\/]/g, '');
7808 };
7809 var decode = function(a){
7810 return _decode(_fromURI(a));
7811 };
7812 var toUint8Array;
7813 if (global.Uint8Array) toUint8Array = function(a) {
7814 return Uint8Array.from(atob(_fromURI(a)), function(c) {
7815 return c.charCodeAt(0);
7816 });
7817 };
7818 var noConflict = function() {
7819 var Base64 = global.Base64;
7820 global.Base64 = _Base64;
7821 return Base64;
7822 };
7823 // export Base64
7824 global.Base64 = {
7825 VERSION: version,
7826 atob: atob,
7827 btoa: btoa,
7828 fromBase64: decode,
7829 toBase64: encode,
7830 utob: utob,
7831 encode: encode,
7832 encodeURI: encodeURI,
7833 btou: btou,
7834 decode: decode,
7835 noConflict: noConflict,
7836 fromUint8Array: fromUint8Array,
7837 toUint8Array: toUint8Array
7838 };
7839 // if ES5 is available, make Base64.extendString() available
7840 if (typeof Object.defineProperty === 'function') {
7841 var noEnum = function(v){
7842 return {value:v,enumerable:false,writable:true,configurable:true};
7843 };
7844 global.Base64.extendString = function () {
7845 Object.defineProperty(
7846 String.prototype, 'fromBase64', noEnum(function () {
7847 return decode(this)
7848 }));
7849 Object.defineProperty(
7850 String.prototype, 'toBase64', noEnum(function (urisafe) {
7851 return encode(this, urisafe)
7852 }));
7853 Object.defineProperty(
7854 String.prototype, 'toBase64URI', noEnum(function () {
7855 return encode(this, true)
7856 }));
7857 };
7858 }
7859 //
7860 // export Base64 to the namespace
7861 //
7862 if (global['Meteor']) { // Meteor.js
7863 Base64 = global.Base64;
7864 }
7865 // module.exports and AMD are mutually exclusive.
7866 // module.exports has precedence.
7867 if (typeof module !== 'undefined' && module.exports) {
7868 module.exports.Base64 = global.Base64;
7869 }
7870 else if (typeof define === 'function' && define.amd) {
7871 // AMD. Register as an anonymous module.
7872 define([], function(){ return global.Base64 });
7873 }
7874 // that's it!
7875 return {Base64: global.Base64}
7876}));
7877
7878}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
7879
7880},{}],47:[function(require,module,exports){
7881/**
7882 * Helpers.
7883 */
7884
7885var s = 1000;
7886var m = s * 60;
7887var h = m * 60;
7888var d = h * 24;
7889var y = d * 365.25;
7890
7891/**
7892 * Parse or format the given `val`.
7893 *
7894 * Options:
7895 *
7896 * - `long` verbose formatting [false]
7897 *
7898 * @param {String|Number} val
7899 * @param {Object} [options]
7900 * @throws {Error} throw an error if val is not a non-empty string or a number
7901 * @return {String|Number}
7902 * @api public
7903 */
7904
7905module.exports = function(val, options) {
7906 options = options || {};
7907 var type = typeof val;
7908 if (type === 'string' && val.length > 0) {
7909 return parse(val);
7910 } else if (type === 'number' && isNaN(val) === false) {
7911 return options.long ? fmtLong(val) : fmtShort(val);
7912 }
7913 throw new Error(
7914 'val is not a non-empty string or a valid number. val=' +
7915 JSON.stringify(val)
7916 );
7917};
7918
7919/**
7920 * Parse the given `str` and return milliseconds.
7921 *
7922 * @param {String} str
7923 * @return {Number}
7924 * @api private
7925 */
7926
7927function parse(str) {
7928 str = String(str);
7929 if (str.length > 100) {
7930 return;
7931 }
7932 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
7933 str
7934 );
7935 if (!match) {
7936 return;
7937 }
7938 var n = parseFloat(match[1]);
7939 var type = (match[2] || 'ms').toLowerCase();
7940 switch (type) {
7941 case 'years':
7942 case 'year':
7943 case 'yrs':
7944 case 'yr':
7945 case 'y':
7946 return n * y;
7947 case 'days':
7948 case 'day':
7949 case 'd':
7950 return n * d;
7951 case 'hours':
7952 case 'hour':
7953 case 'hrs':
7954 case 'hr':
7955 case 'h':
7956 return n * h;
7957 case 'minutes':
7958 case 'minute':
7959 case 'mins':
7960 case 'min':
7961 case 'm':
7962 return n * m;
7963 case 'seconds':
7964 case 'second':
7965 case 'secs':
7966 case 'sec':
7967 case 's':
7968 return n * s;
7969 case 'milliseconds':
7970 case 'millisecond':
7971 case 'msecs':
7972 case 'msec':
7973 case 'ms':
7974 return n;
7975 default:
7976 return undefined;
7977 }
7978}
7979
7980/**
7981 * Short format for `ms`.
7982 *
7983 * @param {Number} ms
7984 * @return {String}
7985 * @api private
7986 */
7987
7988function fmtShort(ms) {
7989 if (ms >= d) {
7990 return Math.round(ms / d) + 'd';
7991 }
7992 if (ms >= h) {
7993 return Math.round(ms / h) + 'h';
7994 }
7995 if (ms >= m) {
7996 return Math.round(ms / m) + 'm';
7997 }
7998 if (ms >= s) {
7999 return Math.round(ms / s) + 's';
8000 }
8001 return ms + 'ms';
8002}
8003
8004/**
8005 * Long format for `ms`.
8006 *
8007 * @param {Number} ms
8008 * @return {String}
8009 * @api private
8010 */
8011
8012function fmtLong(ms) {
8013 return plural(ms, d, 'day') ||
8014 plural(ms, h, 'hour') ||
8015 plural(ms, m, 'minute') ||
8016 plural(ms, s, 'second') ||
8017 ms + ' ms';
8018}
8019
8020/**
8021 * Pluralization helper.
8022 */
8023
8024function plural(ms, n, name) {
8025 if (ms < n) {
8026 return;
8027 }
8028 if (ms < n * 1.5) {
8029 return Math.floor(ms / n) + ' ' + name;
8030 }
8031 return Math.ceil(ms / n) + ' ' + name + 's';
8032}
8033
8034},{}],48:[function(require,module,exports){
8035// shim for using process in browser
8036var process = module.exports = {};
8037
8038// cached from whatever global is present so that test runners that stub it
8039// don't break things. But we need to wrap it in a try catch in case it is
8040// wrapped in strict mode code which doesn't define any globals. It's inside a
8041// function because try/catches deoptimize in certain engines.
8042
8043var cachedSetTimeout;
8044var cachedClearTimeout;
8045
8046function defaultSetTimout() {
8047 throw new Error('setTimeout has not been defined');
8048}
8049function defaultClearTimeout () {
8050 throw new Error('clearTimeout has not been defined');
8051}
8052(function () {
8053 try {
8054 if (typeof setTimeout === 'function') {
8055 cachedSetTimeout = setTimeout;
8056 } else {
8057 cachedSetTimeout = defaultSetTimout;
8058 }
8059 } catch (e) {
8060 cachedSetTimeout = defaultSetTimout;
8061 }
8062 try {
8063 if (typeof clearTimeout === 'function') {
8064 cachedClearTimeout = clearTimeout;
8065 } else {
8066 cachedClearTimeout = defaultClearTimeout;
8067 }
8068 } catch (e) {
8069 cachedClearTimeout = defaultClearTimeout;
8070 }
8071} ())
8072function runTimeout(fun) {
8073 if (cachedSetTimeout === setTimeout) {
8074 //normal enviroments in sane situations
8075 return setTimeout(fun, 0);
8076 }
8077 // if setTimeout wasn't available but was latter defined
8078 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
8079 cachedSetTimeout = setTimeout;
8080 return setTimeout(fun, 0);
8081 }
8082 try {
8083 // when when somebody has screwed with setTimeout but no I.E. maddness
8084 return cachedSetTimeout(fun, 0);
8085 } catch(e){
8086 try {
8087 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
8088 return cachedSetTimeout.call(null, fun, 0);
8089 } catch(e){
8090 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
8091 return cachedSetTimeout.call(this, fun, 0);
8092 }
8093 }
8094
8095
8096}
8097function runClearTimeout(marker) {
8098 if (cachedClearTimeout === clearTimeout) {
8099 //normal enviroments in sane situations
8100 return clearTimeout(marker);
8101 }
8102 // if clearTimeout wasn't available but was latter defined
8103 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
8104 cachedClearTimeout = clearTimeout;
8105 return clearTimeout(marker);
8106 }
8107 try {
8108 // when when somebody has screwed with setTimeout but no I.E. maddness
8109 return cachedClearTimeout(marker);
8110 } catch (e){
8111 try {
8112 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
8113 return cachedClearTimeout.call(null, marker);
8114 } catch (e){
8115 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
8116 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
8117 return cachedClearTimeout.call(this, marker);
8118 }
8119 }
8120
8121
8122
8123}
8124var queue = [];
8125var draining = false;
8126var currentQueue;
8127var queueIndex = -1;
8128
8129function cleanUpNextTick() {
8130 if (!draining || !currentQueue) {
8131 return;
8132 }
8133 draining = false;
8134 if (currentQueue.length) {
8135 queue = currentQueue.concat(queue);
8136 } else {
8137 queueIndex = -1;
8138 }
8139 if (queue.length) {
8140 drainQueue();
8141 }
8142}
8143
8144function drainQueue() {
8145 if (draining) {
8146 return;
8147 }
8148 var timeout = runTimeout(cleanUpNextTick);
8149 draining = true;
8150
8151 var len = queue.length;
8152 while(len) {
8153 currentQueue = queue;
8154 queue = [];
8155 while (++queueIndex < len) {
8156 if (currentQueue) {
8157 currentQueue[queueIndex].run();
8158 }
8159 }
8160 queueIndex = -1;
8161 len = queue.length;
8162 }
8163 currentQueue = null;
8164 draining = false;
8165 runClearTimeout(timeout);
8166}
8167
8168process.nextTick = function (fun) {
8169 var args = new Array(arguments.length - 1);
8170 if (arguments.length > 1) {
8171 for (var i = 1; i < arguments.length; i++) {
8172 args[i - 1] = arguments[i];
8173 }
8174 }
8175 queue.push(new Item(fun, args));
8176 if (queue.length === 1 && !draining) {
8177 runTimeout(drainQueue);
8178 }
8179};
8180
8181// v8 likes predictible objects
8182function Item(fun, array) {
8183 this.fun = fun;
8184 this.array = array;
8185}
8186Item.prototype.run = function () {
8187 this.fun.apply(null, this.array);
8188};
8189process.title = 'browser';
8190process.browser = true;
8191process.env = {};
8192process.argv = [];
8193process.version = ''; // empty string to avoid regexp issues
8194process.versions = {};
8195
8196function noop() {}
8197
8198process.on = noop;
8199process.addListener = noop;
8200process.once = noop;
8201process.off = noop;
8202process.removeListener = noop;
8203process.removeAllListeners = noop;
8204process.emit = noop;
8205process.prependListener = noop;
8206process.prependOnceListener = noop;
8207
8208process.listeners = function (name) { return [] }
8209
8210process.binding = function (name) {
8211 throw new Error('process.binding is not supported');
8212};
8213
8214process.cwd = function () { return '/' };
8215process.chdir = function (dir) {
8216 throw new Error('process.chdir is not supported');
8217};
8218process.umask = function() { return 0; };
8219
8220},{}],49:[function(require,module,exports){
8221(function (global){(function (){
8222/*! https://mths.be/utf8js v2.1.2 by @mathias */
8223;(function(root) {
8224
8225 // Detect free variables `exports`
8226 var freeExports = typeof exports == 'object' && exports;
8227
8228 // Detect free variable `module`
8229 var freeModule = typeof module == 'object' && module &&
8230 module.exports == freeExports && module;
8231
8232 // Detect free variable `global`, from Node.js or Browserified code,
8233 // and use it as `root`
8234 var freeGlobal = typeof global == 'object' && global;
8235 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
8236 root = freeGlobal;
8237 }
8238
8239 /*--------------------------------------------------------------------------*/
8240
8241 var stringFromCharCode = String.fromCharCode;
8242
8243 // Taken from https://mths.be/punycode
8244 function ucs2decode(string) {
8245 var output = [];
8246 var counter = 0;
8247 var length = string.length;
8248 var value;
8249 var extra;
8250 while (counter < length) {
8251 value = string.charCodeAt(counter++);
8252 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
8253 // high surrogate, and there is a next character
8254 extra = string.charCodeAt(counter++);
8255 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
8256 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
8257 } else {
8258 // unmatched surrogate; only append this code unit, in case the next
8259 // code unit is the high surrogate of a surrogate pair
8260 output.push(value);
8261 counter--;
8262 }
8263 } else {
8264 output.push(value);
8265 }
8266 }
8267 return output;
8268 }
8269
8270 // Taken from https://mths.be/punycode
8271 function ucs2encode(array) {
8272 var length = array.length;
8273 var index = -1;
8274 var value;
8275 var output = '';
8276 while (++index < length) {
8277 value = array[index];
8278 if (value > 0xFFFF) {
8279 value -= 0x10000;
8280 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
8281 value = 0xDC00 | value & 0x3FF;
8282 }
8283 output += stringFromCharCode(value);
8284 }
8285 return output;
8286 }
8287
8288 function checkScalarValue(codePoint) {
8289 if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
8290 throw Error(
8291 'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
8292 ' is not a scalar value'
8293 );
8294 }
8295 }
8296 /*--------------------------------------------------------------------------*/
8297
8298 function createByte(codePoint, shift) {
8299 return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
8300 }
8301
8302 function encodeCodePoint(codePoint) {
8303 if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
8304 return stringFromCharCode(codePoint);
8305 }
8306 var symbol = '';
8307 if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
8308 symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
8309 }
8310 else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
8311 checkScalarValue(codePoint);
8312 symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
8313 symbol += createByte(codePoint, 6);
8314 }
8315 else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
8316 symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
8317 symbol += createByte(codePoint, 12);
8318 symbol += createByte(codePoint, 6);
8319 }
8320 symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
8321 return symbol;
8322 }
8323
8324 function utf8encode(string) {
8325 var codePoints = ucs2decode(string);
8326 var length = codePoints.length;
8327 var index = -1;
8328 var codePoint;
8329 var byteString = '';
8330 while (++index < length) {
8331 codePoint = codePoints[index];
8332 byteString += encodeCodePoint(codePoint);
8333 }
8334 return byteString;
8335 }
8336
8337 /*--------------------------------------------------------------------------*/
8338
8339 function readContinuationByte() {
8340 if (byteIndex >= byteCount) {
8341 throw Error('Invalid byte index');
8342 }
8343
8344 var continuationByte = byteArray[byteIndex] & 0xFF;
8345 byteIndex++;
8346
8347 if ((continuationByte & 0xC0) == 0x80) {
8348 return continuationByte & 0x3F;
8349 }
8350
8351 // If we end up here, it’s not a continuation byte
8352 throw Error('Invalid continuation byte');
8353 }
8354
8355 function decodeSymbol() {
8356 var byte1;
8357 var byte2;
8358 var byte3;
8359 var byte4;
8360 var codePoint;
8361
8362 if (byteIndex > byteCount) {
8363 throw Error('Invalid byte index');
8364 }
8365
8366 if (byteIndex == byteCount) {
8367 return false;
8368 }
8369
8370 // Read first byte
8371 byte1 = byteArray[byteIndex] & 0xFF;
8372 byteIndex++;
8373
8374 // 1-byte sequence (no continuation bytes)
8375 if ((byte1 & 0x80) == 0) {
8376 return byte1;
8377 }
8378
8379 // 2-byte sequence
8380 if ((byte1 & 0xE0) == 0xC0) {
8381 byte2 = readContinuationByte();
8382 codePoint = ((byte1 & 0x1F) << 6) | byte2;
8383 if (codePoint >= 0x80) {
8384 return codePoint;
8385 } else {
8386 throw Error('Invalid continuation byte');
8387 }
8388 }
8389
8390 // 3-byte sequence (may include unpaired surrogates)
8391 if ((byte1 & 0xF0) == 0xE0) {
8392 byte2 = readContinuationByte();
8393 byte3 = readContinuationByte();
8394 codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
8395 if (codePoint >= 0x0800) {
8396 checkScalarValue(codePoint);
8397 return codePoint;
8398 } else {
8399 throw Error('Invalid continuation byte');
8400 }
8401 }
8402
8403 // 4-byte sequence
8404 if ((byte1 & 0xF8) == 0xF0) {
8405 byte2 = readContinuationByte();
8406 byte3 = readContinuationByte();
8407 byte4 = readContinuationByte();
8408 codePoint = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0C) |
8409 (byte3 << 0x06) | byte4;
8410 if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
8411 return codePoint;
8412 }
8413 }
8414
8415 throw Error('Invalid UTF-8 detected');
8416 }
8417
8418 var byteArray;
8419 var byteCount;
8420 var byteIndex;
8421 function utf8decode(byteString) {
8422 byteArray = ucs2decode(byteString);
8423 byteCount = byteArray.length;
8424 byteIndex = 0;
8425 var codePoints = [];
8426 var tmp;
8427 while ((tmp = decodeSymbol()) !== false) {
8428 codePoints.push(tmp);
8429 }
8430 return ucs2encode(codePoints);
8431 }
8432
8433 /*--------------------------------------------------------------------------*/
8434
8435 var utf8 = {
8436 'version': '2.1.2',
8437 'encode': utf8encode,
8438 'decode': utf8decode
8439 };
8440
8441 // Some AMD build optimizers, like r.js, check for specific condition patterns
8442 // like the following:
8443 if (
8444 typeof define == 'function' &&
8445 typeof define.amd == 'object' &&
8446 define.amd
8447 ) {
8448 define(function() {
8449 return utf8;
8450 });
8451 } else if (freeExports && !freeExports.nodeType) {
8452 if (freeModule) { // in Node.js or RingoJS v0.8.0+
8453 freeModule.exports = utf8;
8454 } else { // in Narwhal or RingoJS v0.7.0-
8455 var object = {};
8456 var hasOwnProperty = object.hasOwnProperty;
8457 for (var key in utf8) {
8458 hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
8459 }
8460 }
8461 } else { // in Rhino or a web browser
8462 root.utf8 = utf8;
8463 }
8464
8465}(this));
8466
8467}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
8468
8469},{}]},{},[2])(2)
8470});
8471
8472//# sourceMappingURL=GitHub.bundle.js.map