GitHub.bundle.js 335 KB

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