bundle.js 549 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. 'use strict'
  3. exports.byteLength = byteLength
  4. exports.toByteArray = toByteArray
  5. exports.fromByteArray = fromByteArray
  6. var lookup = []
  7. var revLookup = []
  8. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  9. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  10. for (var i = 0, len = code.length; i < len; ++i) {
  11. lookup[i] = code[i]
  12. revLookup[code.charCodeAt(i)] = i
  13. }
  14. // Support decoding URL-safe base64 strings, as Node.js does.
  15. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  16. revLookup['-'.charCodeAt(0)] = 62
  17. revLookup['_'.charCodeAt(0)] = 63
  18. function getLens (b64) {
  19. var len = b64.length
  20. if (len % 4 > 0) {
  21. throw new Error('Invalid string. Length must be a multiple of 4')
  22. }
  23. // Trim off extra bytes after placeholder bytes are found
  24. // See: https://github.com/beatgammit/base64-js/issues/42
  25. var validLen = b64.indexOf('=')
  26. if (validLen === -1) validLen = len
  27. var placeHoldersLen = validLen === len
  28. ? 0
  29. : 4 - (validLen % 4)
  30. return [validLen, placeHoldersLen]
  31. }
  32. // base64 is 4/3 + up to two characters of the original data
  33. function byteLength (b64) {
  34. var lens = getLens(b64)
  35. var validLen = lens[0]
  36. var placeHoldersLen = lens[1]
  37. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  38. }
  39. function _byteLength (b64, validLen, placeHoldersLen) {
  40. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  41. }
  42. function toByteArray (b64) {
  43. var tmp
  44. var lens = getLens(b64)
  45. var validLen = lens[0]
  46. var placeHoldersLen = lens[1]
  47. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  48. var curByte = 0
  49. // if there are placeholders, only get up to the last complete 4 chars
  50. var len = placeHoldersLen > 0
  51. ? validLen - 4
  52. : validLen
  53. var i
  54. for (i = 0; i < len; i += 4) {
  55. tmp =
  56. (revLookup[b64.charCodeAt(i)] << 18) |
  57. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  58. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  59. revLookup[b64.charCodeAt(i + 3)]
  60. arr[curByte++] = (tmp >> 16) & 0xFF
  61. arr[curByte++] = (tmp >> 8) & 0xFF
  62. arr[curByte++] = tmp & 0xFF
  63. }
  64. if (placeHoldersLen === 2) {
  65. tmp =
  66. (revLookup[b64.charCodeAt(i)] << 2) |
  67. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  68. arr[curByte++] = tmp & 0xFF
  69. }
  70. if (placeHoldersLen === 1) {
  71. tmp =
  72. (revLookup[b64.charCodeAt(i)] << 10) |
  73. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  74. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  75. arr[curByte++] = (tmp >> 8) & 0xFF
  76. arr[curByte++] = tmp & 0xFF
  77. }
  78. return arr
  79. }
  80. function tripletToBase64 (num) {
  81. return lookup[num >> 18 & 0x3F] +
  82. lookup[num >> 12 & 0x3F] +
  83. lookup[num >> 6 & 0x3F] +
  84. lookup[num & 0x3F]
  85. }
  86. function encodeChunk (uint8, start, end) {
  87. var tmp
  88. var output = []
  89. for (var i = start; i < end; i += 3) {
  90. tmp =
  91. ((uint8[i] << 16) & 0xFF0000) +
  92. ((uint8[i + 1] << 8) & 0xFF00) +
  93. (uint8[i + 2] & 0xFF)
  94. output.push(tripletToBase64(tmp))
  95. }
  96. return output.join('')
  97. }
  98. function fromByteArray (uint8) {
  99. var tmp
  100. var len = uint8.length
  101. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  102. var parts = []
  103. var maxChunkLength = 16383 // must be multiple of 3
  104. // go through the array every three bytes, we'll deal with trailing stuff later
  105. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  106. parts.push(encodeChunk(
  107. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  108. ))
  109. }
  110. // pad the end with zeros, but make sure to not forget the extra bytes
  111. if (extraBytes === 1) {
  112. tmp = uint8[len - 1]
  113. parts.push(
  114. lookup[tmp >> 2] +
  115. lookup[(tmp << 4) & 0x3F] +
  116. '=='
  117. )
  118. } else if (extraBytes === 2) {
  119. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  120. parts.push(
  121. lookup[tmp >> 10] +
  122. lookup[(tmp >> 4) & 0x3F] +
  123. lookup[(tmp << 2) & 0x3F] +
  124. '='
  125. )
  126. }
  127. return parts.join('')
  128. }
  129. },{}],2:[function(require,module,exports){
  130. (function (Buffer){
  131. /*!
  132. * The buffer module from node.js, for the browser.
  133. *
  134. * @author Feross Aboukhadijeh <https://feross.org>
  135. * @license MIT
  136. */
  137. /* eslint-disable no-proto */
  138. 'use strict'
  139. var base64 = require('base64-js')
  140. var ieee754 = require('ieee754')
  141. exports.Buffer = Buffer
  142. exports.SlowBuffer = SlowBuffer
  143. exports.INSPECT_MAX_BYTES = 50
  144. var K_MAX_LENGTH = 0x7fffffff
  145. exports.kMaxLength = K_MAX_LENGTH
  146. /**
  147. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  148. * === true Use Uint8Array implementation (fastest)
  149. * === false Print warning and recommend using `buffer` v4.x which has an Object
  150. * implementation (most compatible, even IE6)
  151. *
  152. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  153. * Opera 11.6+, iOS 4.2+.
  154. *
  155. * We report that the browser does not support typed arrays if the are not subclassable
  156. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  157. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  158. * for __proto__ and has a buggy typed array implementation.
  159. */
  160. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport()
  161. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  162. typeof console.error === 'function') {
  163. console.error(
  164. 'This browser lacks typed array (Uint8Array) support which is required by ' +
  165. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
  166. )
  167. }
  168. function typedArraySupport () {
  169. // Can typed array instances can be augmented?
  170. try {
  171. var arr = new Uint8Array(1)
  172. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42 } }
  173. return arr.foo() === 42
  174. } catch (e) {
  175. return false
  176. }
  177. }
  178. Object.defineProperty(Buffer.prototype, 'parent', {
  179. enumerable: true,
  180. get: function () {
  181. if (!Buffer.isBuffer(this)) return undefined
  182. return this.buffer
  183. }
  184. })
  185. Object.defineProperty(Buffer.prototype, 'offset', {
  186. enumerable: true,
  187. get: function () {
  188. if (!Buffer.isBuffer(this)) return undefined
  189. return this.byteOffset
  190. }
  191. })
  192. function createBuffer (length) {
  193. if (length > K_MAX_LENGTH) {
  194. throw new RangeError('The value "' + length + '" is invalid for option "size"')
  195. }
  196. // Return an augmented `Uint8Array` instance
  197. var buf = new Uint8Array(length)
  198. buf.__proto__ = Buffer.prototype
  199. return buf
  200. }
  201. /**
  202. * The Buffer constructor returns instances of `Uint8Array` that have their
  203. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  204. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  205. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  206. * returns a single octet.
  207. *
  208. * The `Uint8Array` prototype remains unmodified.
  209. */
  210. function Buffer (arg, encodingOrOffset, length) {
  211. // Common case.
  212. if (typeof arg === 'number') {
  213. if (typeof encodingOrOffset === 'string') {
  214. throw new TypeError(
  215. 'The "string" argument must be of type string. Received type number'
  216. )
  217. }
  218. return allocUnsafe(arg)
  219. }
  220. return from(arg, encodingOrOffset, length)
  221. }
  222. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  223. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  224. Buffer[Symbol.species] === Buffer) {
  225. Object.defineProperty(Buffer, Symbol.species, {
  226. value: null,
  227. configurable: true,
  228. enumerable: false,
  229. writable: false
  230. })
  231. }
  232. Buffer.poolSize = 8192 // not used by this implementation
  233. function from (value, encodingOrOffset, length) {
  234. if (typeof value === 'string') {
  235. return fromString(value, encodingOrOffset)
  236. }
  237. if (ArrayBuffer.isView(value)) {
  238. return fromArrayLike(value)
  239. }
  240. if (value == null) {
  241. throw TypeError(
  242. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  243. 'or Array-like Object. Received type ' + (typeof value)
  244. )
  245. }
  246. if (isInstance(value, ArrayBuffer) ||
  247. (value && isInstance(value.buffer, ArrayBuffer))) {
  248. return fromArrayBuffer(value, encodingOrOffset, length)
  249. }
  250. if (typeof value === 'number') {
  251. throw new TypeError(
  252. 'The "value" argument must not be of type number. Received type number'
  253. )
  254. }
  255. var valueOf = value.valueOf && value.valueOf()
  256. if (valueOf != null && valueOf !== value) {
  257. return Buffer.from(valueOf, encodingOrOffset, length)
  258. }
  259. var b = fromObject(value)
  260. if (b) return b
  261. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  262. typeof value[Symbol.toPrimitive] === 'function') {
  263. return Buffer.from(
  264. value[Symbol.toPrimitive]('string'), encodingOrOffset, length
  265. )
  266. }
  267. throw new TypeError(
  268. 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  269. 'or Array-like Object. Received type ' + (typeof value)
  270. )
  271. }
  272. /**
  273. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  274. * if value is a number.
  275. * Buffer.from(str[, encoding])
  276. * Buffer.from(array)
  277. * Buffer.from(buffer)
  278. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  279. **/
  280. Buffer.from = function (value, encodingOrOffset, length) {
  281. return from(value, encodingOrOffset, length)
  282. }
  283. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  284. // https://github.com/feross/buffer/pull/148
  285. Buffer.prototype.__proto__ = Uint8Array.prototype
  286. Buffer.__proto__ = Uint8Array
  287. function assertSize (size) {
  288. if (typeof size !== 'number') {
  289. throw new TypeError('"size" argument must be of type number')
  290. } else if (size < 0) {
  291. throw new RangeError('The value "' + size + '" is invalid for option "size"')
  292. }
  293. }
  294. function alloc (size, fill, encoding) {
  295. assertSize(size)
  296. if (size <= 0) {
  297. return createBuffer(size)
  298. }
  299. if (fill !== undefined) {
  300. // Only pay attention to encoding if it's a string. This
  301. // prevents accidentally sending in a number that would
  302. // be interpretted as a start offset.
  303. return typeof encoding === 'string'
  304. ? createBuffer(size).fill(fill, encoding)
  305. : createBuffer(size).fill(fill)
  306. }
  307. return createBuffer(size)
  308. }
  309. /**
  310. * Creates a new filled Buffer instance.
  311. * alloc(size[, fill[, encoding]])
  312. **/
  313. Buffer.alloc = function (size, fill, encoding) {
  314. return alloc(size, fill, encoding)
  315. }
  316. function allocUnsafe (size) {
  317. assertSize(size)
  318. return createBuffer(size < 0 ? 0 : checked(size) | 0)
  319. }
  320. /**
  321. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  322. * */
  323. Buffer.allocUnsafe = function (size) {
  324. return allocUnsafe(size)
  325. }
  326. /**
  327. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  328. */
  329. Buffer.allocUnsafeSlow = function (size) {
  330. return allocUnsafe(size)
  331. }
  332. function fromString (string, encoding) {
  333. if (typeof encoding !== 'string' || encoding === '') {
  334. encoding = 'utf8'
  335. }
  336. if (!Buffer.isEncoding(encoding)) {
  337. throw new TypeError('Unknown encoding: ' + encoding)
  338. }
  339. var length = byteLength(string, encoding) | 0
  340. var buf = createBuffer(length)
  341. var actual = buf.write(string, encoding)
  342. if (actual !== length) {
  343. // Writing a hex string, for example, that contains invalid characters will
  344. // cause everything after the first invalid character to be ignored. (e.g.
  345. // 'abxxcd' will be treated as 'ab')
  346. buf = buf.slice(0, actual)
  347. }
  348. return buf
  349. }
  350. function fromArrayLike (array) {
  351. var length = array.length < 0 ? 0 : checked(array.length) | 0
  352. var buf = createBuffer(length)
  353. for (var i = 0; i < length; i += 1) {
  354. buf[i] = array[i] & 255
  355. }
  356. return buf
  357. }
  358. function fromArrayBuffer (array, byteOffset, length) {
  359. if (byteOffset < 0 || array.byteLength < byteOffset) {
  360. throw new RangeError('"offset" is outside of buffer bounds')
  361. }
  362. if (array.byteLength < byteOffset + (length || 0)) {
  363. throw new RangeError('"length" is outside of buffer bounds')
  364. }
  365. var buf
  366. if (byteOffset === undefined && length === undefined) {
  367. buf = new Uint8Array(array)
  368. } else if (length === undefined) {
  369. buf = new Uint8Array(array, byteOffset)
  370. } else {
  371. buf = new Uint8Array(array, byteOffset, length)
  372. }
  373. // Return an augmented `Uint8Array` instance
  374. buf.__proto__ = Buffer.prototype
  375. return buf
  376. }
  377. function fromObject (obj) {
  378. if (Buffer.isBuffer(obj)) {
  379. var len = checked(obj.length) | 0
  380. var buf = createBuffer(len)
  381. if (buf.length === 0) {
  382. return buf
  383. }
  384. obj.copy(buf, 0, 0, len)
  385. return buf
  386. }
  387. if (obj.length !== undefined) {
  388. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  389. return createBuffer(0)
  390. }
  391. return fromArrayLike(obj)
  392. }
  393. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  394. return fromArrayLike(obj.data)
  395. }
  396. }
  397. function checked (length) {
  398. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  399. // length is NaN (which is otherwise coerced to zero.)
  400. if (length >= K_MAX_LENGTH) {
  401. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  402. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
  403. }
  404. return length | 0
  405. }
  406. function SlowBuffer (length) {
  407. if (+length != length) { // eslint-disable-line eqeqeq
  408. length = 0
  409. }
  410. return Buffer.alloc(+length)
  411. }
  412. Buffer.isBuffer = function isBuffer (b) {
  413. return b != null && b._isBuffer === true &&
  414. b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
  415. }
  416. Buffer.compare = function compare (a, b) {
  417. if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)
  418. if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)
  419. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  420. throw new TypeError(
  421. 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
  422. )
  423. }
  424. if (a === b) return 0
  425. var x = a.length
  426. var y = b.length
  427. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  428. if (a[i] !== b[i]) {
  429. x = a[i]
  430. y = b[i]
  431. break
  432. }
  433. }
  434. if (x < y) return -1
  435. if (y < x) return 1
  436. return 0
  437. }
  438. Buffer.isEncoding = function isEncoding (encoding) {
  439. switch (String(encoding).toLowerCase()) {
  440. case 'hex':
  441. case 'utf8':
  442. case 'utf-8':
  443. case 'ascii':
  444. case 'latin1':
  445. case 'binary':
  446. case 'base64':
  447. case 'ucs2':
  448. case 'ucs-2':
  449. case 'utf16le':
  450. case 'utf-16le':
  451. return true
  452. default:
  453. return false
  454. }
  455. }
  456. Buffer.concat = function concat (list, length) {
  457. if (!Array.isArray(list)) {
  458. throw new TypeError('"list" argument must be an Array of Buffers')
  459. }
  460. if (list.length === 0) {
  461. return Buffer.alloc(0)
  462. }
  463. var i
  464. if (length === undefined) {
  465. length = 0
  466. for (i = 0; i < list.length; ++i) {
  467. length += list[i].length
  468. }
  469. }
  470. var buffer = Buffer.allocUnsafe(length)
  471. var pos = 0
  472. for (i = 0; i < list.length; ++i) {
  473. var buf = list[i]
  474. if (isInstance(buf, Uint8Array)) {
  475. buf = Buffer.from(buf)
  476. }
  477. if (!Buffer.isBuffer(buf)) {
  478. throw new TypeError('"list" argument must be an Array of Buffers')
  479. }
  480. buf.copy(buffer, pos)
  481. pos += buf.length
  482. }
  483. return buffer
  484. }
  485. function byteLength (string, encoding) {
  486. if (Buffer.isBuffer(string)) {
  487. return string.length
  488. }
  489. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  490. return string.byteLength
  491. }
  492. if (typeof string !== 'string') {
  493. throw new TypeError(
  494. 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  495. 'Received type ' + typeof string
  496. )
  497. }
  498. var len = string.length
  499. var mustMatch = (arguments.length > 2 && arguments[2] === true)
  500. if (!mustMatch && len === 0) return 0
  501. // Use a for loop to avoid recursion
  502. var loweredCase = false
  503. for (;;) {
  504. switch (encoding) {
  505. case 'ascii':
  506. case 'latin1':
  507. case 'binary':
  508. return len
  509. case 'utf8':
  510. case 'utf-8':
  511. return utf8ToBytes(string).length
  512. case 'ucs2':
  513. case 'ucs-2':
  514. case 'utf16le':
  515. case 'utf-16le':
  516. return len * 2
  517. case 'hex':
  518. return len >>> 1
  519. case 'base64':
  520. return base64ToBytes(string).length
  521. default:
  522. if (loweredCase) {
  523. return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
  524. }
  525. encoding = ('' + encoding).toLowerCase()
  526. loweredCase = true
  527. }
  528. }
  529. }
  530. Buffer.byteLength = byteLength
  531. function slowToString (encoding, start, end) {
  532. var loweredCase = false
  533. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  534. // property of a typed array.
  535. // This behaves neither like String nor Uint8Array in that we set start/end
  536. // to their upper/lower bounds if the value passed is out of range.
  537. // undefined is handled specially as per ECMA-262 6th Edition,
  538. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  539. if (start === undefined || start < 0) {
  540. start = 0
  541. }
  542. // Return early if start > this.length. Done here to prevent potential uint32
  543. // coercion fail below.
  544. if (start > this.length) {
  545. return ''
  546. }
  547. if (end === undefined || end > this.length) {
  548. end = this.length
  549. }
  550. if (end <= 0) {
  551. return ''
  552. }
  553. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  554. end >>>= 0
  555. start >>>= 0
  556. if (end <= start) {
  557. return ''
  558. }
  559. if (!encoding) encoding = 'utf8'
  560. while (true) {
  561. switch (encoding) {
  562. case 'hex':
  563. return hexSlice(this, start, end)
  564. case 'utf8':
  565. case 'utf-8':
  566. return utf8Slice(this, start, end)
  567. case 'ascii':
  568. return asciiSlice(this, start, end)
  569. case 'latin1':
  570. case 'binary':
  571. return latin1Slice(this, start, end)
  572. case 'base64':
  573. return base64Slice(this, start, end)
  574. case 'ucs2':
  575. case 'ucs-2':
  576. case 'utf16le':
  577. case 'utf-16le':
  578. return utf16leSlice(this, start, end)
  579. default:
  580. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  581. encoding = (encoding + '').toLowerCase()
  582. loweredCase = true
  583. }
  584. }
  585. }
  586. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  587. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  588. // reliably in a browserify context because there could be multiple different
  589. // copies of the 'buffer' package in use. This method works even for Buffer
  590. // instances that were created from another copy of the `buffer` package.
  591. // See: https://github.com/feross/buffer/issues/154
  592. Buffer.prototype._isBuffer = true
  593. function swap (b, n, m) {
  594. var i = b[n]
  595. b[n] = b[m]
  596. b[m] = i
  597. }
  598. Buffer.prototype.swap16 = function swap16 () {
  599. var len = this.length
  600. if (len % 2 !== 0) {
  601. throw new RangeError('Buffer size must be a multiple of 16-bits')
  602. }
  603. for (var i = 0; i < len; i += 2) {
  604. swap(this, i, i + 1)
  605. }
  606. return this
  607. }
  608. Buffer.prototype.swap32 = function swap32 () {
  609. var len = this.length
  610. if (len % 4 !== 0) {
  611. throw new RangeError('Buffer size must be a multiple of 32-bits')
  612. }
  613. for (var i = 0; i < len; i += 4) {
  614. swap(this, i, i + 3)
  615. swap(this, i + 1, i + 2)
  616. }
  617. return this
  618. }
  619. Buffer.prototype.swap64 = function swap64 () {
  620. var len = this.length
  621. if (len % 8 !== 0) {
  622. throw new RangeError('Buffer size must be a multiple of 64-bits')
  623. }
  624. for (var i = 0; i < len; i += 8) {
  625. swap(this, i, i + 7)
  626. swap(this, i + 1, i + 6)
  627. swap(this, i + 2, i + 5)
  628. swap(this, i + 3, i + 4)
  629. }
  630. return this
  631. }
  632. Buffer.prototype.toString = function toString () {
  633. var length = this.length
  634. if (length === 0) return ''
  635. if (arguments.length === 0) return utf8Slice(this, 0, length)
  636. return slowToString.apply(this, arguments)
  637. }
  638. Buffer.prototype.toLocaleString = Buffer.prototype.toString
  639. Buffer.prototype.equals = function equals (b) {
  640. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  641. if (this === b) return true
  642. return Buffer.compare(this, b) === 0
  643. }
  644. Buffer.prototype.inspect = function inspect () {
  645. var str = ''
  646. var max = exports.INSPECT_MAX_BYTES
  647. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()
  648. if (this.length > max) str += ' ... '
  649. return '<Buffer ' + str + '>'
  650. }
  651. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  652. if (isInstance(target, Uint8Array)) {
  653. target = Buffer.from(target, target.offset, target.byteLength)
  654. }
  655. if (!Buffer.isBuffer(target)) {
  656. throw new TypeError(
  657. 'The "target" argument must be one of type Buffer or Uint8Array. ' +
  658. 'Received type ' + (typeof target)
  659. )
  660. }
  661. if (start === undefined) {
  662. start = 0
  663. }
  664. if (end === undefined) {
  665. end = target ? target.length : 0
  666. }
  667. if (thisStart === undefined) {
  668. thisStart = 0
  669. }
  670. if (thisEnd === undefined) {
  671. thisEnd = this.length
  672. }
  673. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  674. throw new RangeError('out of range index')
  675. }
  676. if (thisStart >= thisEnd && start >= end) {
  677. return 0
  678. }
  679. if (thisStart >= thisEnd) {
  680. return -1
  681. }
  682. if (start >= end) {
  683. return 1
  684. }
  685. start >>>= 0
  686. end >>>= 0
  687. thisStart >>>= 0
  688. thisEnd >>>= 0
  689. if (this === target) return 0
  690. var x = thisEnd - thisStart
  691. var y = end - start
  692. var len = Math.min(x, y)
  693. var thisCopy = this.slice(thisStart, thisEnd)
  694. var targetCopy = target.slice(start, end)
  695. for (var i = 0; i < len; ++i) {
  696. if (thisCopy[i] !== targetCopy[i]) {
  697. x = thisCopy[i]
  698. y = targetCopy[i]
  699. break
  700. }
  701. }
  702. if (x < y) return -1
  703. if (y < x) return 1
  704. return 0
  705. }
  706. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  707. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  708. //
  709. // Arguments:
  710. // - buffer - a Buffer to search
  711. // - val - a string, Buffer, or number
  712. // - byteOffset - an index into `buffer`; will be clamped to an int32
  713. // - encoding - an optional encoding, relevant is val is a string
  714. // - dir - true for indexOf, false for lastIndexOf
  715. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  716. // Empty buffer means no match
  717. if (buffer.length === 0) return -1
  718. // Normalize byteOffset
  719. if (typeof byteOffset === 'string') {
  720. encoding = byteOffset
  721. byteOffset = 0
  722. } else if (byteOffset > 0x7fffffff) {
  723. byteOffset = 0x7fffffff
  724. } else if (byteOffset < -0x80000000) {
  725. byteOffset = -0x80000000
  726. }
  727. byteOffset = +byteOffset // Coerce to Number.
  728. if (numberIsNaN(byteOffset)) {
  729. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  730. byteOffset = dir ? 0 : (buffer.length - 1)
  731. }
  732. // Normalize byteOffset: negative offsets start from the end of the buffer
  733. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  734. if (byteOffset >= buffer.length) {
  735. if (dir) return -1
  736. else byteOffset = buffer.length - 1
  737. } else if (byteOffset < 0) {
  738. if (dir) byteOffset = 0
  739. else return -1
  740. }
  741. // Normalize val
  742. if (typeof val === 'string') {
  743. val = Buffer.from(val, encoding)
  744. }
  745. // Finally, search either indexOf (if dir is true) or lastIndexOf
  746. if (Buffer.isBuffer(val)) {
  747. // Special case: looking for empty string/buffer always fails
  748. if (val.length === 0) {
  749. return -1
  750. }
  751. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  752. } else if (typeof val === 'number') {
  753. val = val & 0xFF // Search for a byte value [0-255]
  754. if (typeof Uint8Array.prototype.indexOf === 'function') {
  755. if (dir) {
  756. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  757. } else {
  758. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  759. }
  760. }
  761. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  762. }
  763. throw new TypeError('val must be string, number or Buffer')
  764. }
  765. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  766. var indexSize = 1
  767. var arrLength = arr.length
  768. var valLength = val.length
  769. if (encoding !== undefined) {
  770. encoding = String(encoding).toLowerCase()
  771. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  772. encoding === 'utf16le' || encoding === 'utf-16le') {
  773. if (arr.length < 2 || val.length < 2) {
  774. return -1
  775. }
  776. indexSize = 2
  777. arrLength /= 2
  778. valLength /= 2
  779. byteOffset /= 2
  780. }
  781. }
  782. function read (buf, i) {
  783. if (indexSize === 1) {
  784. return buf[i]
  785. } else {
  786. return buf.readUInt16BE(i * indexSize)
  787. }
  788. }
  789. var i
  790. if (dir) {
  791. var foundIndex = -1
  792. for (i = byteOffset; i < arrLength; i++) {
  793. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  794. if (foundIndex === -1) foundIndex = i
  795. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  796. } else {
  797. if (foundIndex !== -1) i -= i - foundIndex
  798. foundIndex = -1
  799. }
  800. }
  801. } else {
  802. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  803. for (i = byteOffset; i >= 0; i--) {
  804. var found = true
  805. for (var j = 0; j < valLength; j++) {
  806. if (read(arr, i + j) !== read(val, j)) {
  807. found = false
  808. break
  809. }
  810. }
  811. if (found) return i
  812. }
  813. }
  814. return -1
  815. }
  816. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  817. return this.indexOf(val, byteOffset, encoding) !== -1
  818. }
  819. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  820. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  821. }
  822. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  823. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  824. }
  825. function hexWrite (buf, string, offset, length) {
  826. offset = Number(offset) || 0
  827. var remaining = buf.length - offset
  828. if (!length) {
  829. length = remaining
  830. } else {
  831. length = Number(length)
  832. if (length > remaining) {
  833. length = remaining
  834. }
  835. }
  836. var strLen = string.length
  837. if (length > strLen / 2) {
  838. length = strLen / 2
  839. }
  840. for (var i = 0; i < length; ++i) {
  841. var parsed = parseInt(string.substr(i * 2, 2), 16)
  842. if (numberIsNaN(parsed)) return i
  843. buf[offset + i] = parsed
  844. }
  845. return i
  846. }
  847. function utf8Write (buf, string, offset, length) {
  848. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  849. }
  850. function asciiWrite (buf, string, offset, length) {
  851. return blitBuffer(asciiToBytes(string), buf, offset, length)
  852. }
  853. function latin1Write (buf, string, offset, length) {
  854. return asciiWrite(buf, string, offset, length)
  855. }
  856. function base64Write (buf, string, offset, length) {
  857. return blitBuffer(base64ToBytes(string), buf, offset, length)
  858. }
  859. function ucs2Write (buf, string, offset, length) {
  860. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  861. }
  862. Buffer.prototype.write = function write (string, offset, length, encoding) {
  863. // Buffer#write(string)
  864. if (offset === undefined) {
  865. encoding = 'utf8'
  866. length = this.length
  867. offset = 0
  868. // Buffer#write(string, encoding)
  869. } else if (length === undefined && typeof offset === 'string') {
  870. encoding = offset
  871. length = this.length
  872. offset = 0
  873. // Buffer#write(string, offset[, length][, encoding])
  874. } else if (isFinite(offset)) {
  875. offset = offset >>> 0
  876. if (isFinite(length)) {
  877. length = length >>> 0
  878. if (encoding === undefined) encoding = 'utf8'
  879. } else {
  880. encoding = length
  881. length = undefined
  882. }
  883. } else {
  884. throw new Error(
  885. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  886. )
  887. }
  888. var remaining = this.length - offset
  889. if (length === undefined || length > remaining) length = remaining
  890. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  891. throw new RangeError('Attempt to write outside buffer bounds')
  892. }
  893. if (!encoding) encoding = 'utf8'
  894. var loweredCase = false
  895. for (;;) {
  896. switch (encoding) {
  897. case 'hex':
  898. return hexWrite(this, string, offset, length)
  899. case 'utf8':
  900. case 'utf-8':
  901. return utf8Write(this, string, offset, length)
  902. case 'ascii':
  903. return asciiWrite(this, string, offset, length)
  904. case 'latin1':
  905. case 'binary':
  906. return latin1Write(this, string, offset, length)
  907. case 'base64':
  908. // Warning: maxLength not taken into account in base64Write
  909. return base64Write(this, string, offset, length)
  910. case 'ucs2':
  911. case 'ucs-2':
  912. case 'utf16le':
  913. case 'utf-16le':
  914. return ucs2Write(this, string, offset, length)
  915. default:
  916. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  917. encoding = ('' + encoding).toLowerCase()
  918. loweredCase = true
  919. }
  920. }
  921. }
  922. Buffer.prototype.toJSON = function toJSON () {
  923. return {
  924. type: 'Buffer',
  925. data: Array.prototype.slice.call(this._arr || this, 0)
  926. }
  927. }
  928. function base64Slice (buf, start, end) {
  929. if (start === 0 && end === buf.length) {
  930. return base64.fromByteArray(buf)
  931. } else {
  932. return base64.fromByteArray(buf.slice(start, end))
  933. }
  934. }
  935. function utf8Slice (buf, start, end) {
  936. end = Math.min(buf.length, end)
  937. var res = []
  938. var i = start
  939. while (i < end) {
  940. var firstByte = buf[i]
  941. var codePoint = null
  942. var bytesPerSequence = (firstByte > 0xEF) ? 4
  943. : (firstByte > 0xDF) ? 3
  944. : (firstByte > 0xBF) ? 2
  945. : 1
  946. if (i + bytesPerSequence <= end) {
  947. var secondByte, thirdByte, fourthByte, tempCodePoint
  948. switch (bytesPerSequence) {
  949. case 1:
  950. if (firstByte < 0x80) {
  951. codePoint = firstByte
  952. }
  953. break
  954. case 2:
  955. secondByte = buf[i + 1]
  956. if ((secondByte & 0xC0) === 0x80) {
  957. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  958. if (tempCodePoint > 0x7F) {
  959. codePoint = tempCodePoint
  960. }
  961. }
  962. break
  963. case 3:
  964. secondByte = buf[i + 1]
  965. thirdByte = buf[i + 2]
  966. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  967. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  968. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  969. codePoint = tempCodePoint
  970. }
  971. }
  972. break
  973. case 4:
  974. secondByte = buf[i + 1]
  975. thirdByte = buf[i + 2]
  976. fourthByte = buf[i + 3]
  977. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  978. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  979. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  980. codePoint = tempCodePoint
  981. }
  982. }
  983. }
  984. }
  985. if (codePoint === null) {
  986. // we did not generate a valid codePoint so insert a
  987. // replacement char (U+FFFD) and advance only 1 byte
  988. codePoint = 0xFFFD
  989. bytesPerSequence = 1
  990. } else if (codePoint > 0xFFFF) {
  991. // encode to utf16 (surrogate pair dance)
  992. codePoint -= 0x10000
  993. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  994. codePoint = 0xDC00 | codePoint & 0x3FF
  995. }
  996. res.push(codePoint)
  997. i += bytesPerSequence
  998. }
  999. return decodeCodePointsArray(res)
  1000. }
  1001. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  1002. // the lowest limit is Chrome, with 0x10000 args.
  1003. // We go 1 magnitude less, for safety
  1004. var MAX_ARGUMENTS_LENGTH = 0x1000
  1005. function decodeCodePointsArray (codePoints) {
  1006. var len = codePoints.length
  1007. if (len <= MAX_ARGUMENTS_LENGTH) {
  1008. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  1009. }
  1010. // Decode in chunks to avoid "call stack size exceeded".
  1011. var res = ''
  1012. var i = 0
  1013. while (i < len) {
  1014. res += String.fromCharCode.apply(
  1015. String,
  1016. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  1017. )
  1018. }
  1019. return res
  1020. }
  1021. function asciiSlice (buf, start, end) {
  1022. var ret = ''
  1023. end = Math.min(buf.length, end)
  1024. for (var i = start; i < end; ++i) {
  1025. ret += String.fromCharCode(buf[i] & 0x7F)
  1026. }
  1027. return ret
  1028. }
  1029. function latin1Slice (buf, start, end) {
  1030. var ret = ''
  1031. end = Math.min(buf.length, end)
  1032. for (var i = start; i < end; ++i) {
  1033. ret += String.fromCharCode(buf[i])
  1034. }
  1035. return ret
  1036. }
  1037. function hexSlice (buf, start, end) {
  1038. var len = buf.length
  1039. if (!start || start < 0) start = 0
  1040. if (!end || end < 0 || end > len) end = len
  1041. var out = ''
  1042. for (var i = start; i < end; ++i) {
  1043. out += toHex(buf[i])
  1044. }
  1045. return out
  1046. }
  1047. function utf16leSlice (buf, start, end) {
  1048. var bytes = buf.slice(start, end)
  1049. var res = ''
  1050. for (var i = 0; i < bytes.length; i += 2) {
  1051. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))
  1052. }
  1053. return res
  1054. }
  1055. Buffer.prototype.slice = function slice (start, end) {
  1056. var len = this.length
  1057. start = ~~start
  1058. end = end === undefined ? len : ~~end
  1059. if (start < 0) {
  1060. start += len
  1061. if (start < 0) start = 0
  1062. } else if (start > len) {
  1063. start = len
  1064. }
  1065. if (end < 0) {
  1066. end += len
  1067. if (end < 0) end = 0
  1068. } else if (end > len) {
  1069. end = len
  1070. }
  1071. if (end < start) end = start
  1072. var newBuf = this.subarray(start, end)
  1073. // Return an augmented `Uint8Array` instance
  1074. newBuf.__proto__ = Buffer.prototype
  1075. return newBuf
  1076. }
  1077. /*
  1078. * Need to make sure that buffer isn't trying to write out of bounds.
  1079. */
  1080. function checkOffset (offset, ext, length) {
  1081. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  1082. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  1083. }
  1084. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  1085. offset = offset >>> 0
  1086. byteLength = byteLength >>> 0
  1087. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1088. var val = this[offset]
  1089. var mul = 1
  1090. var i = 0
  1091. while (++i < byteLength && (mul *= 0x100)) {
  1092. val += this[offset + i] * mul
  1093. }
  1094. return val
  1095. }
  1096. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  1097. offset = offset >>> 0
  1098. byteLength = byteLength >>> 0
  1099. if (!noAssert) {
  1100. checkOffset(offset, byteLength, this.length)
  1101. }
  1102. var val = this[offset + --byteLength]
  1103. var mul = 1
  1104. while (byteLength > 0 && (mul *= 0x100)) {
  1105. val += this[offset + --byteLength] * mul
  1106. }
  1107. return val
  1108. }
  1109. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  1110. offset = offset >>> 0
  1111. if (!noAssert) checkOffset(offset, 1, this.length)
  1112. return this[offset]
  1113. }
  1114. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  1115. offset = offset >>> 0
  1116. if (!noAssert) checkOffset(offset, 2, this.length)
  1117. return this[offset] | (this[offset + 1] << 8)
  1118. }
  1119. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  1120. offset = offset >>> 0
  1121. if (!noAssert) checkOffset(offset, 2, this.length)
  1122. return (this[offset] << 8) | this[offset + 1]
  1123. }
  1124. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  1125. offset = offset >>> 0
  1126. if (!noAssert) checkOffset(offset, 4, this.length)
  1127. return ((this[offset]) |
  1128. (this[offset + 1] << 8) |
  1129. (this[offset + 2] << 16)) +
  1130. (this[offset + 3] * 0x1000000)
  1131. }
  1132. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  1133. offset = offset >>> 0
  1134. if (!noAssert) checkOffset(offset, 4, this.length)
  1135. return (this[offset] * 0x1000000) +
  1136. ((this[offset + 1] << 16) |
  1137. (this[offset + 2] << 8) |
  1138. this[offset + 3])
  1139. }
  1140. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  1141. offset = offset >>> 0
  1142. byteLength = byteLength >>> 0
  1143. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1144. var val = this[offset]
  1145. var mul = 1
  1146. var i = 0
  1147. while (++i < byteLength && (mul *= 0x100)) {
  1148. val += this[offset + i] * mul
  1149. }
  1150. mul *= 0x80
  1151. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1152. return val
  1153. }
  1154. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  1155. offset = offset >>> 0
  1156. byteLength = byteLength >>> 0
  1157. if (!noAssert) checkOffset(offset, byteLength, this.length)
  1158. var i = byteLength
  1159. var mul = 1
  1160. var val = this[offset + --i]
  1161. while (i > 0 && (mul *= 0x100)) {
  1162. val += this[offset + --i] * mul
  1163. }
  1164. mul *= 0x80
  1165. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  1166. return val
  1167. }
  1168. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  1169. offset = offset >>> 0
  1170. if (!noAssert) checkOffset(offset, 1, this.length)
  1171. if (!(this[offset] & 0x80)) return (this[offset])
  1172. return ((0xff - this[offset] + 1) * -1)
  1173. }
  1174. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  1175. offset = offset >>> 0
  1176. if (!noAssert) checkOffset(offset, 2, this.length)
  1177. var val = this[offset] | (this[offset + 1] << 8)
  1178. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1179. }
  1180. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  1181. offset = offset >>> 0
  1182. if (!noAssert) checkOffset(offset, 2, this.length)
  1183. var val = this[offset + 1] | (this[offset] << 8)
  1184. return (val & 0x8000) ? val | 0xFFFF0000 : val
  1185. }
  1186. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  1187. offset = offset >>> 0
  1188. if (!noAssert) checkOffset(offset, 4, this.length)
  1189. return (this[offset]) |
  1190. (this[offset + 1] << 8) |
  1191. (this[offset + 2] << 16) |
  1192. (this[offset + 3] << 24)
  1193. }
  1194. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  1195. offset = offset >>> 0
  1196. if (!noAssert) checkOffset(offset, 4, this.length)
  1197. return (this[offset] << 24) |
  1198. (this[offset + 1] << 16) |
  1199. (this[offset + 2] << 8) |
  1200. (this[offset + 3])
  1201. }
  1202. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  1203. offset = offset >>> 0
  1204. if (!noAssert) checkOffset(offset, 4, this.length)
  1205. return ieee754.read(this, offset, true, 23, 4)
  1206. }
  1207. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  1208. offset = offset >>> 0
  1209. if (!noAssert) checkOffset(offset, 4, this.length)
  1210. return ieee754.read(this, offset, false, 23, 4)
  1211. }
  1212. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  1213. offset = offset >>> 0
  1214. if (!noAssert) checkOffset(offset, 8, this.length)
  1215. return ieee754.read(this, offset, true, 52, 8)
  1216. }
  1217. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  1218. offset = offset >>> 0
  1219. if (!noAssert) checkOffset(offset, 8, this.length)
  1220. return ieee754.read(this, offset, false, 52, 8)
  1221. }
  1222. function checkInt (buf, value, offset, ext, max, min) {
  1223. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  1224. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  1225. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1226. }
  1227. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  1228. value = +value
  1229. offset = offset >>> 0
  1230. byteLength = byteLength >>> 0
  1231. if (!noAssert) {
  1232. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1233. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1234. }
  1235. var mul = 1
  1236. var i = 0
  1237. this[offset] = value & 0xFF
  1238. while (++i < byteLength && (mul *= 0x100)) {
  1239. this[offset + i] = (value / mul) & 0xFF
  1240. }
  1241. return offset + byteLength
  1242. }
  1243. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  1244. value = +value
  1245. offset = offset >>> 0
  1246. byteLength = byteLength >>> 0
  1247. if (!noAssert) {
  1248. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  1249. checkInt(this, value, offset, byteLength, maxBytes, 0)
  1250. }
  1251. var i = byteLength - 1
  1252. var mul = 1
  1253. this[offset + i] = value & 0xFF
  1254. while (--i >= 0 && (mul *= 0x100)) {
  1255. this[offset + i] = (value / mul) & 0xFF
  1256. }
  1257. return offset + byteLength
  1258. }
  1259. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  1260. value = +value
  1261. offset = offset >>> 0
  1262. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  1263. this[offset] = (value & 0xff)
  1264. return offset + 1
  1265. }
  1266. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  1267. value = +value
  1268. offset = offset >>> 0
  1269. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1270. this[offset] = (value & 0xff)
  1271. this[offset + 1] = (value >>> 8)
  1272. return offset + 2
  1273. }
  1274. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  1275. value = +value
  1276. offset = offset >>> 0
  1277. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  1278. this[offset] = (value >>> 8)
  1279. this[offset + 1] = (value & 0xff)
  1280. return offset + 2
  1281. }
  1282. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  1283. value = +value
  1284. offset = offset >>> 0
  1285. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1286. this[offset + 3] = (value >>> 24)
  1287. this[offset + 2] = (value >>> 16)
  1288. this[offset + 1] = (value >>> 8)
  1289. this[offset] = (value & 0xff)
  1290. return offset + 4
  1291. }
  1292. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  1293. value = +value
  1294. offset = offset >>> 0
  1295. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  1296. this[offset] = (value >>> 24)
  1297. this[offset + 1] = (value >>> 16)
  1298. this[offset + 2] = (value >>> 8)
  1299. this[offset + 3] = (value & 0xff)
  1300. return offset + 4
  1301. }
  1302. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  1303. value = +value
  1304. offset = offset >>> 0
  1305. if (!noAssert) {
  1306. var limit = Math.pow(2, (8 * byteLength) - 1)
  1307. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1308. }
  1309. var i = 0
  1310. var mul = 1
  1311. var sub = 0
  1312. this[offset] = value & 0xFF
  1313. while (++i < byteLength && (mul *= 0x100)) {
  1314. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  1315. sub = 1
  1316. }
  1317. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1318. }
  1319. return offset + byteLength
  1320. }
  1321. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  1322. value = +value
  1323. offset = offset >>> 0
  1324. if (!noAssert) {
  1325. var limit = Math.pow(2, (8 * byteLength) - 1)
  1326. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  1327. }
  1328. var i = byteLength - 1
  1329. var mul = 1
  1330. var sub = 0
  1331. this[offset + i] = value & 0xFF
  1332. while (--i >= 0 && (mul *= 0x100)) {
  1333. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  1334. sub = 1
  1335. }
  1336. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  1337. }
  1338. return offset + byteLength
  1339. }
  1340. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  1341. value = +value
  1342. offset = offset >>> 0
  1343. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  1344. if (value < 0) value = 0xff + value + 1
  1345. this[offset] = (value & 0xff)
  1346. return offset + 1
  1347. }
  1348. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  1349. value = +value
  1350. offset = offset >>> 0
  1351. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1352. this[offset] = (value & 0xff)
  1353. this[offset + 1] = (value >>> 8)
  1354. return offset + 2
  1355. }
  1356. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  1357. value = +value
  1358. offset = offset >>> 0
  1359. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  1360. this[offset] = (value >>> 8)
  1361. this[offset + 1] = (value & 0xff)
  1362. return offset + 2
  1363. }
  1364. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  1365. value = +value
  1366. offset = offset >>> 0
  1367. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1368. this[offset] = (value & 0xff)
  1369. this[offset + 1] = (value >>> 8)
  1370. this[offset + 2] = (value >>> 16)
  1371. this[offset + 3] = (value >>> 24)
  1372. return offset + 4
  1373. }
  1374. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  1375. value = +value
  1376. offset = offset >>> 0
  1377. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  1378. if (value < 0) value = 0xffffffff + value + 1
  1379. this[offset] = (value >>> 24)
  1380. this[offset + 1] = (value >>> 16)
  1381. this[offset + 2] = (value >>> 8)
  1382. this[offset + 3] = (value & 0xff)
  1383. return offset + 4
  1384. }
  1385. function checkIEEE754 (buf, value, offset, ext, max, min) {
  1386. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  1387. if (offset < 0) throw new RangeError('Index out of range')
  1388. }
  1389. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  1390. value = +value
  1391. offset = offset >>> 0
  1392. if (!noAssert) {
  1393. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  1394. }
  1395. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  1396. return offset + 4
  1397. }
  1398. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  1399. return writeFloat(this, value, offset, true, noAssert)
  1400. }
  1401. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  1402. return writeFloat(this, value, offset, false, noAssert)
  1403. }
  1404. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  1405. value = +value
  1406. offset = offset >>> 0
  1407. if (!noAssert) {
  1408. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  1409. }
  1410. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  1411. return offset + 8
  1412. }
  1413. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  1414. return writeDouble(this, value, offset, true, noAssert)
  1415. }
  1416. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  1417. return writeDouble(this, value, offset, false, noAssert)
  1418. }
  1419. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  1420. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  1421. if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
  1422. if (!start) start = 0
  1423. if (!end && end !== 0) end = this.length
  1424. if (targetStart >= target.length) targetStart = target.length
  1425. if (!targetStart) targetStart = 0
  1426. if (end > 0 && end < start) end = start
  1427. // Copy 0 bytes; we're done
  1428. if (end === start) return 0
  1429. if (target.length === 0 || this.length === 0) return 0
  1430. // Fatal error conditions
  1431. if (targetStart < 0) {
  1432. throw new RangeError('targetStart out of bounds')
  1433. }
  1434. if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
  1435. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  1436. // Are we oob?
  1437. if (end > this.length) end = this.length
  1438. if (target.length - targetStart < end - start) {
  1439. end = target.length - targetStart + start
  1440. }
  1441. var len = end - start
  1442. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  1443. // Use built-in when available, missing from IE11
  1444. this.copyWithin(targetStart, start, end)
  1445. } else if (this === target && start < targetStart && targetStart < end) {
  1446. // descending copy from end
  1447. for (var i = len - 1; i >= 0; --i) {
  1448. target[i + targetStart] = this[i + start]
  1449. }
  1450. } else {
  1451. Uint8Array.prototype.set.call(
  1452. target,
  1453. this.subarray(start, end),
  1454. targetStart
  1455. )
  1456. }
  1457. return len
  1458. }
  1459. // Usage:
  1460. // buffer.fill(number[, offset[, end]])
  1461. // buffer.fill(buffer[, offset[, end]])
  1462. // buffer.fill(string[, offset[, end]][, encoding])
  1463. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  1464. // Handle string cases:
  1465. if (typeof val === 'string') {
  1466. if (typeof start === 'string') {
  1467. encoding = start
  1468. start = 0
  1469. end = this.length
  1470. } else if (typeof end === 'string') {
  1471. encoding = end
  1472. end = this.length
  1473. }
  1474. if (encoding !== undefined && typeof encoding !== 'string') {
  1475. throw new TypeError('encoding must be a string')
  1476. }
  1477. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  1478. throw new TypeError('Unknown encoding: ' + encoding)
  1479. }
  1480. if (val.length === 1) {
  1481. var code = val.charCodeAt(0)
  1482. if ((encoding === 'utf8' && code < 128) ||
  1483. encoding === 'latin1') {
  1484. // Fast path: If `val` fits into a single byte, use that numeric value.
  1485. val = code
  1486. }
  1487. }
  1488. } else if (typeof val === 'number') {
  1489. val = val & 255
  1490. }
  1491. // Invalid ranges are not set to a default, so can range check early.
  1492. if (start < 0 || this.length < start || this.length < end) {
  1493. throw new RangeError('Out of range index')
  1494. }
  1495. if (end <= start) {
  1496. return this
  1497. }
  1498. start = start >>> 0
  1499. end = end === undefined ? this.length : end >>> 0
  1500. if (!val) val = 0
  1501. var i
  1502. if (typeof val === 'number') {
  1503. for (i = start; i < end; ++i) {
  1504. this[i] = val
  1505. }
  1506. } else {
  1507. var bytes = Buffer.isBuffer(val)
  1508. ? val
  1509. : Buffer.from(val, encoding)
  1510. var len = bytes.length
  1511. if (len === 0) {
  1512. throw new TypeError('The value "' + val +
  1513. '" is invalid for argument "value"')
  1514. }
  1515. for (i = 0; i < end - start; ++i) {
  1516. this[i + start] = bytes[i % len]
  1517. }
  1518. }
  1519. return this
  1520. }
  1521. // HELPER FUNCTIONS
  1522. // ================
  1523. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g
  1524. function base64clean (str) {
  1525. // Node takes equal signs as end of the Base64 encoding
  1526. str = str.split('=')[0]
  1527. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  1528. str = str.trim().replace(INVALID_BASE64_RE, '')
  1529. // Node converts strings with length < 2 to ''
  1530. if (str.length < 2) return ''
  1531. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  1532. while (str.length % 4 !== 0) {
  1533. str = str + '='
  1534. }
  1535. return str
  1536. }
  1537. function toHex (n) {
  1538. if (n < 16) return '0' + n.toString(16)
  1539. return n.toString(16)
  1540. }
  1541. function utf8ToBytes (string, units) {
  1542. units = units || Infinity
  1543. var codePoint
  1544. var length = string.length
  1545. var leadSurrogate = null
  1546. var bytes = []
  1547. for (var i = 0; i < length; ++i) {
  1548. codePoint = string.charCodeAt(i)
  1549. // is surrogate component
  1550. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  1551. // last char was a lead
  1552. if (!leadSurrogate) {
  1553. // no lead yet
  1554. if (codePoint > 0xDBFF) {
  1555. // unexpected trail
  1556. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1557. continue
  1558. } else if (i + 1 === length) {
  1559. // unpaired lead
  1560. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1561. continue
  1562. }
  1563. // valid lead
  1564. leadSurrogate = codePoint
  1565. continue
  1566. }
  1567. // 2 leads in a row
  1568. if (codePoint < 0xDC00) {
  1569. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1570. leadSurrogate = codePoint
  1571. continue
  1572. }
  1573. // valid surrogate pair
  1574. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  1575. } else if (leadSurrogate) {
  1576. // valid bmp char, but last char was a lead
  1577. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  1578. }
  1579. leadSurrogate = null
  1580. // encode utf8
  1581. if (codePoint < 0x80) {
  1582. if ((units -= 1) < 0) break
  1583. bytes.push(codePoint)
  1584. } else if (codePoint < 0x800) {
  1585. if ((units -= 2) < 0) break
  1586. bytes.push(
  1587. codePoint >> 0x6 | 0xC0,
  1588. codePoint & 0x3F | 0x80
  1589. )
  1590. } else if (codePoint < 0x10000) {
  1591. if ((units -= 3) < 0) break
  1592. bytes.push(
  1593. codePoint >> 0xC | 0xE0,
  1594. codePoint >> 0x6 & 0x3F | 0x80,
  1595. codePoint & 0x3F | 0x80
  1596. )
  1597. } else if (codePoint < 0x110000) {
  1598. if ((units -= 4) < 0) break
  1599. bytes.push(
  1600. codePoint >> 0x12 | 0xF0,
  1601. codePoint >> 0xC & 0x3F | 0x80,
  1602. codePoint >> 0x6 & 0x3F | 0x80,
  1603. codePoint & 0x3F | 0x80
  1604. )
  1605. } else {
  1606. throw new Error('Invalid code point')
  1607. }
  1608. }
  1609. return bytes
  1610. }
  1611. function asciiToBytes (str) {
  1612. var byteArray = []
  1613. for (var i = 0; i < str.length; ++i) {
  1614. // Node's code seems to be doing this and not & 0x7F..
  1615. byteArray.push(str.charCodeAt(i) & 0xFF)
  1616. }
  1617. return byteArray
  1618. }
  1619. function utf16leToBytes (str, units) {
  1620. var c, hi, lo
  1621. var byteArray = []
  1622. for (var i = 0; i < str.length; ++i) {
  1623. if ((units -= 2) < 0) break
  1624. c = str.charCodeAt(i)
  1625. hi = c >> 8
  1626. lo = c % 256
  1627. byteArray.push(lo)
  1628. byteArray.push(hi)
  1629. }
  1630. return byteArray
  1631. }
  1632. function base64ToBytes (str) {
  1633. return base64.toByteArray(base64clean(str))
  1634. }
  1635. function blitBuffer (src, dst, offset, length) {
  1636. for (var i = 0; i < length; ++i) {
  1637. if ((i + offset >= dst.length) || (i >= src.length)) break
  1638. dst[i + offset] = src[i]
  1639. }
  1640. return i
  1641. }
  1642. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  1643. // the `instanceof` check but they should be treated as of that type.
  1644. // See: https://github.com/feross/buffer/issues/166
  1645. function isInstance (obj, type) {
  1646. return obj instanceof type ||
  1647. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  1648. obj.constructor.name === type.name)
  1649. }
  1650. function numberIsNaN (obj) {
  1651. // For IE11 support
  1652. return obj !== obj // eslint-disable-line no-self-compare
  1653. }
  1654. }).call(this,require("buffer").Buffer)
  1655. },{"base64-js":1,"buffer":2,"ieee754":3}],3:[function(require,module,exports){
  1656. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  1657. var e, m
  1658. var eLen = (nBytes * 8) - mLen - 1
  1659. var eMax = (1 << eLen) - 1
  1660. var eBias = eMax >> 1
  1661. var nBits = -7
  1662. var i = isLE ? (nBytes - 1) : 0
  1663. var d = isLE ? -1 : 1
  1664. var s = buffer[offset + i]
  1665. i += d
  1666. e = s & ((1 << (-nBits)) - 1)
  1667. s >>= (-nBits)
  1668. nBits += eLen
  1669. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1670. m = e & ((1 << (-nBits)) - 1)
  1671. e >>= (-nBits)
  1672. nBits += mLen
  1673. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  1674. if (e === 0) {
  1675. e = 1 - eBias
  1676. } else if (e === eMax) {
  1677. return m ? NaN : ((s ? -1 : 1) * Infinity)
  1678. } else {
  1679. m = m + Math.pow(2, mLen)
  1680. e = e - eBias
  1681. }
  1682. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  1683. }
  1684. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  1685. var e, m, c
  1686. var eLen = (nBytes * 8) - mLen - 1
  1687. var eMax = (1 << eLen) - 1
  1688. var eBias = eMax >> 1
  1689. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  1690. var i = isLE ? 0 : (nBytes - 1)
  1691. var d = isLE ? 1 : -1
  1692. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  1693. value = Math.abs(value)
  1694. if (isNaN(value) || value === Infinity) {
  1695. m = isNaN(value) ? 1 : 0
  1696. e = eMax
  1697. } else {
  1698. e = Math.floor(Math.log(value) / Math.LN2)
  1699. if (value * (c = Math.pow(2, -e)) < 1) {
  1700. e--
  1701. c *= 2
  1702. }
  1703. if (e + eBias >= 1) {
  1704. value += rt / c
  1705. } else {
  1706. value += rt * Math.pow(2, 1 - eBias)
  1707. }
  1708. if (value * c >= 2) {
  1709. e++
  1710. c /= 2
  1711. }
  1712. if (e + eBias >= eMax) {
  1713. m = 0
  1714. e = eMax
  1715. } else if (e + eBias >= 1) {
  1716. m = ((value * c) - 1) * Math.pow(2, mLen)
  1717. e = e + eBias
  1718. } else {
  1719. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  1720. e = 0
  1721. }
  1722. }
  1723. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  1724. e = (e << mLen) | m
  1725. eLen += mLen
  1726. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  1727. buffer[offset + i - d] |= s * 128
  1728. }
  1729. },{}],4:[function(require,module,exports){
  1730. "use strict";
  1731. var __assign = (this && this.__assign) || function () {
  1732. __assign = Object.assign || function(t) {
  1733. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1734. s = arguments[i];
  1735. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  1736. t[p] = s[p];
  1737. }
  1738. return t;
  1739. };
  1740. return __assign.apply(this, arguments);
  1741. };
  1742. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1743. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1744. return new (P || (P = Promise))(function (resolve, reject) {
  1745. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1746. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1747. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1748. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1749. });
  1750. };
  1751. var __generator = (this && this.__generator) || function (thisArg, body) {
  1752. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1753. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1754. function verb(n) { return function (v) { return step([n, v]); }; }
  1755. function step(op) {
  1756. if (f) throw new TypeError("Generator is already executing.");
  1757. while (_) try {
  1758. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1759. if (y = 0, t) op = [op[0] & 2, t.value];
  1760. switch (op[0]) {
  1761. case 0: case 1: t = op; break;
  1762. case 4: _.label++; return { value: op[1], done: false };
  1763. case 5: _.label++; y = op[1]; op = [0]; continue;
  1764. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1765. default:
  1766. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1767. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1768. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1769. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1770. if (t[2]) _.ops.pop();
  1771. _.trys.pop(); continue;
  1772. }
  1773. op = body.call(thisArg, _);
  1774. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1775. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1776. }
  1777. };
  1778. Object.defineProperty(exports, "__esModule", { value: true });
  1779. exports.HubControl = void 0;
  1780. var manual_1 = require("./states/manual");
  1781. var ai_1 = require("./states/ai");
  1782. var HubControl = /** @class */ (function () {
  1783. function HubControl(deviceInfo, controlData, configuration) {
  1784. this.hub = null;
  1785. this.device = deviceInfo;
  1786. this.control = controlData;
  1787. this.configuration = configuration;
  1788. this.prevControl = __assign({}, this.control);
  1789. this.states = {
  1790. Turn: ai_1.turn,
  1791. Drive: ai_1.drive,
  1792. Stop: ai_1.stop,
  1793. Back: ai_1.back,
  1794. Manual: manual_1.manual,
  1795. Seek: ai_1.seek,
  1796. };
  1797. this.currentState = this.states['Manual'];
  1798. }
  1799. HubControl.prototype.updateConfiguration = function (configuration) {
  1800. this.configuration = configuration;
  1801. };
  1802. HubControl.prototype.start = function (hub) {
  1803. return __awaiter(this, void 0, void 0, function () {
  1804. var _this = this;
  1805. return __generator(this, function (_a) {
  1806. switch (_a.label) {
  1807. case 0:
  1808. this.hub = hub;
  1809. this.device.connected = true;
  1810. this.hub.emitter.on('error', function (err) {
  1811. _this.device.err = err;
  1812. });
  1813. this.hub.emitter.on('disconnect', function () {
  1814. _this.device.connected = false;
  1815. });
  1816. this.hub.emitter.on('distance', function (distance) {
  1817. _this.device.distance = distance;
  1818. });
  1819. this.hub.emitter.on('rssi', function (rssi) {
  1820. _this.device.rssi = rssi;
  1821. });
  1822. this.hub.emitter.on('port', function (portObject) {
  1823. var port = portObject.port, action = portObject.action;
  1824. _this.device.ports[port].action = action;
  1825. });
  1826. this.hub.emitter.on('color', function (color) {
  1827. _this.device.color = color;
  1828. });
  1829. this.hub.emitter.on('tilt', function (tilt) {
  1830. var roll = tilt.roll, pitch = tilt.pitch;
  1831. _this.device.tilt.roll = roll;
  1832. _this.device.tilt.pitch = pitch;
  1833. });
  1834. this.hub.emitter.on('rotation', function (rotation) {
  1835. var port = rotation.port, angle = rotation.angle;
  1836. _this.device.ports[port].angle = angle;
  1837. });
  1838. return [4 /*yield*/, this.hub.ledAsync('red')];
  1839. case 1:
  1840. _a.sent();
  1841. return [4 /*yield*/, this.hub.ledAsync('yellow')];
  1842. case 2:
  1843. _a.sent();
  1844. return [4 /*yield*/, this.hub.ledAsync('green')];
  1845. case 3:
  1846. _a.sent();
  1847. return [2 /*return*/];
  1848. }
  1849. });
  1850. });
  1851. };
  1852. HubControl.prototype.disconnect = function () {
  1853. return __awaiter(this, void 0, void 0, function () {
  1854. return __generator(this, function (_a) {
  1855. switch (_a.label) {
  1856. case 0:
  1857. if (!this.device.connected) return [3 /*break*/, 2];
  1858. return [4 /*yield*/, this.hub.disconnectAsync()];
  1859. case 1:
  1860. _a.sent();
  1861. _a.label = 2;
  1862. case 2: return [2 /*return*/];
  1863. }
  1864. });
  1865. });
  1866. };
  1867. HubControl.prototype.setNextState = function (state) {
  1868. this.control.controlUpdateTime = undefined;
  1869. this.control.state = state;
  1870. this.currentState = this.states[state];
  1871. };
  1872. HubControl.prototype.update = function () {
  1873. // TODO: After removing bind, this requires some more refactoring
  1874. this.currentState(this);
  1875. // TODO: Deep clone
  1876. this.prevControl = __assign({}, this.control);
  1877. this.prevControl.tilt = __assign({}, this.control.tilt);
  1878. this.prevDevice = __assign({}, this.device);
  1879. };
  1880. return HubControl;
  1881. }());
  1882. exports.HubControl = HubControl;
  1883. },{"./states/ai":5,"./states/manual":6}],5:[function(require,module,exports){
  1884. "use strict";
  1885. Object.defineProperty(exports, "__esModule", { value: true });
  1886. exports.seek = exports.turn = exports.drive = exports.back = exports.stop = void 0;
  1887. var MIN_DISTANCE = 75;
  1888. var OK_DISTANCE = 100;
  1889. var EXECUTE_TIME_SEC = 60;
  1890. var CHECK_TIME_MS = 59000;
  1891. // Speeds must be between -100 and 100
  1892. var TURN_SPEED = 30;
  1893. var TURN_SPEED_OPPOSITE = -10;
  1894. var DRIVE_SPEED = 30;
  1895. var REVERSE_SPEED = -15;
  1896. var seek = function (hubControl) {
  1897. if (!hubControl.control.controlUpdateTime || Date.now() - hubControl.control.controlUpdateTime > CHECK_TIME_MS) {
  1898. hubControl.control.controlUpdateTime = Date.now();
  1899. hubControl.hub.motorTimeMulti(EXECUTE_TIME_SEC, TURN_SPEED, TURN_SPEED_OPPOSITE);
  1900. }
  1901. if (Date.now() - hubControl.control.controlUpdateTime < 250)
  1902. return;
  1903. if (hubControl.device.distance > hubControl.prevDevice.distance) {
  1904. hubControl.control.turnDirection = 'right';
  1905. hubControl.setNextState('Turn');
  1906. }
  1907. else {
  1908. hubControl.control.turnDirection = 'left';
  1909. hubControl.setNextState('Turn');
  1910. }
  1911. };
  1912. exports.seek = seek;
  1913. var turn = function (hubControl) {
  1914. if (hubControl.device.distance < MIN_DISTANCE) {
  1915. hubControl.control.turnDirection = null;
  1916. hubControl.setNextState('Back');
  1917. return;
  1918. }
  1919. else if (hubControl.device.distance > OK_DISTANCE) {
  1920. hubControl.control.turnDirection = null;
  1921. hubControl.setNextState('Drive');
  1922. return;
  1923. }
  1924. if (!hubControl.control.controlUpdateTime || Date.now() - hubControl.control.controlUpdateTime > CHECK_TIME_MS) {
  1925. var motorA = hubControl.control.turnDirection === 'right' ? TURN_SPEED : TURN_SPEED_OPPOSITE;
  1926. var motorB = hubControl.control.turnDirection === 'right' ? TURN_SPEED_OPPOSITE : TURN_SPEED;
  1927. hubControl.control.controlUpdateTime = Date.now();
  1928. hubControl.hub.motorTimeMulti(EXECUTE_TIME_SEC, motorA, motorB);
  1929. }
  1930. };
  1931. exports.turn = turn;
  1932. var drive = function (hubControl) {
  1933. if (hubControl.device.distance < MIN_DISTANCE) {
  1934. hubControl.setNextState('Back');
  1935. return;
  1936. }
  1937. else if (hubControl.device.distance < OK_DISTANCE) {
  1938. hubControl.setNextState('Seek');
  1939. return;
  1940. }
  1941. if (!hubControl.control.controlUpdateTime || Date.now() - hubControl.control.controlUpdateTime > CHECK_TIME_MS) {
  1942. hubControl.control.controlUpdateTime = Date.now();
  1943. var speed = hubControl.configuration.leftMotor === 'A' ? DRIVE_SPEED : DRIVE_SPEED * -1;
  1944. hubControl.hub.motorTimeMulti(EXECUTE_TIME_SEC, speed, speed);
  1945. }
  1946. };
  1947. exports.drive = drive;
  1948. var back = function (hubControl) {
  1949. if (hubControl.device.distance > OK_DISTANCE) {
  1950. hubControl.setNextState('Seek');
  1951. return;
  1952. }
  1953. if (!hubControl.control.controlUpdateTime || Date.now() - hubControl.control.controlUpdateTime > CHECK_TIME_MS) {
  1954. hubControl.control.controlUpdateTime = Date.now();
  1955. var speed = hubControl.configuration.leftMotor === 'A' ? REVERSE_SPEED : REVERSE_SPEED * -1;
  1956. hubControl.hub.motorTimeMulti(EXECUTE_TIME_SEC, speed, speed);
  1957. }
  1958. };
  1959. exports.back = back;
  1960. var stop = function (hubControl) {
  1961. hubControl.control.speed = 0;
  1962. hubControl.control.turnAngle = 0;
  1963. if (!hubControl.control.controlUpdateTime || Date.now() - hubControl.control.controlUpdateTime > CHECK_TIME_MS) {
  1964. hubControl.control.controlUpdateTime = Date.now();
  1965. hubControl.hub.motorTimeMulti(EXECUTE_TIME_SEC, 0, 0);
  1966. }
  1967. };
  1968. exports.stop = stop;
  1969. },{}],6:[function(require,module,exports){
  1970. "use strict";
  1971. Object.defineProperty(exports, "__esModule", { value: true });
  1972. exports.manual = void 0;
  1973. function manual(hubControl) {
  1974. if (hubControl.control.speed !== hubControl.prevControl.speed || hubControl.control.turnAngle !== hubControl.prevControl.turnAngle) {
  1975. var motorA = hubControl.control.speed + (hubControl.control.turnAngle > 0 ? Math.abs(hubControl.control.turnAngle) : 0);
  1976. var motorB = hubControl.control.speed + (hubControl.control.turnAngle < 0 ? Math.abs(hubControl.control.turnAngle) : 0);
  1977. if (motorA > 100) {
  1978. motorB -= motorA - 100;
  1979. motorA = 100;
  1980. }
  1981. if (motorB > 100) {
  1982. motorA -= motorB - 100;
  1983. motorB = 100;
  1984. }
  1985. hubControl.control.motorA = motorA;
  1986. hubControl.control.motorB = motorB;
  1987. hubControl.hub.motorTimeMulti(60, motorA, motorB);
  1988. }
  1989. if (hubControl.control.tilt.pitch !== hubControl.prevControl.tilt.pitch) {
  1990. hubControl.hub.motorTime('C', 60, hubControl.control.tilt.pitch);
  1991. }
  1992. if (hubControl.control.tilt.roll !== hubControl.prevControl.tilt.roll) {
  1993. hubControl.hub.motorTime('D', 60, hubControl.control.tilt.roll);
  1994. }
  1995. }
  1996. exports.manual = manual;
  1997. },{}],7:[function(require,module,exports){
  1998. "use strict";
  1999. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2000. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2001. return new (P || (P = Promise))(function (resolve, reject) {
  2002. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2003. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2004. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2005. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2006. });
  2007. };
  2008. var __generator = (this && this.__generator) || function (thisArg, body) {
  2009. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2010. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2011. function verb(n) { return function (v) { return step([n, v]); }; }
  2012. function step(op) {
  2013. if (f) throw new TypeError("Generator is already executing.");
  2014. while (_) try {
  2015. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  2016. if (y = 0, t) op = [op[0] & 2, t.value];
  2017. switch (op[0]) {
  2018. case 0: case 1: t = op; break;
  2019. case 4: _.label++; return { value: op[1], done: false };
  2020. case 5: _.label++; y = op[1]; op = [0]; continue;
  2021. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2022. default:
  2023. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  2024. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  2025. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  2026. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  2027. if (t[2]) _.ops.pop();
  2028. _.trys.pop(); continue;
  2029. }
  2030. op = body.call(thisArg, _);
  2031. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  2032. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  2033. }
  2034. };
  2035. Object.defineProperty(exports, "__esModule", { value: true });
  2036. exports.BoostConnector = void 0;
  2037. var BOOST_HUB_SERVICE_UUID = '00001623-1212-efde-1623-785feabcd123';
  2038. var BOOST_CHARACTERISTIC_UUID = '00001624-1212-efde-1623-785feabcd123';
  2039. var BoostConnector = /** @class */ (function () {
  2040. function BoostConnector() {
  2041. }
  2042. BoostConnector.connect = function (disconnectCallback) {
  2043. return __awaiter(this, void 0, void 0, function () {
  2044. var options, _a;
  2045. var _this = this;
  2046. return __generator(this, function (_b) {
  2047. switch (_b.label) {
  2048. case 0:
  2049. options = {
  2050. acceptAllDevices: false,
  2051. filters: [{ services: [BOOST_HUB_SERVICE_UUID] }],
  2052. optionalServices: [BOOST_HUB_SERVICE_UUID],
  2053. };
  2054. _a = this;
  2055. return [4 /*yield*/, navigator.bluetooth.requestDevice(options)];
  2056. case 1:
  2057. _a.device = _b.sent();
  2058. this.device.addEventListener('gattserverdisconnected', function (event) { return __awaiter(_this, void 0, void 0, function () {
  2059. return __generator(this, function (_a) {
  2060. switch (_a.label) {
  2061. case 0: return [4 /*yield*/, disconnectCallback()];
  2062. case 1:
  2063. _a.sent();
  2064. return [2 /*return*/];
  2065. }
  2066. });
  2067. }); });
  2068. // await this.device.watchAdvertisements();
  2069. // this.device.addEventListener('advertisementreceived', event => {
  2070. // // @ts-ignore
  2071. // console.log(event.rssi);
  2072. // });
  2073. return [2 /*return*/, BoostConnector.getCharacteristic(this.device)];
  2074. }
  2075. });
  2076. });
  2077. };
  2078. BoostConnector.getCharacteristic = function (device) {
  2079. return __awaiter(this, void 0, void 0, function () {
  2080. var server, service;
  2081. return __generator(this, function (_a) {
  2082. switch (_a.label) {
  2083. case 0: return [4 /*yield*/, device.gatt.connect()];
  2084. case 1:
  2085. server = _a.sent();
  2086. return [4 /*yield*/, server.getPrimaryService(BOOST_HUB_SERVICE_UUID)];
  2087. case 2:
  2088. service = _a.sent();
  2089. return [4 /*yield*/, service.getCharacteristic(BOOST_CHARACTERISTIC_UUID)];
  2090. case 3: return [2 /*return*/, _a.sent()];
  2091. }
  2092. });
  2093. });
  2094. };
  2095. BoostConnector.reconnect = function () {
  2096. return __awaiter(this, void 0, void 0, function () {
  2097. var bluetooth;
  2098. return __generator(this, function (_a) {
  2099. switch (_a.label) {
  2100. case 0:
  2101. if (!this.device) return [3 /*break*/, 2];
  2102. return [4 /*yield*/, BoostConnector.getCharacteristic(this.device)];
  2103. case 1:
  2104. bluetooth = _a.sent();
  2105. return [2 /*return*/, [true, bluetooth]];
  2106. case 2: return [2 /*return*/, [false, null]];
  2107. }
  2108. });
  2109. });
  2110. };
  2111. BoostConnector.disconnect = function () {
  2112. if (this.device) {
  2113. this.device.gatt.disconnect();
  2114. return true;
  2115. }
  2116. return false;
  2117. };
  2118. BoostConnector.isWebBluetoothSupported = navigator.bluetooth ? true : false;
  2119. return BoostConnector;
  2120. }());
  2121. exports.BoostConnector = BoostConnector;
  2122. },{}],8:[function(require,module,exports){
  2123. "use strict";
  2124. Object.defineProperty(exports, "__esModule", { value: true });
  2125. var legoBoost_1 = require("./legoBoost");
  2126. var boostConnector_1 = require("./boostConnector");
  2127. var boost = new legoBoost_1.default();
  2128. // @ts-ignore
  2129. boost.logDebug = console.log;
  2130. // Add as a window globals, so these can be called from HTML
  2131. // @ts-ignore
  2132. window.isWebBluetoothSupported = boostConnector_1.BoostConnector.isWebBluetoothSupported;
  2133. ///livecoding.space mode
  2134. window._LegoBoost = boost
  2135. // @ts-ignore
  2136. window.connect = boost.connect.bind(boost);
  2137. // @ts-ignore
  2138. window.led = boost.changeLed.bind(boost);
  2139. // @ts-ignore
  2140. window.drive = boost.drive.bind(boost, 50);
  2141. // @ts-ignore
  2142. window.disconnect = boost.disconnect.bind(boost);
  2143. // @ts-ignore
  2144. window.ai = boost.ai.bind(boost);
  2145. // @ts-ignore
  2146. window.stop = boost.stop.bind(boost);
  2147. // @ts-ignore
  2148. window.turnLeft = boost.turn.bind(boost, 90 * 400);
  2149. // @ts-ignore
  2150. window.turnRight = boost.turn.bind(boost, 90 * 400 * -1);
  2151. // @ts-ignore
  2152. window.driveForward = boost.driveToDirection.bind(boost);
  2153. // @ts-ignore
  2154. window.driveBackward = boost.driveToDirection.bind(boost, -1);
  2155. // @ts-ignore
  2156. window.turnAPositive = boost.motorAngle.bind(boost, 'A', 3600, 10);
  2157. // @ts-ignore
  2158. window.turnANegative = boost.motorAngle.bind(boost, 'A', 3600, -10);
  2159. // @ts-ignore
  2160. window.rawCommand = boost.rawCommand.bind(boost, {
  2161. 0: 0x08,
  2162. 1: 0x00,
  2163. 2: 0x81,
  2164. 3: 0x32,
  2165. 4: 0x11,
  2166. 5: 0x51,
  2167. 6: 0x00,
  2168. 7: 0x02,
  2169. 8: 0x00,
  2170. 9: 0x00,
  2171. 10: 0x00,
  2172. 11: 0x00,
  2173. 12: 0x00,
  2174. 13: 0x00,
  2175. 14: 0x00,
  2176. });
  2177. },{"./boostConnector":7,"./legoBoost":13}],9:[function(require,module,exports){
  2178. (function (Buffer){
  2179. /*!
  2180. * The buffer module from node.js, for the browser.
  2181. *
  2182. * @author Feross Aboukhadijeh <https://feross.org>
  2183. * @license MIT
  2184. */
  2185. /* eslint-disable no-proto */
  2186. 'use strict';
  2187. Object.defineProperty(exports, "__esModule", { value: true });
  2188. exports.kMaxLength = exports.INSPECT_MAX_BYTES = exports.SlowBuffer = exports.Buffer = void 0;
  2189. var base64 = Promise.resolve().then(function () { return require('base64-js'); });
  2190. var ieee754 = Promise.resolve().then(function () { return require('ieee754'); });
  2191. var INSPECT_MAX_BYTES = 50;
  2192. exports.INSPECT_MAX_BYTES = INSPECT_MAX_BYTES;
  2193. var K_MAX_LENGTH = 0x7fffffff;
  2194. var kMaxLength = K_MAX_LENGTH;
  2195. exports.kMaxLength = kMaxLength;
  2196. /**
  2197. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  2198. * === true Use Uint8Array implementation (fastest)
  2199. * === false Print warning and recommend using `buffer` v4.x which has an Object
  2200. * implementation (most compatible, even IE6)
  2201. *
  2202. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  2203. * Opera 11.6+, iOS 4.2+.
  2204. *
  2205. * We report that the browser does not support typed arrays if the are not subclassable
  2206. * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
  2207. * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
  2208. * for __proto__ and has a buggy typed array implementation.
  2209. */
  2210. Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
  2211. if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
  2212. typeof console.error === 'function') {
  2213. console.error('This browser lacks typed array (Uint8Array) support which is required by ' +
  2214. '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.');
  2215. }
  2216. function typedArraySupport() {
  2217. // Can typed array instances can be augmented?
  2218. try {
  2219. var arr = new Uint8Array(1);
  2220. // @ts-ignore
  2221. arr.__proto__ = { __proto__: Uint8Array.prototype, foo: function () { return 42; } };
  2222. // @ts-ignore
  2223. return arr.foo() === 42;
  2224. }
  2225. catch (e) {
  2226. return false;
  2227. }
  2228. }
  2229. Object.defineProperty(Buffer.prototype, 'parent', {
  2230. enumerable: true,
  2231. get: function () {
  2232. if (!Buffer.isBuffer(this))
  2233. return undefined;
  2234. return this.buffer;
  2235. }
  2236. });
  2237. Object.defineProperty(Buffer.prototype, 'offset', {
  2238. enumerable: true,
  2239. get: function () {
  2240. if (!Buffer.isBuffer(this))
  2241. return undefined;
  2242. return this.byteOffset;
  2243. }
  2244. });
  2245. function createBuffer(length) {
  2246. if (length > K_MAX_LENGTH) {
  2247. throw new RangeError('The value "' + length + '" is invalid for option "size"');
  2248. }
  2249. // Return an augmented `Uint8Array` instance
  2250. var buf = new Uint8Array(length);
  2251. // @ts-ignore
  2252. buf.__proto__ = Buffer.prototype;
  2253. return buf;
  2254. }
  2255. /**
  2256. * The Buffer constructor returns instances of `Uint8Array` that have their
  2257. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  2258. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  2259. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  2260. * returns a single octet.
  2261. *
  2262. * The `Uint8Array` prototype remains unmodified.
  2263. */
  2264. function Buffer(arg, encodingOrOffset, length) {
  2265. // Common case.
  2266. if (typeof arg === 'number') {
  2267. if (typeof encodingOrOffset === 'string') {
  2268. throw new TypeError('The "string" argument must be of type string. Received type number');
  2269. }
  2270. return allocUnsafe(arg);
  2271. }
  2272. return from(arg, encodingOrOffset, length);
  2273. }
  2274. exports.Buffer = Buffer;
  2275. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  2276. if (typeof Symbol !== 'undefined' && Symbol.species != null &&
  2277. Buffer[Symbol.species] === Buffer) {
  2278. Object.defineProperty(Buffer, Symbol.species, {
  2279. value: null,
  2280. configurable: true,
  2281. enumerable: false,
  2282. writable: false
  2283. });
  2284. }
  2285. Buffer.poolSize = 8192; // not used by this implementation
  2286. function from(value, encodingOrOffset, length) {
  2287. if (typeof value === 'string') {
  2288. return fromString(value, encodingOrOffset);
  2289. }
  2290. if (ArrayBuffer.isView(value)) {
  2291. return fromArrayLike(value);
  2292. }
  2293. if (value == null) {
  2294. throw TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  2295. 'or Array-like Object. Received type ' + (typeof value));
  2296. }
  2297. if (isInstance(value, ArrayBuffer) ||
  2298. (value && isInstance(value.buffer, ArrayBuffer))) {
  2299. return fromArrayBuffer(value, encodingOrOffset, length);
  2300. }
  2301. if (typeof value === 'number') {
  2302. throw new TypeError('The "value" argument must not be of type number. Received type number');
  2303. }
  2304. var valueOf = value.valueOf && value.valueOf();
  2305. if (valueOf != null && valueOf !== value) {
  2306. return Buffer.from(valueOf, encodingOrOffset, length);
  2307. }
  2308. var b = fromObject(value);
  2309. if (b)
  2310. return b;
  2311. if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
  2312. typeof value[Symbol.toPrimitive] === 'function') {
  2313. return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);
  2314. }
  2315. throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
  2316. 'or Array-like Object. Received type ' + (typeof value));
  2317. }
  2318. /**
  2319. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  2320. * if value is a number.
  2321. * Buffer.from(str[, encoding])
  2322. * Buffer.from(array)
  2323. * Buffer.from(buffer)
  2324. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  2325. **/
  2326. Buffer.from = function (value, encodingOrOffset, length) {
  2327. return from(value, encodingOrOffset, length);
  2328. };
  2329. // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
  2330. // https://github.com/feross/buffer/pull/148
  2331. Buffer.prototype.__proto__ = Uint8Array.prototype;
  2332. Buffer.__proto__ = Uint8Array;
  2333. function assertSize(size) {
  2334. if (typeof size !== 'number') {
  2335. throw new TypeError('"size" argument must be of type number');
  2336. }
  2337. else if (size < 0) {
  2338. throw new RangeError('The value "' + size + '" is invalid for option "size"');
  2339. }
  2340. }
  2341. function alloc(size, fill, encoding) {
  2342. assertSize(size);
  2343. if (size <= 0) {
  2344. return createBuffer(size);
  2345. }
  2346. if (fill !== undefined) {
  2347. // Only pay attention to encoding if it's a string. This
  2348. // prevents accidentally sending in a number that would
  2349. // be interpretted as a start offset.
  2350. return typeof encoding === 'string'
  2351. // @ts-ignore
  2352. ? createBuffer(size).fill(fill, encoding)
  2353. : createBuffer(size).fill(fill);
  2354. }
  2355. return createBuffer(size);
  2356. }
  2357. /**
  2358. * Creates a new filled Buffer instance.
  2359. * alloc(size[, fill[, encoding]])
  2360. **/
  2361. Buffer.alloc = function (size, fill, encoding) {
  2362. return alloc(size, fill, encoding);
  2363. };
  2364. function allocUnsafe(size) {
  2365. assertSize(size);
  2366. return createBuffer(size < 0 ? 0 : checked(size) | 0);
  2367. }
  2368. /**
  2369. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  2370. * */
  2371. Buffer.allocUnsafe = function (size) {
  2372. return allocUnsafe(size);
  2373. };
  2374. /**
  2375. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  2376. */
  2377. Buffer.allocUnsafeSlow = function (size) {
  2378. return allocUnsafe(size);
  2379. };
  2380. function fromString(string, encoding) {
  2381. if (typeof encoding !== 'string' || encoding === '') {
  2382. encoding = 'utf8';
  2383. }
  2384. if (!Buffer.isEncoding(encoding)) {
  2385. throw new TypeError('Unknown encoding: ' + encoding);
  2386. }
  2387. var length = byteLength(string, encoding) | 0;
  2388. var buf = createBuffer(length);
  2389. // @ts-ignore
  2390. var actual = buf.write(string, encoding);
  2391. if (actual !== length) {
  2392. // Writing a hex string, for example, that contains invalid characters will
  2393. // cause everything after the first invalid character to be ignored. (e.g.
  2394. // 'abxxcd' will be treated as 'ab')
  2395. buf = buf.slice(0, actual);
  2396. }
  2397. return buf;
  2398. }
  2399. function fromArrayLike(array) {
  2400. var length = array.length < 0 ? 0 : checked(array.length) | 0;
  2401. var buf = createBuffer(length);
  2402. for (var i = 0; i < length; i += 1) {
  2403. buf[i] = array[i] & 255;
  2404. }
  2405. return buf;
  2406. }
  2407. function fromArrayBuffer(array, byteOffset, length) {
  2408. if (byteOffset < 0 || array.byteLength < byteOffset) {
  2409. throw new RangeError('"offset" is outside of buffer bounds');
  2410. }
  2411. if (array.byteLength < byteOffset + (length || 0)) {
  2412. throw new RangeError('"length" is outside of buffer bounds');
  2413. }
  2414. var buf;
  2415. if (byteOffset === undefined && length === undefined) {
  2416. buf = new Uint8Array(array);
  2417. }
  2418. else if (length === undefined) {
  2419. buf = new Uint8Array(array, byteOffset);
  2420. }
  2421. else {
  2422. buf = new Uint8Array(array, byteOffset, length);
  2423. }
  2424. // Return an augmented `Uint8Array` instance
  2425. buf.__proto__ = Buffer.prototype;
  2426. return buf;
  2427. }
  2428. function fromObject(obj) {
  2429. if (Buffer.isBuffer(obj)) {
  2430. var len = checked(obj.length) | 0;
  2431. var buf = createBuffer(len);
  2432. if (buf.length === 0) {
  2433. return buf;
  2434. }
  2435. obj.copy(buf, 0, 0, len);
  2436. return buf;
  2437. }
  2438. if (obj.length !== undefined) {
  2439. if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
  2440. return createBuffer(0);
  2441. }
  2442. return fromArrayLike(obj);
  2443. }
  2444. if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
  2445. return fromArrayLike(obj.data);
  2446. }
  2447. }
  2448. function checked(length) {
  2449. // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
  2450. // length is NaN (which is otherwise coerced to zero.)
  2451. if (length >= K_MAX_LENGTH) {
  2452. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  2453. 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes');
  2454. }
  2455. return length | 0;
  2456. }
  2457. function SlowBuffer(length) {
  2458. if (+length != length) { // eslint-disable-line eqeqeq
  2459. length = 0;
  2460. }
  2461. // @ts-ignore
  2462. return Buffer.alloc(+length);
  2463. }
  2464. exports.SlowBuffer = SlowBuffer;
  2465. Buffer.isBuffer = function isBuffer(b) {
  2466. return b != null && b._isBuffer === true &&
  2467. b !== Buffer.prototype; // so Buffer.isBuffer(Buffer.prototype) will be false
  2468. };
  2469. Buffer.compare = function compare(a, b) {
  2470. if (isInstance(a, Uint8Array))
  2471. a = Buffer.from(a, a.offset, a.byteLength);
  2472. if (isInstance(b, Uint8Array))
  2473. b = Buffer.from(b, b.offset, b.byteLength);
  2474. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  2475. throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
  2476. }
  2477. if (a === b)
  2478. return 0;
  2479. var x = a.length;
  2480. var y = b.length;
  2481. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  2482. if (a[i] !== b[i]) {
  2483. x = a[i];
  2484. y = b[i];
  2485. break;
  2486. }
  2487. }
  2488. if (x < y)
  2489. return -1;
  2490. if (y < x)
  2491. return 1;
  2492. return 0;
  2493. };
  2494. Buffer.isEncoding = function isEncoding(encoding) {
  2495. switch (String(encoding).toLowerCase()) {
  2496. case 'hex':
  2497. case 'utf8':
  2498. case 'utf-8':
  2499. case 'ascii':
  2500. case 'latin1':
  2501. case 'binary':
  2502. case 'base64':
  2503. case 'ucs2':
  2504. case 'ucs-2':
  2505. case 'utf16le':
  2506. case 'utf-16le':
  2507. return true;
  2508. default:
  2509. return false;
  2510. }
  2511. };
  2512. Buffer.concat = function concat(list, length) {
  2513. if (!Array.isArray(list)) {
  2514. throw new TypeError('"list" argument must be an Array of Buffers');
  2515. }
  2516. if (list.length === 0) {
  2517. // @ts-ignore
  2518. return Buffer.alloc(0);
  2519. }
  2520. var i;
  2521. if (length === undefined) {
  2522. length = 0;
  2523. for (i = 0; i < list.length; ++i) {
  2524. length += list[i].length;
  2525. }
  2526. }
  2527. var buffer = Buffer.allocUnsafe(length);
  2528. var pos = 0;
  2529. for (i = 0; i < list.length; ++i) {
  2530. var buf = list[i];
  2531. if (isInstance(buf, Uint8Array)) {
  2532. // @ts-ignore
  2533. buf = Buffer.from(buf);
  2534. }
  2535. if (!Buffer.isBuffer(buf)) {
  2536. throw new TypeError('"list" argument must be an Array of Buffers');
  2537. }
  2538. buf.copy(buffer, pos);
  2539. pos += buf.length;
  2540. }
  2541. return buffer;
  2542. };
  2543. function byteLength(string, encoding) {
  2544. if (Buffer.isBuffer(string)) {
  2545. return string.length;
  2546. }
  2547. if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
  2548. return string.byteLength;
  2549. }
  2550. if (typeof string !== 'string') {
  2551. throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
  2552. 'Received type ' + typeof string);
  2553. }
  2554. var len = string.length;
  2555. var mustMatch = (arguments.length > 2 && arguments[2] === true);
  2556. if (!mustMatch && len === 0)
  2557. return 0;
  2558. // Use a for loop to avoid recursion
  2559. var loweredCase = false;
  2560. for (;;) {
  2561. switch (encoding) {
  2562. case 'ascii':
  2563. case 'latin1':
  2564. case 'binary':
  2565. return len;
  2566. case 'utf8':
  2567. case 'utf-8':
  2568. // @ts-ignore
  2569. return utf8ToBytes(string).length;
  2570. case 'ucs2':
  2571. case 'ucs-2':
  2572. case 'utf16le':
  2573. case 'utf-16le':
  2574. return len * 2;
  2575. case 'hex':
  2576. return len >>> 1;
  2577. case 'base64':
  2578. return base64ToBytes(string).length;
  2579. default:
  2580. if (loweredCase) {
  2581. // @ts-ignore
  2582. return mustMatch ? -1 : utf8ToBytes(string).length; // assume utf8
  2583. }
  2584. encoding = ('' + encoding).toLowerCase();
  2585. loweredCase = true;
  2586. }
  2587. }
  2588. }
  2589. Buffer.byteLength = byteLength;
  2590. function slowToString(encoding, start, end) {
  2591. var loweredCase = false;
  2592. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  2593. // property of a typed array.
  2594. // This behaves neither like String nor Uint8Array in that we set start/end
  2595. // to their upper/lower bounds if the value passed is out of range.
  2596. // undefined is handled specially as per ECMA-262 6th Edition,
  2597. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  2598. if (start === undefined || start < 0) {
  2599. start = 0;
  2600. }
  2601. // Return early if start > this.length. Done here to prevent potential uint32
  2602. // coercion fail below.
  2603. if (start > this.length) {
  2604. return '';
  2605. }
  2606. if (end === undefined || end > this.length) {
  2607. end = this.length;
  2608. }
  2609. if (end <= 0) {
  2610. return '';
  2611. }
  2612. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  2613. end >>>= 0;
  2614. start >>>= 0;
  2615. if (end <= start) {
  2616. return '';
  2617. }
  2618. if (!encoding)
  2619. encoding = 'utf8';
  2620. while (true) {
  2621. switch (encoding) {
  2622. case 'hex':
  2623. return hexSlice(this, start, end);
  2624. case 'utf8':
  2625. case 'utf-8':
  2626. return utf8Slice(this, start, end);
  2627. case 'ascii':
  2628. return asciiSlice(this, start, end);
  2629. case 'latin1':
  2630. case 'binary':
  2631. return latin1Slice(this, start, end);
  2632. case 'base64':
  2633. return base64Slice(this, start, end);
  2634. case 'ucs2':
  2635. case 'ucs-2':
  2636. case 'utf16le':
  2637. case 'utf-16le':
  2638. return utf16leSlice(this, start, end);
  2639. default:
  2640. if (loweredCase)
  2641. throw new TypeError('Unknown encoding: ' + encoding);
  2642. encoding = (encoding + '').toLowerCase();
  2643. loweredCase = true;
  2644. }
  2645. }
  2646. }
  2647. // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
  2648. // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
  2649. // reliably in a browserify context because there could be multiple different
  2650. // copies of the 'buffer' package in use. This method works even for Buffer
  2651. // instances that were created from another copy of the `buffer` package.
  2652. // See: https://github.com/feross/buffer/issues/154
  2653. Buffer.prototype._isBuffer = true;
  2654. function swap(b, n, m) {
  2655. var i = b[n];
  2656. b[n] = b[m];
  2657. b[m] = i;
  2658. }
  2659. Buffer.prototype.swap16 = function swap16() {
  2660. var len = this.length;
  2661. if (len % 2 !== 0) {
  2662. throw new RangeError('Buffer size must be a multiple of 16-bits');
  2663. }
  2664. for (var i = 0; i < len; i += 2) {
  2665. swap(this, i, i + 1);
  2666. }
  2667. return this;
  2668. };
  2669. Buffer.prototype.swap32 = function swap32() {
  2670. var len = this.length;
  2671. if (len % 4 !== 0) {
  2672. throw new RangeError('Buffer size must be a multiple of 32-bits');
  2673. }
  2674. for (var i = 0; i < len; i += 4) {
  2675. swap(this, i, i + 3);
  2676. swap(this, i + 1, i + 2);
  2677. }
  2678. return this;
  2679. };
  2680. Buffer.prototype.swap64 = function swap64() {
  2681. var len = this.length;
  2682. if (len % 8 !== 0) {
  2683. throw new RangeError('Buffer size must be a multiple of 64-bits');
  2684. }
  2685. for (var i = 0; i < len; i += 8) {
  2686. swap(this, i, i + 7);
  2687. swap(this, i + 1, i + 6);
  2688. swap(this, i + 2, i + 5);
  2689. swap(this, i + 3, i + 4);
  2690. }
  2691. return this;
  2692. };
  2693. Buffer.prototype.toString = function toString() {
  2694. var length = this.length;
  2695. if (length === 0)
  2696. return '';
  2697. if (arguments.length === 0)
  2698. return utf8Slice(this, 0, length);
  2699. return slowToString.apply(this, arguments);
  2700. };
  2701. Buffer.prototype.toLocaleString = Buffer.prototype.toString;
  2702. Buffer.prototype.equals = function equals(b) {
  2703. if (!Buffer.isBuffer(b))
  2704. throw new TypeError('Argument must be a Buffer');
  2705. if (this === b)
  2706. return true;
  2707. return Buffer.compare(this, b) === 0;
  2708. };
  2709. Buffer.prototype.inspect = function inspect() {
  2710. var str = '';
  2711. var max = INSPECT_MAX_BYTES;
  2712. str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
  2713. if (this.length > max)
  2714. str += ' ... ';
  2715. return '<Buffer ' + str + '>';
  2716. };
  2717. Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
  2718. if (isInstance(target, Uint8Array)) {
  2719. target = Buffer.from(target, target.offset, target.byteLength);
  2720. }
  2721. if (!Buffer.isBuffer(target)) {
  2722. throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' +
  2723. 'Received type ' + (typeof target));
  2724. }
  2725. if (start === undefined) {
  2726. start = 0;
  2727. }
  2728. if (end === undefined) {
  2729. end = target ? target.length : 0;
  2730. }
  2731. if (thisStart === undefined) {
  2732. thisStart = 0;
  2733. }
  2734. if (thisEnd === undefined) {
  2735. thisEnd = this.length;
  2736. }
  2737. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  2738. throw new RangeError('out of range index');
  2739. }
  2740. if (thisStart >= thisEnd && start >= end) {
  2741. return 0;
  2742. }
  2743. if (thisStart >= thisEnd) {
  2744. return -1;
  2745. }
  2746. if (start >= end) {
  2747. return 1;
  2748. }
  2749. start >>>= 0;
  2750. end >>>= 0;
  2751. thisStart >>>= 0;
  2752. thisEnd >>>= 0;
  2753. if (this === target)
  2754. return 0;
  2755. var x = thisEnd - thisStart;
  2756. var y = end - start;
  2757. var len = Math.min(x, y);
  2758. var thisCopy = this.slice(thisStart, thisEnd);
  2759. var targetCopy = target.slice(start, end);
  2760. for (var i = 0; i < len; ++i) {
  2761. if (thisCopy[i] !== targetCopy[i]) {
  2762. x = thisCopy[i];
  2763. y = targetCopy[i];
  2764. break;
  2765. }
  2766. }
  2767. if (x < y)
  2768. return -1;
  2769. if (y < x)
  2770. return 1;
  2771. return 0;
  2772. };
  2773. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  2774. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  2775. //
  2776. // Arguments:
  2777. // - buffer - a Buffer to search
  2778. // - val - a string, Buffer, or number
  2779. // - byteOffset - an index into `buffer`; will be clamped to an int32
  2780. // - encoding - an optional encoding, relevant is val is a string
  2781. // - dir - true for indexOf, false for lastIndexOf
  2782. function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
  2783. // Empty buffer means no match
  2784. if (buffer.length === 0)
  2785. return -1;
  2786. // Normalize byteOffset
  2787. if (typeof byteOffset === 'string') {
  2788. encoding = byteOffset;
  2789. byteOffset = 0;
  2790. }
  2791. else if (byteOffset > 0x7fffffff) {
  2792. byteOffset = 0x7fffffff;
  2793. }
  2794. else if (byteOffset < -0x80000000) {
  2795. byteOffset = -0x80000000;
  2796. }
  2797. byteOffset = +byteOffset; // Coerce to Number.
  2798. if (numberIsNaN(byteOffset)) {
  2799. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  2800. byteOffset = dir ? 0 : (buffer.length - 1);
  2801. }
  2802. // Normalize byteOffset: negative offsets start from the end of the buffer
  2803. if (byteOffset < 0)
  2804. byteOffset = buffer.length + byteOffset;
  2805. if (byteOffset >= buffer.length) {
  2806. if (dir)
  2807. return -1;
  2808. else
  2809. byteOffset = buffer.length - 1;
  2810. }
  2811. else if (byteOffset < 0) {
  2812. if (dir)
  2813. byteOffset = 0;
  2814. else
  2815. return -1;
  2816. }
  2817. // Normalize val
  2818. if (typeof val === 'string') {
  2819. // @ts-ignore
  2820. val = Buffer.from(val, encoding);
  2821. }
  2822. // Finally, search either indexOf (if dir is true) or lastIndexOf
  2823. if (Buffer.isBuffer(val)) {
  2824. // Special case: looking for empty string/buffer always fails
  2825. if (val.length === 0) {
  2826. return -1;
  2827. }
  2828. return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
  2829. }
  2830. else if (typeof val === 'number') {
  2831. val = val & 0xFF; // Search for a byte value [0-255]
  2832. if (typeof Uint8Array.prototype.indexOf === 'function') {
  2833. if (dir) {
  2834. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
  2835. }
  2836. else {
  2837. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
  2838. }
  2839. }
  2840. return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
  2841. }
  2842. throw new TypeError('val must be string, number or Buffer');
  2843. }
  2844. function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
  2845. var indexSize = 1;
  2846. var arrLength = arr.length;
  2847. var valLength = val.length;
  2848. if (encoding !== undefined) {
  2849. encoding = String(encoding).toLowerCase();
  2850. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  2851. encoding === 'utf16le' || encoding === 'utf-16le') {
  2852. if (arr.length < 2 || val.length < 2) {
  2853. return -1;
  2854. }
  2855. indexSize = 2;
  2856. arrLength /= 2;
  2857. valLength /= 2;
  2858. byteOffset /= 2;
  2859. }
  2860. }
  2861. function read(buf, i) {
  2862. if (indexSize === 1) {
  2863. return buf[i];
  2864. }
  2865. else {
  2866. return buf.readUInt16BE(i * indexSize);
  2867. }
  2868. }
  2869. var i;
  2870. if (dir) {
  2871. var foundIndex = -1;
  2872. for (i = byteOffset; i < arrLength; i++) {
  2873. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  2874. if (foundIndex === -1)
  2875. foundIndex = i;
  2876. if (i - foundIndex + 1 === valLength)
  2877. return foundIndex * indexSize;
  2878. }
  2879. else {
  2880. if (foundIndex !== -1)
  2881. i -= i - foundIndex;
  2882. foundIndex = -1;
  2883. }
  2884. }
  2885. }
  2886. else {
  2887. if (byteOffset + valLength > arrLength)
  2888. byteOffset = arrLength - valLength;
  2889. for (i = byteOffset; i >= 0; i--) {
  2890. var found = true;
  2891. for (var j = 0; j < valLength; j++) {
  2892. if (read(arr, i + j) !== read(val, j)) {
  2893. found = false;
  2894. break;
  2895. }
  2896. }
  2897. if (found)
  2898. return i;
  2899. }
  2900. }
  2901. return -1;
  2902. }
  2903. Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
  2904. return this.indexOf(val, byteOffset, encoding) !== -1;
  2905. };
  2906. Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
  2907. return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
  2908. };
  2909. Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
  2910. return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
  2911. };
  2912. function hexWrite(buf, string, offset, length) {
  2913. offset = Number(offset) || 0;
  2914. var remaining = buf.length - offset;
  2915. if (!length) {
  2916. length = remaining;
  2917. }
  2918. else {
  2919. length = Number(length);
  2920. if (length > remaining) {
  2921. length = remaining;
  2922. }
  2923. }
  2924. var strLen = string.length;
  2925. if (length > strLen / 2) {
  2926. length = strLen / 2;
  2927. }
  2928. for (var i = 0; i < length; ++i) {
  2929. var parsed = parseInt(string.substr(i * 2, 2), 16);
  2930. if (numberIsNaN(parsed))
  2931. return i;
  2932. buf[offset + i] = parsed;
  2933. }
  2934. return i;
  2935. }
  2936. function utf8Write(buf, string, offset, length) {
  2937. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
  2938. }
  2939. function asciiWrite(buf, string, offset, length) {
  2940. return blitBuffer(asciiToBytes(string), buf, offset, length);
  2941. }
  2942. function latin1Write(buf, string, offset, length) {
  2943. return asciiWrite(buf, string, offset, length);
  2944. }
  2945. function base64Write(buf, string, offset, length) {
  2946. return blitBuffer(base64ToBytes(string), buf, offset, length);
  2947. }
  2948. function ucs2Write(buf, string, offset, length) {
  2949. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
  2950. }
  2951. Buffer.prototype.write = function write(string, offset, length, encoding) {
  2952. // Buffer#write(string)
  2953. if (offset === undefined) {
  2954. encoding = 'utf8';
  2955. length = this.length;
  2956. offset = 0;
  2957. // Buffer#write(string, encoding)
  2958. }
  2959. else if (length === undefined && typeof offset === 'string') {
  2960. encoding = offset;
  2961. length = this.length;
  2962. offset = 0;
  2963. // Buffer#write(string, offset[, length][, encoding])
  2964. }
  2965. else if (isFinite(offset)) {
  2966. offset = offset >>> 0;
  2967. if (isFinite(length)) {
  2968. length = length >>> 0;
  2969. if (encoding === undefined)
  2970. encoding = 'utf8';
  2971. }
  2972. else {
  2973. encoding = length;
  2974. length = undefined;
  2975. }
  2976. }
  2977. else {
  2978. throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');
  2979. }
  2980. var remaining = this.length - offset;
  2981. if (length === undefined || length > remaining)
  2982. length = remaining;
  2983. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  2984. throw new RangeError('Attempt to write outside buffer bounds');
  2985. }
  2986. if (!encoding)
  2987. encoding = 'utf8';
  2988. var loweredCase = false;
  2989. for (;;) {
  2990. switch (encoding) {
  2991. case 'hex':
  2992. return hexWrite(this, string, offset, length);
  2993. case 'utf8':
  2994. case 'utf-8':
  2995. return utf8Write(this, string, offset, length);
  2996. case 'ascii':
  2997. return asciiWrite(this, string, offset, length);
  2998. case 'latin1':
  2999. case 'binary':
  3000. return latin1Write(this, string, offset, length);
  3001. case 'base64':
  3002. // Warning: maxLength not taken into account in base64Write
  3003. return base64Write(this, string, offset, length);
  3004. case 'ucs2':
  3005. case 'ucs-2':
  3006. case 'utf16le':
  3007. case 'utf-16le':
  3008. return ucs2Write(this, string, offset, length);
  3009. default:
  3010. if (loweredCase)
  3011. throw new TypeError('Unknown encoding: ' + encoding);
  3012. encoding = ('' + encoding).toLowerCase();
  3013. loweredCase = true;
  3014. }
  3015. }
  3016. };
  3017. Buffer.prototype.toJSON = function toJSON() {
  3018. return {
  3019. type: 'Buffer',
  3020. data: Array.prototype.slice.call(this._arr || this, 0)
  3021. };
  3022. };
  3023. function base64Slice(buf, start, end) {
  3024. if (start === 0 && end === buf.length) {
  3025. // @ts-ignore
  3026. return base64.fromByteArray(buf);
  3027. }
  3028. else {
  3029. // @ts-ignore
  3030. return base64.fromByteArray(buf.slice(start, end));
  3031. }
  3032. }
  3033. function utf8Slice(buf, start, end) {
  3034. end = Math.min(buf.length, end);
  3035. var res = [];
  3036. var i = start;
  3037. while (i < end) {
  3038. var firstByte = buf[i];
  3039. var codePoint = null;
  3040. var bytesPerSequence = (firstByte > 0xEF) ? 4
  3041. : (firstByte > 0xDF) ? 3
  3042. : (firstByte > 0xBF) ? 2
  3043. : 1;
  3044. if (i + bytesPerSequence <= end) {
  3045. var secondByte, thirdByte, fourthByte, tempCodePoint;
  3046. switch (bytesPerSequence) {
  3047. case 1:
  3048. if (firstByte < 0x80) {
  3049. codePoint = firstByte;
  3050. }
  3051. break;
  3052. case 2:
  3053. secondByte = buf[i + 1];
  3054. if ((secondByte & 0xC0) === 0x80) {
  3055. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
  3056. if (tempCodePoint > 0x7F) {
  3057. codePoint = tempCodePoint;
  3058. }
  3059. }
  3060. break;
  3061. case 3:
  3062. secondByte = buf[i + 1];
  3063. thirdByte = buf[i + 2];
  3064. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  3065. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
  3066. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  3067. codePoint = tempCodePoint;
  3068. }
  3069. }
  3070. break;
  3071. case 4:
  3072. secondByte = buf[i + 1];
  3073. thirdByte = buf[i + 2];
  3074. fourthByte = buf[i + 3];
  3075. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  3076. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
  3077. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  3078. codePoint = tempCodePoint;
  3079. }
  3080. }
  3081. }
  3082. }
  3083. if (codePoint === null) {
  3084. // we did not generate a valid codePoint so insert a
  3085. // replacement char (U+FFFD) and advance only 1 byte
  3086. codePoint = 0xFFFD;
  3087. bytesPerSequence = 1;
  3088. }
  3089. else if (codePoint > 0xFFFF) {
  3090. // encode to utf16 (surrogate pair dance)
  3091. codePoint -= 0x10000;
  3092. res.push(codePoint >>> 10 & 0x3FF | 0xD800);
  3093. codePoint = 0xDC00 | codePoint & 0x3FF;
  3094. }
  3095. res.push(codePoint);
  3096. i += bytesPerSequence;
  3097. }
  3098. return decodeCodePointsArray(res);
  3099. }
  3100. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  3101. // the lowest limit is Chrome, with 0x10000 args.
  3102. // We go 1 magnitude less, for safety
  3103. var MAX_ARGUMENTS_LENGTH = 0x1000;
  3104. function decodeCodePointsArray(codePoints) {
  3105. var len = codePoints.length;
  3106. if (len <= MAX_ARGUMENTS_LENGTH) {
  3107. return String.fromCharCode.apply(String, codePoints); // avoid extra slice()
  3108. }
  3109. // Decode in chunks to avoid "call stack size exceeded".
  3110. var res = '';
  3111. var i = 0;
  3112. while (i < len) {
  3113. res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
  3114. }
  3115. return res;
  3116. }
  3117. function asciiSlice(buf, start, end) {
  3118. var ret = '';
  3119. end = Math.min(buf.length, end);
  3120. for (var i = start; i < end; ++i) {
  3121. ret += String.fromCharCode(buf[i] & 0x7F);
  3122. }
  3123. return ret;
  3124. }
  3125. function latin1Slice(buf, start, end) {
  3126. var ret = '';
  3127. end = Math.min(buf.length, end);
  3128. for (var i = start; i < end; ++i) {
  3129. ret += String.fromCharCode(buf[i]);
  3130. }
  3131. return ret;
  3132. }
  3133. function hexSlice(buf, start, end) {
  3134. var len = buf.length;
  3135. if (!start || start < 0)
  3136. start = 0;
  3137. if (!end || end < 0 || end > len)
  3138. end = len;
  3139. var out = '';
  3140. for (var i = start; i < end; ++i) {
  3141. out += toHex(buf[i]);
  3142. }
  3143. return out;
  3144. }
  3145. function utf16leSlice(buf, start, end) {
  3146. var bytes = buf.slice(start, end);
  3147. var res = '';
  3148. for (var i = 0; i < bytes.length; i += 2) {
  3149. res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
  3150. }
  3151. return res;
  3152. }
  3153. Buffer.prototype.slice = function slice(start, end) {
  3154. var len = this.length;
  3155. start = ~~start;
  3156. end = end === undefined ? len : ~~end;
  3157. if (start < 0) {
  3158. start += len;
  3159. if (start < 0)
  3160. start = 0;
  3161. }
  3162. else if (start > len) {
  3163. start = len;
  3164. }
  3165. if (end < 0) {
  3166. end += len;
  3167. if (end < 0)
  3168. end = 0;
  3169. }
  3170. else if (end > len) {
  3171. end = len;
  3172. }
  3173. if (end < start)
  3174. end = start;
  3175. var newBuf = this.subarray(start, end);
  3176. // Return an augmented `Uint8Array` instance
  3177. newBuf.__proto__ = Buffer.prototype;
  3178. return newBuf;
  3179. };
  3180. /*
  3181. * Need to make sure that buffer isn't trying to write out of bounds.
  3182. */
  3183. function checkOffset(offset, ext, length) {
  3184. if ((offset % 1) !== 0 || offset < 0)
  3185. throw new RangeError('offset is not uint');
  3186. if (offset + ext > length)
  3187. throw new RangeError('Trying to access beyond buffer length');
  3188. }
  3189. Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
  3190. offset = offset >>> 0;
  3191. byteLength = byteLength >>> 0;
  3192. if (!noAssert)
  3193. checkOffset(offset, byteLength, this.length);
  3194. var val = this[offset];
  3195. var mul = 1;
  3196. var i = 0;
  3197. while (++i < byteLength && (mul *= 0x100)) {
  3198. val += this[offset + i] * mul;
  3199. }
  3200. return val;
  3201. };
  3202. Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
  3203. offset = offset >>> 0;
  3204. byteLength = byteLength >>> 0;
  3205. if (!noAssert) {
  3206. checkOffset(offset, byteLength, this.length);
  3207. }
  3208. var val = this[offset + --byteLength];
  3209. var mul = 1;
  3210. while (byteLength > 0 && (mul *= 0x100)) {
  3211. val += this[offset + --byteLength] * mul;
  3212. }
  3213. return val;
  3214. };
  3215. Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
  3216. offset = offset >>> 0;
  3217. if (!noAssert)
  3218. checkOffset(offset, 1, this.length);
  3219. return this[offset];
  3220. };
  3221. Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
  3222. offset = offset >>> 0;
  3223. if (!noAssert)
  3224. checkOffset(offset, 2, this.length);
  3225. return this[offset] | (this[offset + 1] << 8);
  3226. };
  3227. Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
  3228. offset = offset >>> 0;
  3229. if (!noAssert)
  3230. checkOffset(offset, 2, this.length);
  3231. return (this[offset] << 8) | this[offset + 1];
  3232. };
  3233. Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
  3234. offset = offset >>> 0;
  3235. if (!noAssert)
  3236. checkOffset(offset, 4, this.length);
  3237. return ((this[offset]) |
  3238. (this[offset + 1] << 8) |
  3239. (this[offset + 2] << 16)) +
  3240. (this[offset + 3] * 0x1000000);
  3241. };
  3242. Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
  3243. offset = offset >>> 0;
  3244. if (!noAssert)
  3245. checkOffset(offset, 4, this.length);
  3246. return (this[offset] * 0x1000000) +
  3247. ((this[offset + 1] << 16) |
  3248. (this[offset + 2] << 8) |
  3249. this[offset + 3]);
  3250. };
  3251. Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
  3252. offset = offset >>> 0;
  3253. byteLength = byteLength >>> 0;
  3254. if (!noAssert)
  3255. checkOffset(offset, byteLength, this.length);
  3256. var val = this[offset];
  3257. var mul = 1;
  3258. var i = 0;
  3259. while (++i < byteLength && (mul *= 0x100)) {
  3260. val += this[offset + i] * mul;
  3261. }
  3262. mul *= 0x80;
  3263. if (val >= mul)
  3264. val -= Math.pow(2, 8 * byteLength);
  3265. return val;
  3266. };
  3267. Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
  3268. offset = offset >>> 0;
  3269. byteLength = byteLength >>> 0;
  3270. if (!noAssert)
  3271. checkOffset(offset, byteLength, this.length);
  3272. var i = byteLength;
  3273. var mul = 1;
  3274. var val = this[offset + --i];
  3275. while (i > 0 && (mul *= 0x100)) {
  3276. val += this[offset + --i] * mul;
  3277. }
  3278. mul *= 0x80;
  3279. if (val >= mul)
  3280. val -= Math.pow(2, 8 * byteLength);
  3281. return val;
  3282. };
  3283. Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
  3284. offset = offset >>> 0;
  3285. if (!noAssert)
  3286. checkOffset(offset, 1, this.length);
  3287. if (!(this[offset] & 0x80))
  3288. return (this[offset]);
  3289. return ((0xff - this[offset] + 1) * -1);
  3290. };
  3291. Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
  3292. offset = offset >>> 0;
  3293. if (!noAssert)
  3294. checkOffset(offset, 2, this.length);
  3295. var val = this[offset] | (this[offset + 1] << 8);
  3296. return (val & 0x8000) ? val | 0xFFFF0000 : val;
  3297. };
  3298. Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
  3299. offset = offset >>> 0;
  3300. if (!noAssert)
  3301. checkOffset(offset, 2, this.length);
  3302. var val = this[offset + 1] | (this[offset] << 8);
  3303. return (val & 0x8000) ? val | 0xFFFF0000 : val;
  3304. };
  3305. Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
  3306. offset = offset >>> 0;
  3307. if (!noAssert)
  3308. checkOffset(offset, 4, this.length);
  3309. return (this[offset]) |
  3310. (this[offset + 1] << 8) |
  3311. (this[offset + 2] << 16) |
  3312. (this[offset + 3] << 24);
  3313. };
  3314. Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
  3315. offset = offset >>> 0;
  3316. if (!noAssert)
  3317. checkOffset(offset, 4, this.length);
  3318. return (this[offset] << 24) |
  3319. (this[offset + 1] << 16) |
  3320. (this[offset + 2] << 8) |
  3321. (this[offset + 3]);
  3322. };
  3323. Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
  3324. offset = offset >>> 0;
  3325. if (!noAssert)
  3326. checkOffset(offset, 4, this.length);
  3327. // @ts-ignore
  3328. return ieee754.read(this, offset, true, 23, 4);
  3329. };
  3330. Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
  3331. offset = offset >>> 0;
  3332. if (!noAssert)
  3333. checkOffset(offset, 4, this.length);
  3334. // @ts-ignore
  3335. return ieee754.read(this, offset, false, 23, 4);
  3336. };
  3337. Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
  3338. offset = offset >>> 0;
  3339. if (!noAssert)
  3340. checkOffset(offset, 8, this.length);
  3341. // @ts-ignore
  3342. return ieee754.read(this, offset, true, 52, 8);
  3343. };
  3344. Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
  3345. offset = offset >>> 0;
  3346. if (!noAssert)
  3347. checkOffset(offset, 8, this.length);
  3348. // @ts-ignore
  3349. return ieee754.read(this, offset, false, 52, 8);
  3350. };
  3351. function checkInt(buf, value, offset, ext, max, min) {
  3352. if (!Buffer.isBuffer(buf))
  3353. throw new TypeError('"buffer" argument must be a Buffer instance');
  3354. if (value > max || value < min)
  3355. throw new RangeError('"value" argument is out of bounds');
  3356. if (offset + ext > buf.length)
  3357. throw new RangeError('Index out of range');
  3358. }
  3359. Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
  3360. value = +value;
  3361. offset = offset >>> 0;
  3362. byteLength = byteLength >>> 0;
  3363. if (!noAssert) {
  3364. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  3365. checkInt(this, value, offset, byteLength, maxBytes, 0);
  3366. }
  3367. var mul = 1;
  3368. var i = 0;
  3369. this[offset] = value & 0xFF;
  3370. while (++i < byteLength && (mul *= 0x100)) {
  3371. this[offset + i] = (value / mul) & 0xFF;
  3372. }
  3373. return offset + byteLength;
  3374. };
  3375. Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
  3376. value = +value;
  3377. offset = offset >>> 0;
  3378. byteLength = byteLength >>> 0;
  3379. if (!noAssert) {
  3380. var maxBytes = Math.pow(2, 8 * byteLength) - 1;
  3381. checkInt(this, value, offset, byteLength, maxBytes, 0);
  3382. }
  3383. var i = byteLength - 1;
  3384. var mul = 1;
  3385. this[offset + i] = value & 0xFF;
  3386. while (--i >= 0 && (mul *= 0x100)) {
  3387. this[offset + i] = (value / mul) & 0xFF;
  3388. }
  3389. return offset + byteLength;
  3390. };
  3391. Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
  3392. value = +value;
  3393. offset = offset >>> 0;
  3394. if (!noAssert)
  3395. checkInt(this, value, offset, 1, 0xff, 0);
  3396. this[offset] = (value & 0xff);
  3397. return offset + 1;
  3398. };
  3399. Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
  3400. value = +value;
  3401. offset = offset >>> 0;
  3402. if (!noAssert)
  3403. checkInt(this, value, offset, 2, 0xffff, 0);
  3404. this[offset] = (value & 0xff);
  3405. this[offset + 1] = (value >>> 8);
  3406. return offset + 2;
  3407. };
  3408. Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
  3409. value = +value;
  3410. offset = offset >>> 0;
  3411. if (!noAssert)
  3412. checkInt(this, value, offset, 2, 0xffff, 0);
  3413. this[offset] = (value >>> 8);
  3414. this[offset + 1] = (value & 0xff);
  3415. return offset + 2;
  3416. };
  3417. Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
  3418. value = +value;
  3419. offset = offset >>> 0;
  3420. if (!noAssert)
  3421. checkInt(this, value, offset, 4, 0xffffffff, 0);
  3422. this[offset + 3] = (value >>> 24);
  3423. this[offset + 2] = (value >>> 16);
  3424. this[offset + 1] = (value >>> 8);
  3425. this[offset] = (value & 0xff);
  3426. return offset + 4;
  3427. };
  3428. Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
  3429. value = +value;
  3430. offset = offset >>> 0;
  3431. if (!noAssert)
  3432. checkInt(this, value, offset, 4, 0xffffffff, 0);
  3433. this[offset] = (value >>> 24);
  3434. this[offset + 1] = (value >>> 16);
  3435. this[offset + 2] = (value >>> 8);
  3436. this[offset + 3] = (value & 0xff);
  3437. return offset + 4;
  3438. };
  3439. Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
  3440. value = +value;
  3441. offset = offset >>> 0;
  3442. if (!noAssert) {
  3443. var limit = Math.pow(2, (8 * byteLength) - 1);
  3444. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  3445. }
  3446. var i = 0;
  3447. var mul = 1;
  3448. var sub = 0;
  3449. this[offset] = value & 0xFF;
  3450. while (++i < byteLength && (mul *= 0x100)) {
  3451. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  3452. sub = 1;
  3453. }
  3454. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  3455. }
  3456. return offset + byteLength;
  3457. };
  3458. Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
  3459. value = +value;
  3460. offset = offset >>> 0;
  3461. if (!noAssert) {
  3462. var limit = Math.pow(2, (8 * byteLength) - 1);
  3463. checkInt(this, value, offset, byteLength, limit - 1, -limit);
  3464. }
  3465. var i = byteLength - 1;
  3466. var mul = 1;
  3467. var sub = 0;
  3468. this[offset + i] = value & 0xFF;
  3469. while (--i >= 0 && (mul *= 0x100)) {
  3470. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  3471. sub = 1;
  3472. }
  3473. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
  3474. }
  3475. return offset + byteLength;
  3476. };
  3477. Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
  3478. value = +value;
  3479. offset = offset >>> 0;
  3480. if (!noAssert)
  3481. checkInt(this, value, offset, 1, 0x7f, -0x80);
  3482. if (value < 0)
  3483. value = 0xff + value + 1;
  3484. this[offset] = (value & 0xff);
  3485. return offset + 1;
  3486. };
  3487. Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
  3488. value = +value;
  3489. offset = offset >>> 0;
  3490. if (!noAssert)
  3491. checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  3492. this[offset] = (value & 0xff);
  3493. this[offset + 1] = (value >>> 8);
  3494. return offset + 2;
  3495. };
  3496. Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
  3497. value = +value;
  3498. offset = offset >>> 0;
  3499. if (!noAssert)
  3500. checkInt(this, value, offset, 2, 0x7fff, -0x8000);
  3501. this[offset] = (value >>> 8);
  3502. this[offset + 1] = (value & 0xff);
  3503. return offset + 2;
  3504. };
  3505. Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
  3506. value = +value;
  3507. offset = offset >>> 0;
  3508. if (!noAssert)
  3509. checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  3510. this[offset] = (value & 0xff);
  3511. this[offset + 1] = (value >>> 8);
  3512. this[offset + 2] = (value >>> 16);
  3513. this[offset + 3] = (value >>> 24);
  3514. return offset + 4;
  3515. };
  3516. Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
  3517. value = +value;
  3518. offset = offset >>> 0;
  3519. if (!noAssert)
  3520. checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000);
  3521. if (value < 0)
  3522. value = 0xffffffff + value + 1;
  3523. this[offset] = (value >>> 24);
  3524. this[offset + 1] = (value >>> 16);
  3525. this[offset + 2] = (value >>> 8);
  3526. this[offset + 3] = (value & 0xff);
  3527. return offset + 4;
  3528. };
  3529. function checkIEEE754(buf, value, offset, ext, max, min) {
  3530. if (offset + ext > buf.length)
  3531. throw new RangeError('Index out of range');
  3532. if (offset < 0)
  3533. throw new RangeError('Index out of range');
  3534. }
  3535. function writeFloat(buf, value, offset, littleEndian, noAssert) {
  3536. value = +value;
  3537. offset = offset >>> 0;
  3538. if (!noAssert) {
  3539. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38);
  3540. }
  3541. // @ts-ignore
  3542. ieee754.write(buf, value, offset, littleEndian, 23, 4);
  3543. return offset + 4;
  3544. }
  3545. Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
  3546. return writeFloat(this, value, offset, true, noAssert);
  3547. };
  3548. Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
  3549. return writeFloat(this, value, offset, false, noAssert);
  3550. };
  3551. function writeDouble(buf, value, offset, littleEndian, noAssert) {
  3552. value = +value;
  3553. offset = offset >>> 0;
  3554. if (!noAssert) {
  3555. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308);
  3556. }
  3557. // @ts-ignore
  3558. ieee754.write(buf, value, offset, littleEndian, 52, 8);
  3559. return offset + 8;
  3560. }
  3561. Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
  3562. return writeDouble(this, value, offset, true, noAssert);
  3563. };
  3564. Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
  3565. return writeDouble(this, value, offset, false, noAssert);
  3566. };
  3567. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  3568. Buffer.prototype.copy = function copy(target, targetStart, start, end) {
  3569. if (!Buffer.isBuffer(target))
  3570. throw new TypeError('argument should be a Buffer');
  3571. if (!start)
  3572. start = 0;
  3573. if (!end && end !== 0)
  3574. end = this.length;
  3575. if (targetStart >= target.length)
  3576. targetStart = target.length;
  3577. if (!targetStart)
  3578. targetStart = 0;
  3579. if (end > 0 && end < start)
  3580. end = start;
  3581. // Copy 0 bytes; we're done
  3582. if (end === start)
  3583. return 0;
  3584. if (target.length === 0 || this.length === 0)
  3585. return 0;
  3586. // Fatal error conditions
  3587. if (targetStart < 0) {
  3588. throw new RangeError('targetStart out of bounds');
  3589. }
  3590. if (start < 0 || start >= this.length)
  3591. throw new RangeError('Index out of range');
  3592. if (end < 0)
  3593. throw new RangeError('sourceEnd out of bounds');
  3594. // Are we oob?
  3595. if (end > this.length)
  3596. end = this.length;
  3597. if (target.length - targetStart < end - start) {
  3598. end = target.length - targetStart + start;
  3599. }
  3600. var len = end - start;
  3601. if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
  3602. // Use built-in when available, missing from IE11
  3603. this.copyWithin(targetStart, start, end);
  3604. }
  3605. else if (this === target && start < targetStart && targetStart < end) {
  3606. // descending copy from end
  3607. for (var i = len - 1; i >= 0; --i) {
  3608. target[i + targetStart] = this[i + start];
  3609. }
  3610. }
  3611. else {
  3612. Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
  3613. }
  3614. return len;
  3615. };
  3616. // Usage:
  3617. // buffer.fill(number[, offset[, end]])
  3618. // buffer.fill(buffer[, offset[, end]])
  3619. // buffer.fill(string[, offset[, end]][, encoding])
  3620. Buffer.prototype.fill = function fill(val, start, end, encoding) {
  3621. // Handle string cases:
  3622. if (typeof val === 'string') {
  3623. if (typeof start === 'string') {
  3624. encoding = start;
  3625. start = 0;
  3626. end = this.length;
  3627. }
  3628. else if (typeof end === 'string') {
  3629. encoding = end;
  3630. end = this.length;
  3631. }
  3632. if (encoding !== undefined && typeof encoding !== 'string') {
  3633. throw new TypeError('encoding must be a string');
  3634. }
  3635. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  3636. throw new TypeError('Unknown encoding: ' + encoding);
  3637. }
  3638. if (val.length === 1) {
  3639. var code = val.charCodeAt(0);
  3640. if ((encoding === 'utf8' && code < 128) ||
  3641. encoding === 'latin1') {
  3642. // Fast path: If `val` fits into a single byte, use that numeric value.
  3643. val = code;
  3644. }
  3645. }
  3646. }
  3647. else if (typeof val === 'number') {
  3648. val = val & 255;
  3649. }
  3650. // Invalid ranges are not set to a default, so can range check early.
  3651. if (start < 0 || this.length < start || this.length < end) {
  3652. throw new RangeError('Out of range index');
  3653. }
  3654. if (end <= start) {
  3655. return this;
  3656. }
  3657. start = start >>> 0;
  3658. end = end === undefined ? this.length : end >>> 0;
  3659. if (!val)
  3660. val = 0;
  3661. var i;
  3662. if (typeof val === 'number') {
  3663. for (i = start; i < end; ++i) {
  3664. this[i] = val;
  3665. }
  3666. }
  3667. else {
  3668. var bytes = Buffer.isBuffer(val)
  3669. ? val
  3670. // @ts-ignore
  3671. : Buffer.from(val, encoding);
  3672. var len = bytes.length;
  3673. if (len === 0) {
  3674. throw new TypeError('The value "' + val +
  3675. '" is invalid for argument "value"');
  3676. }
  3677. for (i = 0; i < end - start; ++i) {
  3678. this[i + start] = bytes[i % len];
  3679. }
  3680. }
  3681. return this;
  3682. };
  3683. // HELPER FUNCTIONS
  3684. // ================
  3685. var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
  3686. function base64clean(str) {
  3687. // Node takes equal signs as end of the Base64 encoding
  3688. str = str.split('=')[0];
  3689. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  3690. str = str.trim().replace(INVALID_BASE64_RE, '');
  3691. // Node converts strings with length < 2 to ''
  3692. if (str.length < 2)
  3693. return '';
  3694. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  3695. while (str.length % 4 !== 0) {
  3696. str = str + '=';
  3697. }
  3698. return str;
  3699. }
  3700. function toHex(n) {
  3701. if (n < 16)
  3702. return '0' + n.toString(16);
  3703. return n.toString(16);
  3704. }
  3705. function utf8ToBytes(string, units) {
  3706. units = units || Infinity;
  3707. var codePoint;
  3708. var length = string.length;
  3709. var leadSurrogate = null;
  3710. var bytes = [];
  3711. for (var i = 0; i < length; ++i) {
  3712. codePoint = string.charCodeAt(i);
  3713. // is surrogate component
  3714. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  3715. // last char was a lead
  3716. if (!leadSurrogate) {
  3717. // no lead yet
  3718. if (codePoint > 0xDBFF) {
  3719. // unexpected trail
  3720. if ((units -= 3) > -1)
  3721. bytes.push(0xEF, 0xBF, 0xBD);
  3722. continue;
  3723. }
  3724. else if (i + 1 === length) {
  3725. // unpaired lead
  3726. if ((units -= 3) > -1)
  3727. bytes.push(0xEF, 0xBF, 0xBD);
  3728. continue;
  3729. }
  3730. // valid lead
  3731. leadSurrogate = codePoint;
  3732. continue;
  3733. }
  3734. // 2 leads in a row
  3735. if (codePoint < 0xDC00) {
  3736. if ((units -= 3) > -1)
  3737. bytes.push(0xEF, 0xBF, 0xBD);
  3738. leadSurrogate = codePoint;
  3739. continue;
  3740. }
  3741. // valid surrogate pair
  3742. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
  3743. }
  3744. else if (leadSurrogate) {
  3745. // valid bmp char, but last char was a lead
  3746. if ((units -= 3) > -1)
  3747. bytes.push(0xEF, 0xBF, 0xBD);
  3748. }
  3749. leadSurrogate = null;
  3750. // encode utf8
  3751. if (codePoint < 0x80) {
  3752. if ((units -= 1) < 0)
  3753. break;
  3754. bytes.push(codePoint);
  3755. }
  3756. else if (codePoint < 0x800) {
  3757. if ((units -= 2) < 0)
  3758. break;
  3759. bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
  3760. }
  3761. else if (codePoint < 0x10000) {
  3762. if ((units -= 3) < 0)
  3763. break;
  3764. bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  3765. }
  3766. else if (codePoint < 0x110000) {
  3767. if ((units -= 4) < 0)
  3768. break;
  3769. bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
  3770. }
  3771. else {
  3772. throw new Error('Invalid code point');
  3773. }
  3774. }
  3775. return bytes;
  3776. }
  3777. function asciiToBytes(str) {
  3778. var byteArray = [];
  3779. for (var i = 0; i < str.length; ++i) {
  3780. // Node's code seems to be doing this and not & 0x7F..
  3781. byteArray.push(str.charCodeAt(i) & 0xFF);
  3782. }
  3783. return byteArray;
  3784. }
  3785. function utf16leToBytes(str, units) {
  3786. var c, hi, lo;
  3787. var byteArray = [];
  3788. for (var i = 0; i < str.length; ++i) {
  3789. if ((units -= 2) < 0)
  3790. break;
  3791. c = str.charCodeAt(i);
  3792. hi = c >> 8;
  3793. lo = c % 256;
  3794. byteArray.push(lo);
  3795. byteArray.push(hi);
  3796. }
  3797. return byteArray;
  3798. }
  3799. function base64ToBytes(str) {
  3800. // @ts-ignore
  3801. return base64.toByteArray(base64clean(str));
  3802. }
  3803. function blitBuffer(src, dst, offset, length) {
  3804. for (var i = 0; i < length; ++i) {
  3805. if ((i + offset >= dst.length) || (i >= src.length))
  3806. break;
  3807. dst[i + offset] = src[i];
  3808. }
  3809. return i;
  3810. }
  3811. // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
  3812. // the `instanceof` check but they should be treated as of that type.
  3813. // See: https://github.com/feross/buffer/issues/166
  3814. function isInstance(obj, type) {
  3815. return obj instanceof type ||
  3816. (obj != null && obj.constructor != null && obj.constructor.name != null &&
  3817. obj.constructor.name === type.name);
  3818. }
  3819. function numberIsNaN(obj) {
  3820. // For IE11 support
  3821. return obj !== obj; // eslint-disable-line no-self-compare
  3822. }
  3823. }).call(this,require("buffer").Buffer)
  3824. },{"base64-js":1,"buffer":2,"ieee754":3}],10:[function(require,module,exports){
  3825. "use strict";
  3826. // https://gist.github.com/mudge/5830382#gistcomment-2658721
  3827. var __spreadArrays = (this && this.__spreadArrays) || function () {
  3828. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  3829. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  3830. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  3831. r[k] = a[j];
  3832. return r;
  3833. };
  3834. Object.defineProperty(exports, "__esModule", { value: true });
  3835. exports.EventEmitter = void 0;
  3836. var EventEmitter = /** @class */ (function () {
  3837. function EventEmitter() {
  3838. this.events = {};
  3839. }
  3840. EventEmitter.prototype.on = function (event, listener) {
  3841. var _this = this;
  3842. if (typeof this.events[event] !== 'object') {
  3843. this.events[event] = [];
  3844. }
  3845. this.events[event].push(listener);
  3846. return function () { return _this.removeListener(event, listener); };
  3847. };
  3848. EventEmitter.prototype.removeListener = function (event, listener) {
  3849. if (typeof this.events[event] !== 'object') {
  3850. return;
  3851. }
  3852. var idx = this.events[event].indexOf(listener);
  3853. if (idx > -1) {
  3854. this.events[event].splice(idx, 1);
  3855. }
  3856. };
  3857. EventEmitter.prototype.removeAllListeners = function () {
  3858. var _this = this;
  3859. Object.keys(this.events).forEach(function (event) { return _this.events[event].splice(0, _this.events[event].length); });
  3860. };
  3861. EventEmitter.prototype.emit = function (event) {
  3862. var _this = this;
  3863. var args = [];
  3864. for (var _i = 1; _i < arguments.length; _i++) {
  3865. args[_i - 1] = arguments[_i];
  3866. }
  3867. if (typeof this.events[event] !== 'object') {
  3868. return;
  3869. }
  3870. __spreadArrays(this.events[event]).forEach(function (listener) { return listener.apply(_this, args); });
  3871. };
  3872. EventEmitter.prototype.once = function (event, listener) {
  3873. var _this = this;
  3874. var remove = this.on(event, function () {
  3875. var args = [];
  3876. for (var _i = 0; _i < arguments.length; _i++) {
  3877. args[_i] = arguments[_i];
  3878. }
  3879. remove();
  3880. listener.apply(_this, args);
  3881. });
  3882. return remove;
  3883. };
  3884. return EventEmitter;
  3885. }());
  3886. exports.EventEmitter = EventEmitter;
  3887. },{}],11:[function(require,module,exports){
  3888. (function (global){
  3889. "use strict";
  3890. Object.defineProperty(exports, "__esModule", { value: true });
  3891. exports.Hub = void 0;
  3892. var eventEmitter_1 = require("../helpers/eventEmitter");
  3893. var buffer_1 = require("../helpers/buffer");
  3894. var Hub = /** @class */ (function () {
  3895. function Hub(bluetooth) {
  3896. this.emitter = new eventEmitter_1.EventEmitter();
  3897. this.autoSubscribe = true;
  3898. this.writeCue = [];
  3899. this.isWriting = false;
  3900. this.bluetooth = bluetooth;
  3901. this.log = console.log;
  3902. this.autoSubscribe = true;
  3903. this.ports = {};
  3904. this.num2type = {
  3905. 23: 'LED',
  3906. 37: 'DISTANCE',
  3907. 38: 'IMOTOR',
  3908. 39: 'MOTOR',
  3909. 40: 'TILT',
  3910. };
  3911. this.port2num = {
  3912. A: 0x00,
  3913. B: 0x01,
  3914. C: 0x02,
  3915. D: 0x03,
  3916. AB: 0x10,
  3917. LED: 0x32,
  3918. TILT: 0x3a,
  3919. };
  3920. this.num2port = Object.entries(this.port2num).reduce(function (acc, _a) {
  3921. var port = _a[0], portNum = _a[1];
  3922. acc[portNum] = port;
  3923. return acc;
  3924. }, {});
  3925. this.num2action = {
  3926. 1: 'start',
  3927. 5: 'conflict',
  3928. 10: 'stop',
  3929. };
  3930. this.num2color = {
  3931. 0: 'black',
  3932. 3: 'blue',
  3933. 5: 'green',
  3934. 7: 'yellow',
  3935. 9: 'red',
  3936. 10: 'white',
  3937. };
  3938. this.ledColors = [
  3939. 'off',
  3940. 'pink',
  3941. 'purple',
  3942. 'blue',
  3943. 'lightblue',
  3944. 'cyan',
  3945. 'green',
  3946. 'yellow',
  3947. 'orange',
  3948. 'red',
  3949. 'white',
  3950. ];
  3951. this.addListeners();
  3952. }
  3953. Hub.prototype.emit = function (type, data) {
  3954. if (data === void 0) { data = null; }
  3955. this.emitter.emit(type, data);
  3956. };
  3957. Hub.prototype.addListeners = function () {
  3958. var _this = this;
  3959. this.bluetooth.addEventListener('characteristicvaluechanged', function (event) {
  3960. // https://googlechrome.github.io/samples/web-bluetooth/read-characteristic-value-changed.html
  3961. // @ts-ignore
  3962. var data = buffer_1.Buffer.from(event.target.value.buffer);
  3963. _this.parseMessage(data);
  3964. });
  3965. global.setTimeout(function () {
  3966. // Without timout missed first characteristicvaluechanged events
  3967. _this.bluetooth.startNotifications();
  3968. }, 1000);
  3969. };
  3970. Hub.prototype.parseMessage = function (data) {
  3971. var _this = this;
  3972. switch (data[2]) {
  3973. case 0x04: {
  3974. global.clearTimeout(this.portInfoTimeout);
  3975. this.portInfoTimeout = global.setTimeout(function () {
  3976. /**
  3977. * Fires when a connection to the Move Hub is established
  3978. * @event Hub#connect
  3979. */
  3980. if (_this.autoSubscribe) {
  3981. _this.subscribeAll();
  3982. }
  3983. if (!_this.connected) {
  3984. _this.connected = true;
  3985. _this.emit('connect');
  3986. }
  3987. }, 1000);
  3988. this.log('Found: ' + this.num2type[data[5]]);
  3989. this.logDebug('Found', data);
  3990. if (data[4] === 0x01) {
  3991. this.ports[data[3]] = {
  3992. type: 'port',
  3993. deviceType: this.num2type[data[5]],
  3994. deviceTypeNum: data[5],
  3995. };
  3996. }
  3997. else if (data[4] === 0x02) {
  3998. this.ports[data[3]] = {
  3999. type: 'group',
  4000. deviceType: this.num2type[data[5]],
  4001. deviceTypeNum: data[5],
  4002. members: [data[7], data[8]],
  4003. };
  4004. }
  4005. break;
  4006. }
  4007. case 0x05: {
  4008. this.log('Malformed message');
  4009. this.log('<', data);
  4010. break;
  4011. }
  4012. case 0x45: {
  4013. this.parseSensor(data);
  4014. break;
  4015. }
  4016. case 0x47: {
  4017. // 0x47 subscription acknowledgements
  4018. // https://github.com/JorgePe/BOOSTreveng/blob/master/Notifications.md
  4019. break;
  4020. }
  4021. case 0x82: {
  4022. /**
  4023. * Fires on port changes
  4024. * @event Hub#port
  4025. * @param port {object}
  4026. * @param port.port {string}
  4027. * @param port.action {string}
  4028. */
  4029. this.emit('port', {
  4030. port: this.num2port[data[3]],
  4031. action: this.num2action[data[4]],
  4032. });
  4033. break;
  4034. }
  4035. default:
  4036. this.log('unknown message type 0x' + data[2].toString(16));
  4037. this.log('<', data);
  4038. }
  4039. };
  4040. Hub.prototype.parseSensor = function (data) {
  4041. if (!this.ports[data[3]]) {
  4042. this.log('parseSensor unknown port 0x' + data[3].toString(16));
  4043. return;
  4044. }
  4045. switch (this.ports[data[3]].deviceType) {
  4046. case 'DISTANCE': {
  4047. /**
  4048. * @event Hub#color
  4049. * @param color {string}
  4050. */
  4051. this.emit('color', this.num2color[data[4]]);
  4052. // TODO: improve distance calculation!
  4053. var distance = void 0;
  4054. if (data[7] > 0 && data[5] < 2) {
  4055. distance = Math.floor(20 - data[7] * 2.85);
  4056. }
  4057. else if (data[5] > 9) {
  4058. distance = Infinity;
  4059. }
  4060. else {
  4061. distance = Math.floor(20 + data[5] * 18);
  4062. }
  4063. /**
  4064. * @event Hub#distance
  4065. * @param distance {number} distance in millimeters
  4066. */
  4067. this.emit('distance', distance);
  4068. break;
  4069. }
  4070. case 'TILT': {
  4071. var roll = data.readInt8(4);
  4072. var pitch = data.readInt8(5);
  4073. /**
  4074. * @event Hub#tilt
  4075. * @param tilt {object}
  4076. * @param tilt.roll {number}
  4077. * @param tilt.pitch {number}
  4078. */
  4079. this.emit('tilt', { roll: roll, pitch: pitch });
  4080. break;
  4081. }
  4082. case 'MOTOR':
  4083. case 'IMOTOR': {
  4084. var angle = data.readInt32LE(4);
  4085. /**
  4086. * @event Hub#rotation
  4087. * @param rotation {object}
  4088. * @param rotation.port {string}
  4089. * @param rotation.angle
  4090. */
  4091. this.emit('rotation', {
  4092. port: this.num2port[data[3]],
  4093. angle: angle,
  4094. });
  4095. break;
  4096. }
  4097. default:
  4098. this.log('unknown sensor type 0x' + data[3].toString(16), data[3], this.ports[data[3]].deviceType);
  4099. }
  4100. };
  4101. /**
  4102. * Set Move Hub as disconnected
  4103. * @method Hub#setDisconnected
  4104. */
  4105. Hub.prototype.setDisconnected = function () {
  4106. // TODO: Should get this from some notification?
  4107. this.connected = false;
  4108. this.noReconnect = true;
  4109. this.writeCue = [];
  4110. };
  4111. /**
  4112. * Run a motor for specific time
  4113. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  4114. * @param {number} seconds
  4115. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  4116. * is counterclockwise.
  4117. * @param {function} [callback]
  4118. */
  4119. Hub.prototype.motorTime = function (port, seconds, dutyCycle, callback) {
  4120. if (typeof dutyCycle === 'function') {
  4121. callback = dutyCycle;
  4122. dutyCycle = 100;
  4123. }
  4124. var portNum = typeof port === 'string' ? this.port2num[port] : port;
  4125. this.write(this.encodeMotorTime(portNum, seconds, dutyCycle), callback);
  4126. };
  4127. /**
  4128. * Run both motors (A and B) for specific time
  4129. * @param {number} seconds
  4130. * @param {number} dutyCycleA motor power percentage from `-100` to `100`. If a negative value is given rotation
  4131. * is counterclockwise.
  4132. * @param {number} dutyCycleB motor power percentage from `-100` to `100`. If a negative value is given rotation
  4133. * is counterclockwise.
  4134. * @param {function} callback
  4135. */
  4136. Hub.prototype.motorTimeMulti = function (seconds, dutyCycleA, dutyCycleB, callback) {
  4137. this.write(this.encodeMotorTimeMulti(this.port2num['AB'], seconds, dutyCycleA, dutyCycleB), callback);
  4138. };
  4139. /**
  4140. * Turn a motor by specific angle
  4141. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  4142. * @param {number} angle - degrees to turn from `0` to `2147483647`
  4143. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given
  4144. * rotation is counterclockwise.
  4145. * @param {function} [callback]
  4146. */
  4147. Hub.prototype.motorAngle = function (port, angle, dutyCycle, callback) {
  4148. if (typeof dutyCycle === 'function') {
  4149. callback = dutyCycle;
  4150. dutyCycle = 100;
  4151. }
  4152. var portNum = typeof port === 'string' ? this.port2num[port] : port;
  4153. this.write(this.encodeMotorAngle(portNum, angle, dutyCycle), callback);
  4154. };
  4155. /**
  4156. * Turn both motors (A and B) by specific angle
  4157. * @param {number} angle degrees to turn from `0` to `2147483647`
  4158. * @param {number} dutyCycleA motor power percentage from `-100` to `100`. If a negative value is given
  4159. * rotation is counterclockwise.
  4160. * @param {number} dutyCycleB motor power percentage from `-100` to `100`. If a negative value is given
  4161. * rotation is counterclockwise.
  4162. * @param {function} callback
  4163. */
  4164. Hub.prototype.motorAngleMulti = function (angle, dutyCycleA, dutyCycleB, callback) {
  4165. this.write(this.encodeMotorAngleMulti(this.port2num['AB'], angle, dutyCycleA, dutyCycleB), callback);
  4166. };
  4167. /**
  4168. * Send raw data
  4169. * @param {object} raw raw data
  4170. * @param {function} callback
  4171. */
  4172. Hub.prototype.rawCommand = function (raw, callback) {
  4173. // @ts-ignore
  4174. var buf = buffer_1.Buffer.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
  4175. for (var idx in raw) {
  4176. buf.writeIntLE(raw[idx], idx);
  4177. }
  4178. this.write(buf, callback);
  4179. };
  4180. Hub.prototype.motorPowerCommand = function (port, power) {
  4181. this.write(this.encodeMotorPower(port, power));
  4182. };
  4183. //[0x09, 0x00, 0x81, 0x39, 0x11, 0x07, 0x00, 0x64, 0x03]
  4184. Hub.prototype.encodeMotorPower = function (port, dutyCycle) {
  4185. if (dutyCycle === void 0) { dutyCycle = 100; }
  4186. var portNum = typeof port === 'string' ? this.port2num[port] : port;
  4187. // @ts-ignore
  4188. var buf = buffer_1.Buffer.from([0x09, 0x00, 0x81, portNum, 0x11, 0x07, 0x00, 0x64, 0x03]);
  4189. //buf.writeUInt16LE(seconds * 1000, 6);
  4190. buf.writeInt8(dutyCycle, 6);
  4191. return buf;
  4192. };
  4193. //0x0C, 0x00, 0x81, port, 0x11, 0x09, 0x00, 0x00, 0x00, 0x64, 0x7F, 0x03
  4194. /**
  4195. * Control the LED on the Move Hub
  4196. * @method Hub#led
  4197. * @param {boolean|number|string} color
  4198. * If set to boolean `false` the LED is switched off, if set to `true` the LED will be white.
  4199. * Possible string values: `off`, `pink`, `purple`, `blue`, `lightblue`, `cyan`, `green`, `yellow`, `orange`, `red`,
  4200. * `white`
  4201. * @param {function} [callback]
  4202. */
  4203. Hub.prototype.led = function (color, callback) {
  4204. this.write(this.encodeLed(color), callback);
  4205. };
  4206. /**
  4207. * Subscribe for sensor notifications
  4208. * @param {string|number} port - e.g. call `.subscribe('C')` if you have your distance/color sensor on port C.
  4209. * @param {number} [option=0] Unknown meaning. Needs to be 0 for distance/color, 2 for motors, 8 for tilt
  4210. * @param {function} [callback]
  4211. */
  4212. Hub.prototype.subscribe = function (port, option, callback) {
  4213. if (option === void 0) { option = 0; }
  4214. if (typeof option === 'function') {
  4215. // TODO: Why we have function check here?
  4216. callback = option;
  4217. option = 0x00;
  4218. }
  4219. var portNum = typeof port === 'string' ? this.port2num[port] : port;
  4220. this.write(
  4221. // @ts-ignore
  4222. buffer_1.Buffer.from([0x0a, 0x00, 0x41, portNum, option, 0x01, 0x00, 0x00, 0x00, 0x01]), callback);
  4223. };
  4224. /**
  4225. * Unsubscribe from sensor notifications
  4226. * @param {string|number} port
  4227. * @param {number} [option=0] Unknown meaning. Needs to be 0 for distance/color, 2 for motors, 8 for tilt
  4228. * @param {function} [callback]
  4229. */
  4230. Hub.prototype.unsubscribe = function (port, option, callback) {
  4231. if (option === void 0) { option = 0; }
  4232. if (typeof option === 'function') {
  4233. callback = option;
  4234. option = 0x00;
  4235. }
  4236. var portNum = typeof port === 'string' ? this.port2num[port] : port;
  4237. this.write(
  4238. // @ts-ignore
  4239. buffer_1.Buffer.from([0x0a, 0x00, 0x41, portNum, option, 0x01, 0x00, 0x00, 0x00, 0x00]), callback);
  4240. };
  4241. Hub.prototype.subscribeAll = function () {
  4242. var _this = this;
  4243. Object.entries(this.ports).forEach(function (_a) {
  4244. var port = _a[0], data = _a[1];
  4245. if (data.deviceType === 'DISTANCE') {
  4246. _this.subscribe(parseInt(port, 10), 8);
  4247. }
  4248. else if (data.deviceType === 'TILT') {
  4249. _this.subscribe(parseInt(port, 10), 0);
  4250. }
  4251. else if (data.deviceType === 'IMOTOR') {
  4252. _this.subscribe(parseInt(port, 10), 2);
  4253. }
  4254. else if (data.deviceType === 'MOTOR') {
  4255. _this.subscribe(parseInt(port, 10), 2);
  4256. }
  4257. else {
  4258. _this.logDebug("Port subscribtion not sent: " + port);
  4259. }
  4260. });
  4261. };
  4262. /**
  4263. * Send data over BLE
  4264. * @method Hub#write
  4265. * @param {string|Buffer} data If a string is given it has to have hex bytes separated by spaces, e.g. `0a 01 c3 b2`
  4266. * @param {function} callback
  4267. */
  4268. Hub.prototype.write = function (data, callback) {
  4269. if (typeof data === 'string') {
  4270. var arr_1 = [];
  4271. data.split(' ').forEach(function (c) {
  4272. arr_1.push(parseInt(c, 16));
  4273. });
  4274. // @ts-ignore
  4275. data = buffer_1.Buffer.from(arr_1);
  4276. }
  4277. // Original implementation passed secondArg to define if response is waited
  4278. this.writeCue.push({
  4279. data: data,
  4280. secondArg: true,
  4281. callback: callback,
  4282. });
  4283. this.writeFromCue();
  4284. };
  4285. Hub.prototype.writeFromCue = function () {
  4286. var _this = this;
  4287. if (this.writeCue.length === 0 || this.isWriting)
  4288. return;
  4289. var el = this.writeCue.shift();
  4290. this.logDebug('Writing to device', el);
  4291. this.isWriting = true;
  4292. this.bluetooth
  4293. .writeValue(el.data)
  4294. .then(function () {
  4295. _this.isWriting = false;
  4296. if (typeof el.callback === 'function')
  4297. el.callback();
  4298. })
  4299. .catch(function (err) {
  4300. _this.isWriting = false;
  4301. _this.log("Error while writing: " + el.data + " - Error " + err.toString());
  4302. // TODO: Notify of failure
  4303. })
  4304. .finally(function () {
  4305. _this.writeFromCue();
  4306. });
  4307. };
  4308. Hub.prototype.encodeMotorTimeMulti = function (port, seconds, dutyCycleA, dutyCycleB) {
  4309. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  4310. if (dutyCycleB === void 0) { dutyCycleB = -100; }
  4311. // @ts-ignore
  4312. var buf = buffer_1.Buffer.from([0x0d, 0x00, 0x81, port, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);
  4313. buf.writeUInt16LE(seconds * 1000, 6);
  4314. buf.writeInt8(dutyCycleA, 8);
  4315. buf.writeInt8(dutyCycleB, 9);
  4316. return buf;
  4317. };
  4318. Hub.prototype.encodeMotorTime = function (port, seconds, dutyCycle) {
  4319. if (dutyCycle === void 0) { dutyCycle = 100; }
  4320. // @ts-ignore
  4321. var buf = buffer_1.Buffer.from([0x0c, 0x00, 0x81, port, 0x11, 0x09, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);
  4322. buf.writeUInt16LE(seconds * 1000, 6);
  4323. buf.writeInt8(dutyCycle, 8);
  4324. return buf;
  4325. };
  4326. Hub.prototype.encodeMotorAngleMulti = function (port, angle, dutyCycleA, dutyCycleB) {
  4327. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  4328. if (dutyCycleB === void 0) { dutyCycleB = -100; }
  4329. // @ts-ignore
  4330. var buf = buffer_1.Buffer.from([0x0f, 0x00, 0x81, port, 0x11, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);
  4331. buf.writeUInt32LE(angle, 6);
  4332. buf.writeInt8(dutyCycleA, 10);
  4333. buf.writeInt8(dutyCycleB, 11);
  4334. return buf;
  4335. };
  4336. Hub.prototype.encodeMotorAngle = function (port, angle, dutyCycle) {
  4337. if (dutyCycle === void 0) { dutyCycle = 100; }
  4338. // @ts-ignore
  4339. var buf = buffer_1.Buffer.from([0x0e, 0x00, 0x81, port, 0x11, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x7f, 0x03]);
  4340. buf.writeUInt32LE(angle, 6);
  4341. buf.writeInt8(dutyCycle, 10);
  4342. return buf;
  4343. };
  4344. Hub.prototype.encodeLed = function (color) {
  4345. if (typeof color === 'boolean') {
  4346. color = color ? 'white' : 'off';
  4347. }
  4348. var colorNum = typeof color === 'string' ? this.ledColors.indexOf(color) : color;
  4349. // @ts-ignore
  4350. return buffer_1.Buffer.from([0x08, 0x00, 0x81, 0x32, 0x11, 0x51, 0x00, colorNum]);
  4351. };
  4352. return Hub;
  4353. }());
  4354. exports.Hub = Hub;
  4355. }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
  4356. },{"../helpers/buffer":9,"../helpers/eventEmitter":10}],12:[function(require,module,exports){
  4357. "use strict";
  4358. var __extends = (this && this.__extends) || (function () {
  4359. var extendStatics = function (d, b) {
  4360. extendStatics = Object.setPrototypeOf ||
  4361. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4362. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4363. return extendStatics(d, b);
  4364. };
  4365. return function (d, b) {
  4366. extendStatics(d, b);
  4367. function __() { this.constructor = d; }
  4368. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4369. };
  4370. })();
  4371. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  4372. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4373. return new (P || (P = Promise))(function (resolve, reject) {
  4374. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4375. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4376. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4377. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4378. });
  4379. };
  4380. var __generator = (this && this.__generator) || function (thisArg, body) {
  4381. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  4382. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  4383. function verb(n) { return function (v) { return step([n, v]); }; }
  4384. function step(op) {
  4385. if (f) throw new TypeError("Generator is already executing.");
  4386. while (_) try {
  4387. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4388. if (y = 0, t) op = [op[0] & 2, t.value];
  4389. switch (op[0]) {
  4390. case 0: case 1: t = op; break;
  4391. case 4: _.label++; return { value: op[1], done: false };
  4392. case 5: _.label++; y = op[1]; op = [0]; continue;
  4393. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  4394. default:
  4395. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  4396. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  4397. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  4398. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  4399. if (t[2]) _.ops.pop();
  4400. _.trys.pop(); continue;
  4401. }
  4402. op = body.call(thisArg, _);
  4403. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  4404. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  4405. }
  4406. };
  4407. Object.defineProperty(exports, "__esModule", { value: true });
  4408. exports.HubAsync = exports.DEFAULT_CONFIG = void 0;
  4409. var hub_1 = require("./hub");
  4410. var CALLBACK_TIMEOUT_MS = 1000 / 3;
  4411. exports.DEFAULT_CONFIG = {
  4412. METRIC_MODIFIER: 28.5,
  4413. TURN_MODIFIER: 2.56,
  4414. DRIVE_SPEED: 25,
  4415. TURN_SPEED: 20,
  4416. DEFAULT_STOP_DISTANCE: 105,
  4417. DEFAULT_CLEAR_DISTANCE: 120,
  4418. LEFT_MOTOR: 'A',
  4419. RIGHT_MOTOR: 'B',
  4420. VALID_MOTORS: ['A', 'B'],
  4421. };
  4422. var validateConfiguration = function (configuration) {
  4423. configuration.leftMotor = configuration.leftMotor || exports.DEFAULT_CONFIG.LEFT_MOTOR;
  4424. configuration.rightMotor = configuration.rightMotor || exports.DEFAULT_CONFIG.RIGHT_MOTOR;
  4425. // @ts-ignore
  4426. if (!exports.DEFAULT_CONFIG.VALID_MOTORS.includes(configuration.leftMotor))
  4427. throw Error('Define left port port correctly');
  4428. // @ts-ignore
  4429. if (!exports.DEFAULT_CONFIG.VALID_MOTORS.includes(configuration.rightMotor))
  4430. throw Error('Define right port port correctly');
  4431. if (configuration.leftMotor === configuration.rightMotor)
  4432. throw Error('Left and right motor can not be same');
  4433. configuration.distanceModifier = configuration.distanceModifier || exports.DEFAULT_CONFIG.METRIC_MODIFIER;
  4434. configuration.turnModifier = configuration.turnModifier || exports.DEFAULT_CONFIG.TURN_MODIFIER;
  4435. configuration.driveSpeed = configuration.driveSpeed || exports.DEFAULT_CONFIG.DRIVE_SPEED;
  4436. configuration.turnSpeed = configuration.turnSpeed || exports.DEFAULT_CONFIG.TURN_SPEED;
  4437. configuration.defaultStopDistance = configuration.defaultStopDistance || exports.DEFAULT_CONFIG.DEFAULT_STOP_DISTANCE;
  4438. configuration.defaultClearDistance = configuration.defaultClearDistance || exports.DEFAULT_CONFIG.DEFAULT_CLEAR_DISTANCE;
  4439. };
  4440. var waitForValueToSet = function (valueName, compareFunc, timeoutMs) {
  4441. var _this = this;
  4442. if (compareFunc === void 0) { compareFunc = function (valueNameToCompare) { return _this[valueNameToCompare]; }; }
  4443. if (timeoutMs === void 0) { timeoutMs = 0; }
  4444. if (compareFunc.bind(this)(valueName))
  4445. return Promise.resolve(this[valueName]);
  4446. return new Promise(function (resolve, reject) {
  4447. setTimeout(function () { return __awaiter(_this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
  4448. switch (_b.label) {
  4449. case 0:
  4450. _a = resolve;
  4451. return [4 /*yield*/, waitForValueToSet.bind(this)(valueName, compareFunc, timeoutMs)];
  4452. case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent()])];
  4453. }
  4454. }); }); }, timeoutMs + 100);
  4455. });
  4456. };
  4457. var HubAsync = /** @class */ (function (_super) {
  4458. __extends(HubAsync, _super);
  4459. function HubAsync(bluetooth, configuration) {
  4460. var _this = _super.call(this, bluetooth) || this;
  4461. validateConfiguration(configuration);
  4462. _this.configuration = configuration;
  4463. return _this;
  4464. }
  4465. /**
  4466. * Disconnect Hub
  4467. * @method Hub#disconnectAsync
  4468. * @returns {Promise<boolean>} disconnection successful
  4469. */
  4470. HubAsync.prototype.disconnectAsync = function () {
  4471. this.setDisconnected();
  4472. return waitForValueToSet.bind(this)('hubDisconnected');
  4473. };
  4474. /**
  4475. * Execute this method after new instance of Hub is created
  4476. * @method Hub#afterInitialization
  4477. */
  4478. HubAsync.prototype.afterInitialization = function () {
  4479. var _this = this;
  4480. this.hubDisconnected = null;
  4481. this.portData = {
  4482. A: { angle: 0 },
  4483. B: { angle: 0 },
  4484. AB: { angle: 0 },
  4485. C: { angle: 0 },
  4486. D: { angle: 0 },
  4487. LED: { angle: 0 },
  4488. };
  4489. this.useMetric = true;
  4490. this.modifier = 1;
  4491. this.emitter.on('rotation', function (rotation) { return (_this.portData[rotation.port].angle = rotation.angle); });
  4492. this.emitter.on('disconnect', function () { return (_this.hubDisconnected = true); });
  4493. this.emitter.on('distance', function (distance) { return (_this.distance = distance); });
  4494. };
  4495. /**
  4496. * Control the LED on the Move Hub
  4497. * @method Hub#ledAsync
  4498. * @param {boolean|number|string} color
  4499. * If set to boolean `false` the LED is switched off, if set to `true` the LED will be white.
  4500. * Possible string values: `off`, `pink`, `purple`, `blue`, `lightblue`, `cyan`, `green`, `yellow`, `orange`, `red`,
  4501. * `white`
  4502. * @returns {Promise}
  4503. */
  4504. HubAsync.prototype.ledAsync = function (color) {
  4505. var _this = this;
  4506. return new Promise(function (resolve, reject) {
  4507. _this.led(color, function () {
  4508. // Callback is executed when command is sent and it will take some time before MoveHub executes the command
  4509. setTimeout(resolve, CALLBACK_TIMEOUT_MS);
  4510. });
  4511. });
  4512. };
  4513. /**
  4514. * Run a motor for specific time
  4515. * @method Hub#motorTimeAsync
  4516. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  4517. * @param {number} seconds
  4518. * @param {number} [dutyCycle=100] motor power percentsage from `-100` to `100`. If a negative value is given rotation
  4519. * is counterclockwise.
  4520. * @param {boolean} [wait=false] will promise wait unitll motorTime run time has elapsed
  4521. * @returns {Promise}
  4522. */
  4523. HubAsync.prototype.motorTimeAsync = function (port, seconds, dutyCycle, wait) {
  4524. var _this = this;
  4525. if (dutyCycle === void 0) { dutyCycle = 100; }
  4526. if (wait === void 0) { wait = false; }
  4527. return new Promise(function (resolve, _) {
  4528. _this.motorTime(port, seconds, dutyCycle, function () {
  4529. setTimeout(resolve, wait ? CALLBACK_TIMEOUT_MS + seconds * 1000 : CALLBACK_TIMEOUT_MS);
  4530. });
  4531. });
  4532. };
  4533. /**
  4534. * Run both motors (A and B) for specific time
  4535. * @method Hub#motorTimeMultiAsync
  4536. * @param {number} seconds
  4537. * @param {number} [dutyCycleA=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  4538. * is counterclockwise.
  4539. * @param {number} [dutyCycleB=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  4540. * is counterclockwise.
  4541. * @param {boolean} [wait=false] will promise wait unitll motorTime run time has elapsed
  4542. * @returns {Promise}
  4543. */
  4544. HubAsync.prototype.motorTimeMultiAsync = function (seconds, dutyCycleA, dutyCycleB, wait) {
  4545. var _this = this;
  4546. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  4547. if (dutyCycleB === void 0) { dutyCycleB = 100; }
  4548. if (wait === void 0) { wait = false; }
  4549. return new Promise(function (resolve, _) {
  4550. _this.motorTimeMulti(seconds, dutyCycleA, dutyCycleB, function () {
  4551. setTimeout(resolve, wait ? CALLBACK_TIMEOUT_MS + seconds * 1000 : CALLBACK_TIMEOUT_MS);
  4552. });
  4553. });
  4554. };
  4555. /**
  4556. * Turn a motor by specific angle
  4557. * @method Hub#motorAngleAsync
  4558. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  4559. * @param {number} angle - degrees to turn from `0` to `2147483647`
  4560. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given
  4561. * rotation is counterclockwise.
  4562. * @param {boolean} [wait=false] will promise wait unitll motorAngle has turned
  4563. * @returns {Promise}
  4564. */
  4565. HubAsync.prototype.motorAngleAsync = function (port, angle, dutyCycle, wait) {
  4566. var _this = this;
  4567. if (dutyCycle === void 0) { dutyCycle = 100; }
  4568. if (wait === void 0) { wait = false; }
  4569. return new Promise(function (resolve, _) {
  4570. _this.motorAngle(port, angle, dutyCycle, function () { return __awaiter(_this, void 0, void 0, function () {
  4571. var beforeTurn;
  4572. return __generator(this, function (_a) {
  4573. switch (_a.label) {
  4574. case 0:
  4575. if (!wait) return [3 /*break*/, 5];
  4576. beforeTurn = void 0;
  4577. _a.label = 1;
  4578. case 1:
  4579. beforeTurn = this.portData[port].angle;
  4580. return [4 /*yield*/, new Promise(function (res) { return setTimeout(res, CALLBACK_TIMEOUT_MS); })];
  4581. case 2:
  4582. _a.sent();
  4583. _a.label = 3;
  4584. case 3:
  4585. if (this.portData[port].angle !== beforeTurn) return [3 /*break*/, 1];
  4586. _a.label = 4;
  4587. case 4:
  4588. resolve();
  4589. return [3 /*break*/, 6];
  4590. case 5:
  4591. setTimeout(resolve, CALLBACK_TIMEOUT_MS);
  4592. _a.label = 6;
  4593. case 6: return [2 /*return*/];
  4594. }
  4595. });
  4596. }); });
  4597. });
  4598. };
  4599. /**
  4600. * Turn both motors (A and B) by specific angle
  4601. * @method Hub#motorAngleMultiAsync
  4602. * @param {number} angle degrees to turn from `0` to `2147483647`
  4603. * @param {number} [dutyCycleA=100] motor power percentage from `-100` to `100`. If a negative value is given
  4604. * rotation is counterclockwise.
  4605. * @param {number} [dutyCycleB=100] motor power percentage from `-100` to `100`. If a negative value is given
  4606. * rotation is counterclockwise.
  4607. * @param {boolean} [wait=false] will promise wait unitll motorAngle has turned
  4608. * @returns {Promise}
  4609. */
  4610. HubAsync.prototype.motorAngleMultiAsync = function (angle, dutyCycleA, dutyCycleB, wait) {
  4611. var _this = this;
  4612. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  4613. if (dutyCycleB === void 0) { dutyCycleB = 100; }
  4614. if (wait === void 0) { wait = false; }
  4615. return new Promise(function (resolve, _) {
  4616. _this.motorAngleMulti(angle, dutyCycleA, dutyCycleB, function () { return __awaiter(_this, void 0, void 0, function () {
  4617. var beforeTurn;
  4618. return __generator(this, function (_a) {
  4619. switch (_a.label) {
  4620. case 0:
  4621. if (!wait) return [3 /*break*/, 5];
  4622. beforeTurn = void 0;
  4623. _a.label = 1;
  4624. case 1:
  4625. beforeTurn = this.portData['AB'].angle;
  4626. return [4 /*yield*/, new Promise(function (res) { return setTimeout(res, CALLBACK_TIMEOUT_MS); })];
  4627. case 2:
  4628. _a.sent();
  4629. _a.label = 3;
  4630. case 3:
  4631. if (this.portData['AB'].angle !== beforeTurn) return [3 /*break*/, 1];
  4632. _a.label = 4;
  4633. case 4:
  4634. resolve();
  4635. return [3 /*break*/, 6];
  4636. case 5:
  4637. setTimeout(resolve, CALLBACK_TIMEOUT_MS);
  4638. _a.label = 6;
  4639. case 6: return [2 /*return*/];
  4640. }
  4641. });
  4642. }); });
  4643. });
  4644. };
  4645. /**
  4646. * Use metric units (default)
  4647. * @method Hub#useMetricUnits
  4648. */
  4649. HubAsync.prototype.useMetricUnits = function () {
  4650. this.useMetric = true;
  4651. };
  4652. /**
  4653. * Use imperial units
  4654. * @method Hub#useImperialUnits
  4655. */
  4656. HubAsync.prototype.useImperialUnits = function () {
  4657. this.useMetric = false;
  4658. };
  4659. /**
  4660. * Set friction modifier
  4661. * @method Hub#setFrictionModifier
  4662. * @param {number} modifier friction modifier
  4663. */
  4664. HubAsync.prototype.setFrictionModifier = function (modifier) {
  4665. this.modifier = modifier;
  4666. };
  4667. /**
  4668. * Drive specified distance
  4669. * @method Hub#drive
  4670. * @param {number} distance distance in centimeters (default) or inches. Positive is forward and negative is backward.
  4671. * @param {boolean} [wait=true] will promise wait untill the drive has completed.
  4672. * @returns {Promise}
  4673. */
  4674. HubAsync.prototype.drive = function (distance, wait) {
  4675. if (wait === void 0) { wait = true; }
  4676. var angle = Math.abs(distance) *
  4677. ((this.useMetric ? this.configuration.distanceModifier : this.configuration.distanceModifier / 4) *
  4678. this.modifier);
  4679. var dutyCycleA = this.configuration.driveSpeed * (distance > 0 ? 1 : -1) * (this.configuration.leftMotor === 'A' ? 1 : -1);
  4680. var dutyCycleB = this.configuration.driveSpeed * (distance > 0 ? 1 : -1) * (this.configuration.leftMotor === 'A' ? 1 : -1);
  4681. return this.motorAngleMultiAsync(angle, dutyCycleA, dutyCycleB, wait);
  4682. };
  4683. /**
  4684. * Turn robot specified degrees
  4685. * @method Hub#turn
  4686. * @param {number} degrees degrees to turn. Negative is to the left and positive to the right.
  4687. * @param {boolean} [wait=true] will promise wait untill the turn has completed.
  4688. * @returns {Promise}
  4689. */
  4690. HubAsync.prototype.turn = function (degrees, wait) {
  4691. if (wait === void 0) { wait = true; }
  4692. var angle = Math.abs(degrees) * this.configuration.turnModifier;
  4693. var turnMotorModifier = this.configuration.leftMotor === 'A' ? 1 : -1;
  4694. var leftTurn = this.configuration.turnSpeed * (degrees > 0 ? 1 : -1) * turnMotorModifier;
  4695. var rightTurn = this.configuration.turnSpeed * (degrees > 0 ? -1 : 1) * turnMotorModifier;
  4696. var dutyCycleA = this.configuration.leftMotor === 'A' ? leftTurn : rightTurn;
  4697. var dutyCycleB = this.configuration.leftMotor === 'A' ? rightTurn : leftTurn;
  4698. return this.motorAngleMultiAsync(angle, dutyCycleA, dutyCycleB, wait);
  4699. };
  4700. /**
  4701. * Drive untill sensor shows object in defined distance
  4702. * @method Hub#driveUntil
  4703. * @param {number} [distance=0] distance in centimeters (default) or inches when to stop. Distance sensor is not very sensitive or accurate.
  4704. * By default will stop when sensor notices wall for the first time. Sensor distance values are usualy between 110-50.
  4705. * @param {boolean} [wait=true] will promise wait untill the bot will stop.
  4706. * @returns {Promise}
  4707. */
  4708. HubAsync.prototype.driveUntil = function (distance, wait) {
  4709. if (distance === void 0) { distance = 0; }
  4710. if (wait === void 0) { wait = true; }
  4711. return __awaiter(this, void 0, void 0, function () {
  4712. var distanceCheck, direction, compareFunc;
  4713. var _this = this;
  4714. return __generator(this, function (_a) {
  4715. switch (_a.label) {
  4716. case 0:
  4717. distanceCheck = distance !== 0 ? (this.useMetric ? distance : distance * 2.54) : this.configuration.defaultStopDistance;
  4718. direction = this.configuration.leftMotor === 'A' ? 1 : -1;
  4719. compareFunc = direction === 1 ? function () { return distanceCheck >= _this.distance; } : function () { return distanceCheck <= _this.distance; };
  4720. this.motorTimeMulti(60, this.configuration.driveSpeed * direction, this.configuration.driveSpeed * direction);
  4721. if (!wait) return [3 /*break*/, 3];
  4722. return [4 /*yield*/, waitForValueToSet.bind(this)('distance', compareFunc)];
  4723. case 1:
  4724. _a.sent();
  4725. return [4 /*yield*/, this.motorAngleMultiAsync(0)];
  4726. case 2:
  4727. _a.sent();
  4728. return [3 /*break*/, 4];
  4729. case 3: return [2 /*return*/, waitForValueToSet
  4730. .bind(this)('distance', compareFunc)
  4731. .then(function (_) { return _this.motorAngleMulti(0, 0, 0); })];
  4732. case 4: return [2 /*return*/];
  4733. }
  4734. });
  4735. });
  4736. };
  4737. /**
  4738. * Turn until there is no object in sensors sight
  4739. * @method Hub#turnUntil
  4740. * @param {number} [direction=1] direction to turn to. 1 (or any positive) is to the right and 0 (or any negative) is to the left.
  4741. * @param {boolean} [wait=true] will promise wait untill the bot will stop.
  4742. * @returns {Promise}
  4743. */
  4744. HubAsync.prototype.turnUntil = function (direction, wait) {
  4745. if (direction === void 0) { direction = 1; }
  4746. if (wait === void 0) { wait = true; }
  4747. return __awaiter(this, void 0, void 0, function () {
  4748. var directionModifier;
  4749. var _this = this;
  4750. return __generator(this, function (_a) {
  4751. switch (_a.label) {
  4752. case 0:
  4753. directionModifier = direction > 0 ? 1 : -1;
  4754. this.turn(360 * directionModifier, false);
  4755. if (!wait) return [3 /*break*/, 3];
  4756. return [4 /*yield*/, waitForValueToSet.bind(this)('distance', function () { return _this.distance >= _this.configuration.defaultClearDistance; })];
  4757. case 1:
  4758. _a.sent();
  4759. return [4 /*yield*/, this.turn(0, false)];
  4760. case 2:
  4761. _a.sent();
  4762. return [3 /*break*/, 4];
  4763. case 3: return [2 /*return*/, waitForValueToSet
  4764. .bind(this)('distance', function () { return _this.distance >= _this.configuration.defaultClearDistance; })
  4765. .then(function (_) { return _this.turn(0, false); })];
  4766. case 4: return [2 /*return*/];
  4767. }
  4768. });
  4769. });
  4770. };
  4771. HubAsync.prototype.updateConfiguration = function (configuration) {
  4772. validateConfiguration(configuration);
  4773. this.configuration = configuration;
  4774. };
  4775. return HubAsync;
  4776. }(hub_1.Hub));
  4777. exports.HubAsync = HubAsync;
  4778. },{"./hub":11}],13:[function(require,module,exports){
  4779. "use strict";
  4780. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  4781. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4782. return new (P || (P = Promise))(function (resolve, reject) {
  4783. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4784. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4785. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4786. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4787. });
  4788. };
  4789. var __generator = (this && this.__generator) || function (thisArg, body) {
  4790. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  4791. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  4792. function verb(n) { return function (v) { return step([n, v]); }; }
  4793. function step(op) {
  4794. if (f) throw new TypeError("Generator is already executing.");
  4795. while (_) try {
  4796. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4797. if (y = 0, t) op = [op[0] & 2, t.value];
  4798. switch (op[0]) {
  4799. case 0: case 1: t = op; break;
  4800. case 4: _.label++; return { value: op[1], done: false };
  4801. case 5: _.label++; y = op[1]; op = [0]; continue;
  4802. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  4803. default:
  4804. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  4805. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  4806. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  4807. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  4808. if (t[2]) _.ops.pop();
  4809. _.trys.pop(); continue;
  4810. }
  4811. op = body.call(thisArg, _);
  4812. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  4813. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  4814. }
  4815. };
  4816. Object.defineProperty(exports, "__esModule", { value: true });
  4817. var boostConnector_1 = require("./boostConnector");
  4818. var hubAsync_1 = require("./hub/hubAsync");
  4819. var hub_control_1 = require("./ai/hub-control");
  4820. var LegoBoost = /** @class */ (function () {
  4821. function LegoBoost() {
  4822. this.logDebug = function (s) { };
  4823. /**
  4824. * Information from Lego Boost motors and sensors
  4825. * @property LegoBoost#deviceInfo
  4826. */
  4827. this.deviceInfo = {
  4828. ports: {
  4829. A: { action: '', angle: 0 },
  4830. B: { action: '', angle: 0 },
  4831. AB: { action: '', angle: 0 },
  4832. C: { action: '', angle: 0 },
  4833. D: { action: '', angle: 0 },
  4834. LED: { action: '', angle: 0 },
  4835. },
  4836. tilt: { roll: 0, pitch: 0 },
  4837. distance: Number.MAX_SAFE_INTEGER,
  4838. rssi: 0,
  4839. color: '',
  4840. error: '',
  4841. connected: false,
  4842. };
  4843. /**
  4844. * Input data to used on manual and AI control
  4845. * @property LegoBoost#controlData
  4846. */
  4847. this.controlData = {
  4848. input: null,
  4849. speed: 0,
  4850. turnAngle: 0,
  4851. tilt: { roll: 0, pitch: 0 },
  4852. forceState: null,
  4853. updateInputMode: null,
  4854. controlUpdateTime: undefined,
  4855. state: undefined,
  4856. };
  4857. }
  4858. /**
  4859. * Drive forward until wall is reaced or drive backwards 100meters
  4860. * @method LegoBoost#connect
  4861. * @param {BoostConfiguration} [configuration={}] Lego boost motor and control configuration
  4862. * @returns {Promise}
  4863. */
  4864. LegoBoost.prototype.connect = function (configuration) {
  4865. if (configuration === void 0) { configuration = {}; }
  4866. return __awaiter(this, void 0, void 0, function () {
  4867. var bluetooth, e_1;
  4868. return __generator(this, function (_a) {
  4869. switch (_a.label) {
  4870. case 0:
  4871. _a.trys.push([0, 2, , 3]);
  4872. this.configuration = configuration;
  4873. return [4 /*yield*/, boostConnector_1.BoostConnector.connect(this.handleGattDisconnect.bind(this))];
  4874. case 1:
  4875. bluetooth = _a.sent();
  4876. this.initHub(bluetooth, this.configuration);
  4877. return [3 /*break*/, 3];
  4878. case 2:
  4879. e_1 = _a.sent();
  4880. console.log('Error from connect: ' + e_1);
  4881. return [3 /*break*/, 3];
  4882. case 3: return [2 /*return*/];
  4883. }
  4884. });
  4885. });
  4886. };
  4887. LegoBoost.prototype.initHub = function (bluetooth, configuration) {
  4888. return __awaiter(this, void 0, void 0, function () {
  4889. var _this = this;
  4890. return __generator(this, function (_a) {
  4891. switch (_a.label) {
  4892. case 0:
  4893. this.hub = new hubAsync_1.HubAsync(bluetooth, configuration);
  4894. this.hub.logDebug = this.logDebug;
  4895. this.hub.emitter.on('disconnect', function (evt) { return __awaiter(_this, void 0, void 0, function () {
  4896. return __generator(this, function (_a) {
  4897. return [2 /*return*/];
  4898. });
  4899. }); });
  4900. this.hub.emitter.on('connect', function (evt) { return __awaiter(_this, void 0, void 0, function () {
  4901. return __generator(this, function (_a) {
  4902. switch (_a.label) {
  4903. case 0:
  4904. this.hub.afterInitialization();
  4905. return [4 /*yield*/, this.hub.ledAsync('white')];
  4906. case 1:
  4907. _a.sent();
  4908. this.logDebug('Connected');
  4909. return [2 /*return*/];
  4910. }
  4911. });
  4912. }); });
  4913. this.hubControl = new hub_control_1.HubControl(this.deviceInfo, this.controlData, configuration);
  4914. return [4 /*yield*/, this.hubControl.start(this.hub)];
  4915. case 1:
  4916. _a.sent();
  4917. this.updateTimer = setInterval(function () {
  4918. _this.hubControl.update();
  4919. }, 100);
  4920. return [2 /*return*/];
  4921. }
  4922. });
  4923. });
  4924. };
  4925. LegoBoost.prototype.handleGattDisconnect = function () {
  4926. return __awaiter(this, void 0, void 0, function () {
  4927. return __generator(this, function (_a) {
  4928. this.logDebug('handleGattDisconnect');
  4929. if (this.deviceInfo.connected === false)
  4930. return [2 /*return*/];
  4931. this.hub.setDisconnected();
  4932. this.deviceInfo.connected = false;
  4933. clearInterval(this.updateTimer);
  4934. this.logDebug('Disconnected');
  4935. return [2 /*return*/];
  4936. });
  4937. });
  4938. };
  4939. /**
  4940. * Change the color of the led between pink and orange
  4941. * @method LegoBoost#changeLed
  4942. * @returns {Promise}
  4943. */
  4944. LegoBoost.prototype.changeLed = function () {
  4945. return __awaiter(this, void 0, void 0, function () {
  4946. return __generator(this, function (_a) {
  4947. switch (_a.label) {
  4948. case 0:
  4949. if (!this.hub || this.hub.connected === false)
  4950. return [2 /*return*/];
  4951. this.color = this.color === 'pink' ? 'orange' : 'pink';
  4952. return [4 /*yield*/, this.hub.ledAsync(this.color)];
  4953. case 1:
  4954. _a.sent();
  4955. return [2 /*return*/];
  4956. }
  4957. });
  4958. });
  4959. };
  4960. /**
  4961. * Drive forward until wall is reaced or drive backwards 100meters
  4962. * @method LegoBoost#driveToDirection
  4963. * @param {number} [direction=1] Direction to drive. 1 or positive is forward, 0 or negative is backwards.
  4964. * @returns {Promise}
  4965. */
  4966. LegoBoost.prototype.driveToDirection = function (direction) {
  4967. if (direction === void 0) { direction = 1; }
  4968. return __awaiter(this, void 0, void 0, function () {
  4969. return __generator(this, function (_a) {
  4970. switch (_a.label) {
  4971. case 0:
  4972. if (!this.preCheck())
  4973. return [2 /*return*/];
  4974. if (!(direction > 0)) return [3 /*break*/, 2];
  4975. return [4 /*yield*/, this.hub.driveUntil()];
  4976. case 1: return [2 /*return*/, _a.sent()];
  4977. case 2: return [4 /*yield*/, this.hub.drive(-10000)];
  4978. case 3: return [2 /*return*/, _a.sent()];
  4979. }
  4980. });
  4981. });
  4982. };
  4983. /**
  4984. * Disconnect Lego Boost
  4985. * @method LegoBoost#disconnect
  4986. * @returns {boolean|undefined}
  4987. */
  4988. LegoBoost.prototype.disconnect = function () {
  4989. if (!this.hub || this.hub.connected === false)
  4990. return;
  4991. this.hub.setDisconnected();
  4992. var success = boostConnector_1.BoostConnector.disconnect();
  4993. return success;
  4994. };
  4995. /**
  4996. * Start AI mode
  4997. * @method LegoBoost#ai
  4998. */
  4999. LegoBoost.prototype.ai = function () {
  5000. if (!this.hub || this.hub.connected === false)
  5001. return;
  5002. this.hubControl.setNextState('Drive');
  5003. };
  5004. /**
  5005. * Stop engines A and B
  5006. * @method LegoBoost#stop
  5007. * @returns {Promise}
  5008. */
  5009. LegoBoost.prototype.stop = function () {
  5010. return __awaiter(this, void 0, void 0, function () {
  5011. return __generator(this, function (_a) {
  5012. switch (_a.label) {
  5013. case 0:
  5014. if (!this.preCheck())
  5015. return [2 /*return*/];
  5016. this.controlData.speed = 0;
  5017. this.controlData.turnAngle = 0;
  5018. return [4 /*yield*/, this.hub.motorTimeMultiAsync(1, 0, 0)];
  5019. case 1:
  5020. // control datas values might have always been 0, execute force stop
  5021. return [2 /*return*/, _a.sent()];
  5022. }
  5023. });
  5024. });
  5025. };
  5026. /**
  5027. * Update Boost motor and control configuration
  5028. * @method LegoBoost#updateConfiguration
  5029. * @param {BoostConfiguration} configuration Boost motor and control configuration
  5030. */
  5031. LegoBoost.prototype.updateConfiguration = function (configuration) {
  5032. if (!this.hub)
  5033. return;
  5034. this.hub.updateConfiguration(configuration);
  5035. this.hubControl.updateConfiguration(configuration);
  5036. };
  5037. // Methods from Hub
  5038. /**
  5039. * Control the LED on the Move Hub
  5040. * @method LegoBoost#led
  5041. * @param {boolean|number|string} color
  5042. * If set to boolean `false` the LED is switched off, if set to `true` the LED will be white.
  5043. * Possible string values: `off`, `pink`, `purple`, `blue`, `lightblue`, `cyan`, `green`, `yellow`, `orange`, `red`,
  5044. * `white`
  5045. */
  5046. LegoBoost.prototype.led = function (color) {
  5047. if (!this.preCheck())
  5048. return;
  5049. this.hub.led(color);
  5050. };
  5051. /**
  5052. * Control the LED on the Move Hub
  5053. * @method LegoBoost#ledAsync
  5054. * @param {boolean|number|string} color
  5055. * If set to boolean `false` the LED is switched off, if set to `true` the LED will be white.
  5056. * Possible string values: `off`, `pink`, `purple`, `blue`, `lightblue`, `cyan`, `green`, `yellow`, `orange`, `red`,
  5057. * `white`
  5058. * @returns {Promise}
  5059. */
  5060. LegoBoost.prototype.ledAsync = function (color) {
  5061. return __awaiter(this, void 0, void 0, function () {
  5062. return __generator(this, function (_a) {
  5063. switch (_a.label) {
  5064. case 0:
  5065. if (!this.preCheck())
  5066. return [2 /*return*/];
  5067. this.color = color;
  5068. return [4 /*yield*/, this.hub.ledAsync(color)];
  5069. case 1: return [2 /*return*/, _a.sent()];
  5070. }
  5071. });
  5072. });
  5073. };
  5074. /**
  5075. * Run a motor for specific time
  5076. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  5077. * @param {number} seconds
  5078. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  5079. * is counterclockwise.
  5080. */
  5081. LegoBoost.prototype.motorTime = function (port, seconds, dutyCycle) {
  5082. if (dutyCycle === void 0) { dutyCycle = 100; }
  5083. if (!this.preCheck())
  5084. return;
  5085. this.hub.motorTime(port, seconds, dutyCycle);
  5086. };
  5087. /**
  5088. * Run a motor for specific time
  5089. * @method LegoBoost#motorTimeAsync
  5090. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  5091. * @param {number} seconds
  5092. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  5093. * is counterclockwise.
  5094. * @param {boolean} [wait=false] will promise wait unitll motorTime run time has elapsed
  5095. * @returns {Promise}
  5096. */
  5097. LegoBoost.prototype.motorTimeAsync = function (port, seconds, dutyCycle, wait) {
  5098. if (dutyCycle === void 0) { dutyCycle = 100; }
  5099. if (wait === void 0) { wait = true; }
  5100. return __awaiter(this, void 0, void 0, function () {
  5101. return __generator(this, function (_a) {
  5102. switch (_a.label) {
  5103. case 0:
  5104. if (!this.preCheck())
  5105. return [2 /*return*/];
  5106. return [4 /*yield*/, this.hub.motorTimeAsync(port, seconds, dutyCycle, wait)];
  5107. case 1:
  5108. _a.sent();
  5109. return [2 /*return*/];
  5110. }
  5111. });
  5112. });
  5113. };
  5114. /**
  5115. * Run both motors (A and B) for specific time
  5116. * @param {number} seconds
  5117. * @param {number} dutyCycleA motor power percentage from `-100` to `100`. If a negative value is given rotation
  5118. * is counterclockwise.
  5119. * @param {number} dutyCycleB motor power percentage from `-100` to `100`. If a negative value is given rotation
  5120. * is counterclockwise.
  5121. * @param {function} callback
  5122. */
  5123. LegoBoost.prototype.motorTimeMulti = function (seconds, dutyCycleA, dutyCycleB) {
  5124. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  5125. if (dutyCycleB === void 0) { dutyCycleB = 100; }
  5126. if (!this.preCheck())
  5127. return;
  5128. this.hub.motorTimeMulti(seconds, dutyCycleA, dutyCycleB);
  5129. };
  5130. /**
  5131. * Run both motors (A and B) for specific time
  5132. * @method LegoBoost#motorTimeMultiAsync
  5133. * @param {number} seconds
  5134. * @param {number} [dutyCycleA=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  5135. * is counterclockwise.
  5136. * @param {number} [dutyCycleB=100] motor power percentage from `-100` to `100`. If a negative value is given rotation
  5137. * is counterclockwise.
  5138. * @param {boolean} [wait=false] will promise wait unitll motorTime run time has elapsed
  5139. * @returns {Promise}
  5140. */
  5141. LegoBoost.prototype.motorTimeMultiAsync = function (seconds, dutyCycleA, dutyCycleB, wait) {
  5142. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  5143. if (dutyCycleB === void 0) { dutyCycleB = 100; }
  5144. if (wait === void 0) { wait = true; }
  5145. return __awaiter(this, void 0, void 0, function () {
  5146. return __generator(this, function (_a) {
  5147. switch (_a.label) {
  5148. case 0:
  5149. if (!this.preCheck())
  5150. return [2 /*return*/];
  5151. return [4 /*yield*/, this.hub.motorTimeMultiAsync(seconds, dutyCycleA, dutyCycleB, wait)];
  5152. case 1:
  5153. _a.sent();
  5154. return [2 /*return*/];
  5155. }
  5156. });
  5157. });
  5158. };
  5159. /**
  5160. * Turn a motor by specific angle
  5161. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  5162. * @param {number} angle - degrees to turn from `0` to `2147483647`
  5163. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given
  5164. * rotation is counterclockwise.
  5165. */
  5166. LegoBoost.prototype.motorAngle = function (port, angle, dutyCycle) {
  5167. if (dutyCycle === void 0) { dutyCycle = 100; }
  5168. if (!this.preCheck())
  5169. return;
  5170. this.hub.motorAngle(port, angle, dutyCycle);
  5171. };
  5172. /**
  5173. * Turn a motor by specific angle
  5174. * @method LegoBoost#motorAngleAsync
  5175. * @param {string|number} port possible string values: `A`, `B`, `AB`, `C`, `D`.
  5176. * @param {number} angle - degrees to turn from `0` to `2147483647`
  5177. * @param {number} [dutyCycle=100] motor power percentage from `-100` to `100`. If a negative value is given
  5178. * rotation is counterclockwise.
  5179. * @param {boolean} [wait=false] will promise wait unitll motorAngle has turned
  5180. * @returns {Promise}
  5181. */
  5182. LegoBoost.prototype.motorAngleAsync = function (port, angle, dutyCycle, wait) {
  5183. if (dutyCycle === void 0) { dutyCycle = 100; }
  5184. if (wait === void 0) { wait = true; }
  5185. return __awaiter(this, void 0, void 0, function () {
  5186. return __generator(this, function (_a) {
  5187. switch (_a.label) {
  5188. case 0:
  5189. if (!this.preCheck())
  5190. return [2 /*return*/];
  5191. return [4 /*yield*/, this.hub.motorAngleAsync(port, angle, dutyCycle, wait)];
  5192. case 1:
  5193. _a.sent();
  5194. return [2 /*return*/];
  5195. }
  5196. });
  5197. });
  5198. };
  5199. /**
  5200. * Turn both motors (A and B) by specific angle
  5201. * @method LegoBoost#motorAngleMulti
  5202. * @param {number} angle degrees to turn from `0` to `2147483647`
  5203. * @param {number} dutyCycleA motor power percentage from `-100` to `100`. If a negative value is given
  5204. * rotation is counterclockwise.
  5205. * @param {number} dutyCycleB motor power percentage from `-100` to `100`. If a negative value is given
  5206. * rotation is counterclockwise.
  5207. */
  5208. LegoBoost.prototype.motorAngleMulti = function (angle, dutyCycleA, dutyCycleB) {
  5209. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  5210. if (dutyCycleB === void 0) { dutyCycleB = 100; }
  5211. if (!this.preCheck())
  5212. return;
  5213. this.hub.motorAngleMulti(angle, dutyCycleA, dutyCycleB);
  5214. };
  5215. /**
  5216. * Turn both motors (A and B) by specific angle
  5217. * @method LegoBoost#motorAngleMultiAsync
  5218. * @param {number} angle degrees to turn from `0` to `2147483647`
  5219. * @param {number} [dutyCycleA=100] motor power percentage from `-100` to `100`. If a negative value is given
  5220. * rotation is counterclockwise.
  5221. * @param {number} [dutyCycleB=100] motor power percentage from `-100` to `100`. If a negative value is given
  5222. * rotation is counterclockwise.
  5223. * @param {boolean} [wait=false] will promise wait unitll motorAngle has turned
  5224. * @returns {Promise}
  5225. */
  5226. LegoBoost.prototype.motorAngleMultiAsync = function (angle, dutyCycleA, dutyCycleB, wait) {
  5227. if (dutyCycleA === void 0) { dutyCycleA = 100; }
  5228. if (dutyCycleB === void 0) { dutyCycleB = 100; }
  5229. if (wait === void 0) { wait = true; }
  5230. return __awaiter(this, void 0, void 0, function () {
  5231. return __generator(this, function (_a) {
  5232. switch (_a.label) {
  5233. case 0:
  5234. if (!this.preCheck())
  5235. return [2 /*return*/];
  5236. return [4 /*yield*/, this.hub.motorAngleMultiAsync(angle, dutyCycleA, dutyCycleB, wait)];
  5237. case 1:
  5238. _a.sent();
  5239. return [2 /*return*/];
  5240. }
  5241. });
  5242. });
  5243. };
  5244. /**
  5245. * Drive specified distance
  5246. * @method LegoBoost#drive
  5247. * @param {number} distance distance in centimeters (default) or inches. Positive is forward and negative is backward.
  5248. * @param {boolean} [wait=true] will promise wait untill the drive has completed.
  5249. * @returns {Promise}
  5250. */
  5251. LegoBoost.prototype.drive = function (distance, wait) {
  5252. if (wait === void 0) { wait = true; }
  5253. return __awaiter(this, void 0, void 0, function () {
  5254. return __generator(this, function (_a) {
  5255. switch (_a.label) {
  5256. case 0:
  5257. if (!this.preCheck())
  5258. return [2 /*return*/];
  5259. return [4 /*yield*/, this.hub.drive(distance, wait)];
  5260. case 1: return [2 /*return*/, _a.sent()];
  5261. }
  5262. });
  5263. });
  5264. };
  5265. /**
  5266. * Turn robot specified degrees
  5267. * @method LegoBoost#turn
  5268. * @param {number} degrees degrees to turn. Negative is to the left and positive to the right.
  5269. * @param {boolean} [wait=true] will promise wait untill the turn has completed.
  5270. * @returns {Promise}
  5271. */
  5272. LegoBoost.prototype.turn = function (degrees, wait) {
  5273. if (wait === void 0) { wait = true; }
  5274. return __awaiter(this, void 0, void 0, function () {
  5275. return __generator(this, function (_a) {
  5276. switch (_a.label) {
  5277. case 0:
  5278. if (!this.preCheck())
  5279. return [2 /*return*/];
  5280. return [4 /*yield*/, this.hub.turn(degrees, wait)];
  5281. case 1: return [2 /*return*/, _a.sent()];
  5282. }
  5283. });
  5284. });
  5285. };
  5286. /**
  5287. * Drive untill sensor shows object in defined distance
  5288. * @method LegoBoost#driveUntil
  5289. * @param {number} [distance=0] distance in centimeters (default) or inches when to stop. Distance sensor is not very sensitive or accurate.
  5290. * By default will stop when sensor notices wall for the first time. Sensor distance values are usualy between 110-50.
  5291. * @param {boolean} [wait=true] will promise wait untill the bot will stop.
  5292. * @returns {Promise}
  5293. */
  5294. LegoBoost.prototype.driveUntil = function (distance, wait) {
  5295. if (distance === void 0) { distance = 0; }
  5296. if (wait === void 0) { wait = true; }
  5297. return __awaiter(this, void 0, void 0, function () {
  5298. return __generator(this, function (_a) {
  5299. switch (_a.label) {
  5300. case 0:
  5301. if (!this.preCheck())
  5302. return [2 /*return*/];
  5303. return [4 /*yield*/, this.hub.driveUntil(distance, wait)];
  5304. case 1: return [2 /*return*/, _a.sent()];
  5305. }
  5306. });
  5307. });
  5308. };
  5309. /**
  5310. * Turn until there is no object in sensors sight
  5311. * @method LegoBoost#turnUntil
  5312. * @param {number} [direction=1] direction to turn to. 1 (or any positive) is to the right and 0 (or any negative) is to the left.
  5313. * @param {boolean} [wait=true] will promise wait untill the bot will stop.
  5314. * @returns {Promise}
  5315. */
  5316. LegoBoost.prototype.turnUntil = function (direction, wait) {
  5317. if (direction === void 0) { direction = 1; }
  5318. if (wait === void 0) { wait = true; }
  5319. return __awaiter(this, void 0, void 0, function () {
  5320. return __generator(this, function (_a) {
  5321. switch (_a.label) {
  5322. case 0:
  5323. if (!this.preCheck())
  5324. return [2 /*return*/];
  5325. return [4 /*yield*/, this.hub.turnUntil(direction, wait)];
  5326. case 1: return [2 /*return*/, _a.sent()];
  5327. }
  5328. });
  5329. });
  5330. };
  5331. /**
  5332. * Send raw data
  5333. * @param {object} raw raw data
  5334. */
  5335. LegoBoost.prototype.rawCommand = function (raw) {
  5336. if (!this.preCheck())
  5337. return;
  5338. return this.hub.rawCommand(raw);
  5339. };
  5340. LegoBoost.prototype.preCheck = function () {
  5341. if (!this.hub || this.hub.connected === false)
  5342. return false;
  5343. this.hubControl.setNextState('Manual');
  5344. return true;
  5345. };
  5346. return LegoBoost;
  5347. }());
  5348. exports.default = LegoBoost;
  5349. },{"./ai/hub-control":4,"./boostConnector":7,"./hub/hubAsync":12}]},{},[8])
  5350. //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5v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lQXQoaSlcblxuICAgIC8vIGlzIHN1cnJvZ2F0ZSBjb21wb25lbnRcbiAgICBpZiAoY29kZVBvaW50ID4gMHhEN0ZGICYmIGNvZGVQb2ludCA8IDB4RTAwMCkge1xuICAgICAgLy8gbGFzdCBjaGFyIHdhcyBhIGxlYWRcbiAgICAgIGlmICghbGVhZFN1cnJvZ2F0ZSkge1xuICAgICAgICAvLyBubyBsZWFkIHlldFxuICAgICAgICBpZiAoY29kZVBvaW50ID4gMHhEQkZGKSB7XG4gICAgICAgICAgLy8gdW5leHBlY3RlZCB0cmFpbFxuICAgICAgICAgIGlmICgodW5pdHMgLT0gMykgPiAtMSkgYnl0ZXMucHVzaCgweEVGLCAweEJGLCAweEJEKVxuICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgIH0gZWxzZSBpZiAoaSArIDEgPT09IGxlbmd0aCkge1xuICAgICAgICAgIC8vIHVucGFpcmVkIGxlYWRcbiAgICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpIGJ5dGVzLnB1c2goMHhFRiwgMHhCRiwgMHhCRClcbiAgICAgICAgICBjb250aW51ZVxuICAgICAgICB9XG5cbiAgICAgICAgLy8gdmFsaWQgbGVhZFxuICAgICAgICBsZWFkU3Vycm9nYXRlID0gY29kZVBvaW50XG5cbiAgICAgICAgY29udGludWVcbiAgICAgIH1cblxuICAgICAgLy8gMiBsZWFkcyBpbiBhIHJvd1xuICAgICAgaWYgKGNvZGVQb2ludCA8IDB4REMwMCkge1xuICAgICAgICBpZiAoKHVuaXRzIC09IDMpID4gLTEpIGJ5dGVzLnB1c2goMHhFRiwgMHhCRiwgMHhCRClcbiAgICAgICAgbGVhZFN1cnJvZ2F0ZSA9IGNvZGVQb2ludFxuICAgICAgICBjb250aW51ZVxuICAgICAgfVxuXG4gICAgICAvLyB2YWxpZCBzdXJyb2dhdGUgcGFpclxuICAgICAgY29kZVBvaW50ID0gKGxlYWRTdXJyb2dhdGUgLSAweEQ4MDAgPDwgMTAgfCB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IDAsIDApO1xuICB9XG59XG5cbmV4cG9ydCB7IHN0b3AsIGJhY2ssIGRyaXZlLCB0dXJuLCBzZWVrIH07XG4iLCJpbXBvcnQgeyBIdWJDb250cm9sIH0gZnJvbSAnLi4vaHViLWNvbnRyb2wnO1xuXG5mdW5jdGlvbiBtYW51YWwoaHViQ29udHJvbDogSHViQ29udHJvbCkge1xuICBpZiAoaHViQ29udHJvbC5jb250cm9sLnNwZWVkICE9PSBodWJDb250cm9sLnByZXZDb250cm9sLnNwZWVkIHx8IGh1YkNvbnRyb2wuY29udHJvbC50dXJuQW5nbGUgIT09IGh1YkNvbnRyb2wucHJldkNvbnRyb2wudHVybkFuZ2xlKSB7XG4gICAgbGV0IG1vdG9yQSA9IGh1YkNvbnRyb2wuY29udHJvbC5zcGVlZCArIChodWJDb250cm9sLmNvbnRyb2wudHVybkFuZ2xlID4gMCA/IE1hdGguYWJzKGh1YkNvbnRyb2wuY29udHJvbC50dXJuQW5nbGUpIDogMCk7XG4gICAgbGV0IG1vdG9yQiA9IGh1YkNvbnRyb2wuY29udHJvbC5zcGVlZCArIChodWJDb250cm9sLmNvbnRyb2wudHVybkFuZ2xlIDwgMCA/IE1hdGguYWJzKGh1YkNvbnRyb2wuY29udHJvbC50dXJuQW5nbGUpIDogMCk7XG5cbiAgICBpZiAobW90b3JBID4gMTAwKSB7XG4gICAgICBtb3RvckIgLT0gbW90b3JBIC0gMTAwO1xuICAgICAgbW90b3JBID0gMTAwO1xuICAgIH1cblxuICAgIGlmIChtb3RvckIgPiAxMDApIHtcbiAgICAgIG1vdG9yQSAtPSBtb3RvckIgLSAxMDA7XG4gICAgICBtb3RvckIgPSAxMDA7XG4gICAgfVxuXG4gICAgaHViQ29udHJvbC5jb250cm9sLm1vdG9yQSA9IG1vdG9yQTtcbiAgICBodWJDb250cm9sLmNvbnRyb2wubW90b3JCID0gbW90b3JCO1xuXG4gICAgaHViQ29udHJvbC5odWIubW90b3JUaW1lTXVsdGkoNjAsIG1vdG9yQ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woKTtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBpZiAoIXRoaXMuY29ubmVjdGVkKSB7XG4gICAgICAgICAgICB0aGlzLmNvbm5lY3RlZCA9IHRydWU7XG4gICAgICAgICAgICB0aGlzLmVtaXQoJ2Nvbm5lY3QnKTtcbiAgICAgICAgICB9XG4gICAgICAgIH0sIDEwMDApO1xuXG4gICAgICAgIHRoaXMubG9nKCdGb3VuZDogJyArIHRoaXMubnVtMnR5cGVbZGF0YVs1XV0pO1xuICAgICAgICB0aGlzLmxvZ0RlYnVnKCdGb3VuZCcsIGRhdGEpO1xuXG4gICAgICAgIGlmIChkYXRhWzRdID09PSAweDAxKSB7XG4gICAgICAgICAgdGhpcy5wb3J0c1tkYXRhWzNdXSA9IHtcbiAgICAgICAgICAgIHR5cGU6ICdwb3J0JyxcbiAgICAgICAgICAgIGRldmljZVR5cGU6IHRoaXMubnVtMnR5cGVbZGF0YVs1XV0sXG4gICAgICAgICAgICBkZXZpY2VUeXBlTnVtOiBkYXRhWzVdLFxuICAgICAgICAgIH07XG4gICAgICAgIH0gZWxzZSBpZiAoZGF0YVs0XSA9PT0gMHgwMikge1xuICAgICAgICAgIHRoaXMucG9ydHNbZGF0YVszXV0gPSB7XG4gICAgICAgICAgICB0eXBlOiAnZ3JvdXAnLFxuICAgICAgICAgICAgZGV2aWNlVHlwZTogdGhpcy5udW0ydHlwZVtkYXRhWzVdXSxcbiAgICAgICAgICAgIGRldmljZVR5cGVOdW06IGRhdGFbNV0sXG4gICAgICAgICAgICBtZW1iZXJzOiBbZGF0YVs3XSwgZGF0YVs4XV0sXG4gICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgICBicmVhaztcbiAgICAgIH1cbiAgICAgIGNhc2UgMHgwNToge1xuICAgICAgICB0aGlzLmxvZygnTWFsZm9ybWVkIG1lc3NhZ2UnKTtcbiAgICAgICAgdGhpcy5sb2coJzwnLCBkYXRhKTtcbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG4g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