[{"data":1,"prerenderedAt":1848},["ShallowReactive",2],{"blog:2017:downloading-files-with-progress-in-electron":3,"blogMore-Development":1804,"comments-downloading-files-with-progress-in-electron":1817},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":14,"body":29,"_type":1796,"_id":1797,"_source":1798,"_file":1799,"_stem":1800,"_extension":1801,"url":1802,"wordCount":1803,"minutes":164,"commentCount":115},"/blog/2017/downloading-files-with-progress-in-electron","2017",false,"en","Download files with progress in Electron via window.fetch","Working on Atom lately, I need to be able to download files to disk. We have ways to achieve this, but they do not show the download progress. This leads to confusion and sometimes frustration on larger downloads such as updates or large packages.","2017-03-10T12:25:00+00:00","Development",[13],"JavaScript",{"type":15,"children":16},"root",[17,24],{"type":18,"tag":19,"props":20,"children":21},"element","p",{},[22],{"type":23,"value":9},"text",{"type":18,"tag":19,"props":25,"children":26},{},[27],{"type":23,"value":28},"There are many npm libraries out there, but they either don't expose a progress indicator, or they bypass Chrome (thus not using proxy settings, caching and network inspector) by using Node directly.",{"type":15,"children":30,"toc":1790},[31,35,39,44,51,67,89,95,100,1548,1564,1570,1575,1744,1750,1755,1770,1775,1784],{"type":18,"tag":19,"props":32,"children":33},{},[34],{"type":23,"value":9},{"type":18,"tag":19,"props":36,"children":37},{},[38],{"type":23,"value":28},{"type":18,"tag":19,"props":40,"children":41},{},[42],{"type":23,"value":43},"I'm also not a fan of sprawling dependencies to achieve what can be done simply in a function or two.",{"type":18,"tag":45,"props":46,"children":48},"h2",{"id":47},"hello-windowfetch",[49],{"type":23,"value":50},"Hello window.fetch",{"type":18,"tag":19,"props":52,"children":53},{},[54,56,65],{"type":23,"value":55},"window.fetch is a replacement for XMLHttpRequest currently shipping in Chrome (and therefore Electron) as well as a ",{"type":18,"tag":57,"props":58,"children":62},"a",{"href":59,"rel":60},"https://fetch.spec.whatwg.org",[61],"nofollow",[63],{"type":23,"value":64},"whatWG living standard",{"type":23,"value":66},". There is some documentation around, but most of it grabs the entire content as JSON, a blob, or text which is not advisable for streaming where the files might be large. You want to not only minimize memory impact but also display a progress indicator to your users.",{"type":18,"tag":19,"props":68,"children":69},{},[70,72,79,81,87],{"type":23,"value":71},"Luckily, window.fetch has a ",{"type":18,"tag":73,"props":74,"children":76},"code",{"className":75},[],[77],{"type":23,"value":78},"getReader()",{"type":23,"value":80}," function that gives you a ",{"type":18,"tag":73,"props":82,"children":84},{"className":83},[],[85],{"type":23,"value":86},"ReadableStreamReader",{"type":23,"value":88}," that reads in chunks (32KB on my machine) but isn't compatible with Node's streams, pipes, and data events.",{"type":18,"tag":45,"props":90,"children":92},{"id":91},"download-function",[93],{"type":23,"value":94},"Download function",{"type":18,"tag":19,"props":96,"children":97},{},[98],{"type":23,"value":99},"With a little effort, we can wire these two things up to get us a file downloader that has no extra dependencies outside of Electron, honours the Chrome cache, proxy and network inspector and best of all, is incredibly easy to use;",{"type":18,"tag":101,"props":102,"children":107},"pre",{"className":103,"code":104,"language":105,"meta":106,"style":106},"language-javascript shiki shiki-themes everforest-light dracula","import fs from \"fs\"\n\nexport default async function download(\n  sourceUrl,\n  targetFile,\n  progressCallback,\n  length\n) {\n  const request = new Request(sourceUrl, {\n    headers: new Headers({ \"Content-Type\": \"application/octet-stream\" }),\n  })\n\n  const response = await fetch(request)\n  if (!response.ok) {\n    throw Error(\n      `Unable to download, server returned ${response.status} ${response.statusText}`\n    )\n  }\n\n  const body = response.body\n  if (body == null) {\n    throw Error(\"No response body\")\n  }\n\n  const finalLength =\n    length || parseInt(response.headers.get(\"Content-Length\" || \"0\"), 10)\n  const reader = body.getReader()\n  const writer = fs.createWriteStream(targetFile)\n\n  await streamWithProgress(finalLength, reader, writer, progressCallback)\n  writer.end()\n}\n\nasync function streamWithProgress(length, reader, writer, progressCallback) {\n  let bytesDone = 0\n\n  while (true) {\n    const result = await reader.read()\n    if (result.done) {\n      if (progressCallback != null) {\n        progressCallback(length, 100)\n      }\n      return\n    }\n\n    const chunk = result.value\n    if (chunk == null) {\n      throw Error(\"Empty chunk received during download\")\n    } else {\n      writer.write(Buffer.from(chunk))\n      if (progressCallback != null) {\n        bytesDone += chunk.byteLength\n        const percent =\n          length === 0 ? null : Math.floor((bytesDone / length) * 100)\n        progressCallback(bytesDone, percent)\n      }\n    }\n  }\n}\n","javascript","",[108],{"type":18,"tag":73,"props":109,"children":110},{"__ignoreMap":106},[111,152,162,198,213,226,239,248,262,301,366,375,383,415,454,472,532,541,550,558,588,620,655,663,671,689,779,814,850,858,892,914,923,931,991,1014,1022,1048,1087,1114,1145,1168,1177,1186,1195,1203,1233,1262,1296,1314,1350,1378,1405,1423,1498,1516,1524,1532,1540],{"type":18,"tag":112,"props":113,"children":116},"span",{"class":114,"line":115},"line",1,[117,123,129,135,141,147],{"type":18,"tag":112,"props":118,"children":120},{"style":119},"--shiki-default:#35A77C;--shiki-dark:#FF79C6",[121],{"type":23,"value":122},"import",{"type":18,"tag":112,"props":124,"children":126},{"style":125},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[127],{"type":23,"value":128}," fs ",{"type":18,"tag":112,"props":130,"children":132},{"style":131},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[133],{"type":23,"value":134},"from",{"type":18,"tag":112,"props":136,"children":138},{"style":137},"--shiki-default:#DFA000;--shiki-dark:#E9F284",[139],{"type":23,"value":140}," \"",{"type":18,"tag":112,"props":142,"children":144},{"style":143},"--shiki-default:#DFA000;--shiki-dark:#F1FA8C",[145],{"type":23,"value":146},"fs",{"type":18,"tag":112,"props":148,"children":149},{"style":137},[150],{"type":23,"value":151},"\"\n",{"type":18,"tag":112,"props":153,"children":155},{"class":114,"line":154},2,[156],{"type":18,"tag":112,"props":157,"children":159},{"emptyLinePlaceholder":158},true,[160],{"type":23,"value":161},"\n",{"type":18,"tag":112,"props":163,"children":165},{"class":114,"line":164},3,[166,171,176,182,187,193],{"type":18,"tag":112,"props":167,"children":168},{"style":119},[169],{"type":23,"value":170},"export",{"type":18,"tag":112,"props":172,"children":173},{"style":131},[174],{"type":23,"value":175}," default",{"type":18,"tag":112,"props":177,"children":179},{"style":178},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[180],{"type":23,"value":181}," async",{"type":18,"tag":112,"props":183,"children":184},{"style":131},[185],{"type":23,"value":186}," function",{"type":18,"tag":112,"props":188,"children":190},{"style":189},"--shiki-default:#8DA101;--shiki-dark:#50FA7B",[191],{"type":23,"value":192}," download",{"type":18,"tag":112,"props":194,"children":195},{"style":125},[196],{"type":23,"value":197},"(\n",{"type":18,"tag":112,"props":199,"children":201},{"class":114,"line":200},4,[202,208],{"type":18,"tag":112,"props":203,"children":205},{"style":204},"--shiki-default:#5C6A72;--shiki-default-font-style:inherit;--shiki-dark:#FFB86C;--shiki-dark-font-style:italic",[206],{"type":23,"value":207},"  sourceUrl",{"type":18,"tag":112,"props":209,"children":210},{"style":125},[211],{"type":23,"value":212},",\n",{"type":18,"tag":112,"props":214,"children":216},{"class":114,"line":215},5,[217,222],{"type":18,"tag":112,"props":218,"children":219},{"style":204},[220],{"type":23,"value":221},"  targetFile",{"type":18,"tag":112,"props":223,"children":224},{"style":125},[225],{"type":23,"value":212},{"type":18,"tag":112,"props":227,"children":229},{"class":114,"line":228},6,[230,235],{"type":18,"tag":112,"props":231,"children":232},{"style":204},[233],{"type":23,"value":234},"  progressCallback",{"type":18,"tag":112,"props":236,"children":237},{"style":125},[238],{"type":23,"value":212},{"type":18,"tag":112,"props":240,"children":242},{"class":114,"line":241},7,[243],{"type":18,"tag":112,"props":244,"children":245},{"style":204},[246],{"type":23,"value":247},"  length\n",{"type":18,"tag":112,"props":249,"children":251},{"class":114,"line":250},8,[252,257],{"type":18,"tag":112,"props":253,"children":254},{"style":125},[255],{"type":23,"value":256},")",{"type":18,"tag":112,"props":258,"children":259},{"style":125},[260],{"type":23,"value":261}," {\n",{"type":18,"tag":112,"props":263,"children":265},{"class":114,"line":264},9,[266,271,276,281,287,292,297],{"type":18,"tag":112,"props":267,"children":268},{"style":178},[269],{"type":23,"value":270},"  const",{"type":18,"tag":112,"props":272,"children":273},{"style":125},[274],{"type":23,"value":275}," request",{"type":18,"tag":112,"props":277,"children":278},{"style":178},[279],{"type":23,"value":280}," =",{"type":18,"tag":112,"props":282,"children":284},{"style":283},"--shiki-default:#F85552;--shiki-default-font-weight:inherit;--shiki-dark:#FF79C6;--shiki-dark-font-weight:bold",[285],{"type":23,"value":286}," new",{"type":18,"tag":112,"props":288,"children":289},{"style":189},[290],{"type":23,"value":291}," Request",{"type":18,"tag":112,"props":293,"children":294},{"style":125},[295],{"type":23,"value":296},"(sourceUrl,",{"type":18,"tag":112,"props":298,"children":299},{"style":125},[300],{"type":23,"value":261},{"type":18,"tag":112,"props":302,"children":304},{"class":114,"line":303},10,[305,310,316,320,325,330,334,339,344,348,352,357,361],{"type":18,"tag":112,"props":306,"children":307},{"style":125},[308],{"type":23,"value":309},"    headers",{"type":18,"tag":112,"props":311,"children":313},{"style":312},"--shiki-default:#939F91;--shiki-dark:#FF79C6",[314],{"type":23,"value":315},":",{"type":18,"tag":112,"props":317,"children":318},{"style":283},[319],{"type":23,"value":286},{"type":18,"tag":112,"props":321,"children":322},{"style":189},[323],{"type":23,"value":324}," Headers",{"type":18,"tag":112,"props":326,"children":327},{"style":125},[328],{"type":23,"value":329},"({",{"type":18,"tag":112,"props":331,"children":332},{"style":137},[333],{"type":23,"value":140},{"type":18,"tag":112,"props":335,"children":336},{"style":143},[337],{"type":23,"value":338},"Content-Type",{"type":18,"tag":112,"props":340,"children":341},{"style":137},[342],{"type":23,"value":343},"\"",{"type":18,"tag":112,"props":345,"children":346},{"style":312},[347],{"type":23,"value":315},{"type":18,"tag":112,"props":349,"children":350},{"style":137},[351],{"type":23,"value":140},{"type":18,"tag":112,"props":353,"children":354},{"style":143},[355],{"type":23,"value":356},"application/octet-stream",{"type":18,"tag":112,"props":358,"children":359},{"style":137},[360],{"type":23,"value":343},{"type":18,"tag":112,"props":362,"children":363},{"style":125},[364],{"type":23,"value":365}," }),\n",{"type":18,"tag":112,"props":367,"children":369},{"class":114,"line":368},11,[370],{"type":18,"tag":112,"props":371,"children":372},{"style":125},[373],{"type":23,"value":374},"  })\n",{"type":18,"tag":112,"props":376,"children":378},{"class":114,"line":377},12,[379],{"type":18,"tag":112,"props":380,"children":381},{"emptyLinePlaceholder":158},[382],{"type":23,"value":161},{"type":18,"tag":112,"props":384,"children":386},{"class":114,"line":385},13,[387,391,396,400,405,410],{"type":18,"tag":112,"props":388,"children":389},{"style":178},[390],{"type":23,"value":270},{"type":18,"tag":112,"props":392,"children":393},{"style":125},[394],{"type":23,"value":395}," response",{"type":18,"tag":112,"props":397,"children":398},{"style":178},[399],{"type":23,"value":280},{"type":18,"tag":112,"props":401,"children":402},{"style":131},[403],{"type":23,"value":404}," await",{"type":18,"tag":112,"props":406,"children":407},{"style":189},[408],{"type":23,"value":409}," fetch",{"type":18,"tag":112,"props":411,"children":412},{"style":125},[413],{"type":23,"value":414},"(request)\n",{"type":18,"tag":112,"props":416,"children":418},{"class":114,"line":417},14,[419,424,429,434,439,445,450],{"type":18,"tag":112,"props":420,"children":421},{"style":131},[422],{"type":23,"value":423},"  if",{"type":18,"tag":112,"props":425,"children":426},{"style":125},[427],{"type":23,"value":428}," (",{"type":18,"tag":112,"props":430,"children":431},{"style":178},[432],{"type":23,"value":433},"!",{"type":18,"tag":112,"props":435,"children":436},{"style":125},[437],{"type":23,"value":438},"response",{"type":18,"tag":112,"props":440,"children":442},{"style":441},"--shiki-default:#939F91;--shiki-dark:#F8F8F2",[443],{"type":23,"value":444},".",{"type":18,"tag":112,"props":446,"children":447},{"style":125},[448],{"type":23,"value":449},"ok)",{"type":18,"tag":112,"props":451,"children":452},{"style":125},[453],{"type":23,"value":261},{"type":18,"tag":112,"props":455,"children":457},{"class":114,"line":456},15,[458,463,468],{"type":18,"tag":112,"props":459,"children":460},{"style":131},[461],{"type":23,"value":462},"    throw",{"type":18,"tag":112,"props":464,"children":465},{"style":189},[466],{"type":23,"value":467}," Error",{"type":18,"tag":112,"props":469,"children":470},{"style":125},[471],{"type":23,"value":197},{"type":18,"tag":112,"props":473,"children":475},{"class":114,"line":474},16,[476,481,487,491,495,500,505,510,514,518,523,527],{"type":18,"tag":112,"props":477,"children":478},{"style":143},[479],{"type":23,"value":480},"      `Unable to download, server returned ",{"type":18,"tag":112,"props":482,"children":484},{"style":483},"--shiki-default:#8DA101;--shiki-dark:#FF79C6",[485],{"type":23,"value":486},"${",{"type":18,"tag":112,"props":488,"children":489},{"style":125},[490],{"type":23,"value":438},{"type":18,"tag":112,"props":492,"children":493},{"style":441},[494],{"type":23,"value":444},{"type":18,"tag":112,"props":496,"children":497},{"style":125},[498],{"type":23,"value":499},"status",{"type":18,"tag":112,"props":501,"children":502},{"style":483},[503],{"type":23,"value":504},"}",{"type":18,"tag":112,"props":506,"children":507},{"style":483},[508],{"type":23,"value":509}," ${",{"type":18,"tag":112,"props":511,"children":512},{"style":125},[513],{"type":23,"value":438},{"type":18,"tag":112,"props":515,"children":516},{"style":441},[517],{"type":23,"value":444},{"type":18,"tag":112,"props":519,"children":520},{"style":125},[521],{"type":23,"value":522},"statusText",{"type":18,"tag":112,"props":524,"children":525},{"style":483},[526],{"type":23,"value":504},{"type":18,"tag":112,"props":528,"children":529},{"style":143},[530],{"type":23,"value":531},"`\n",{"type":18,"tag":112,"props":533,"children":535},{"class":114,"line":534},17,[536],{"type":18,"tag":112,"props":537,"children":538},{"style":125},[539],{"type":23,"value":540},"    )\n",{"type":18,"tag":112,"props":542,"children":544},{"class":114,"line":543},18,[545],{"type":18,"tag":112,"props":546,"children":547},{"style":125},[548],{"type":23,"value":549},"  }\n",{"type":18,"tag":112,"props":551,"children":553},{"class":114,"line":552},19,[554],{"type":18,"tag":112,"props":555,"children":556},{"emptyLinePlaceholder":158},[557],{"type":23,"value":161},{"type":18,"tag":112,"props":559,"children":561},{"class":114,"line":560},20,[562,566,571,575,579,583],{"type":18,"tag":112,"props":563,"children":564},{"style":178},[565],{"type":23,"value":270},{"type":18,"tag":112,"props":567,"children":568},{"style":125},[569],{"type":23,"value":570}," body",{"type":18,"tag":112,"props":572,"children":573},{"style":178},[574],{"type":23,"value":280},{"type":18,"tag":112,"props":576,"children":577},{"style":125},[578],{"type":23,"value":395},{"type":18,"tag":112,"props":580,"children":581},{"style":441},[582],{"type":23,"value":444},{"type":18,"tag":112,"props":584,"children":585},{"style":125},[586],{"type":23,"value":587},"body\n",{"type":18,"tag":112,"props":589,"children":591},{"class":114,"line":590},21,[592,596,601,606,612,616],{"type":18,"tag":112,"props":593,"children":594},{"style":131},[595],{"type":23,"value":423},{"type":18,"tag":112,"props":597,"children":598},{"style":125},[599],{"type":23,"value":600}," (body",{"type":18,"tag":112,"props":602,"children":603},{"style":178},[604],{"type":23,"value":605}," ==",{"type":18,"tag":112,"props":607,"children":609},{"style":608},"--shiki-default:#DF69BA;--shiki-dark:#BD93F9",[610],{"type":23,"value":611}," null",{"type":18,"tag":112,"props":613,"children":614},{"style":125},[615],{"type":23,"value":256},{"type":18,"tag":112,"props":617,"children":618},{"style":125},[619],{"type":23,"value":261},{"type":18,"tag":112,"props":621,"children":623},{"class":114,"line":622},22,[624,628,632,637,641,646,650],{"type":18,"tag":112,"props":625,"children":626},{"style":131},[627],{"type":23,"value":462},{"type":18,"tag":112,"props":629,"children":630},{"style":189},[631],{"type":23,"value":467},{"type":18,"tag":112,"props":633,"children":634},{"style":125},[635],{"type":23,"value":636},"(",{"type":18,"tag":112,"props":638,"children":639},{"style":137},[640],{"type":23,"value":343},{"type":18,"tag":112,"props":642,"children":643},{"style":143},[644],{"type":23,"value":645},"No response body",{"type":18,"tag":112,"props":647,"children":648},{"style":137},[649],{"type":23,"value":343},{"type":18,"tag":112,"props":651,"children":652},{"style":125},[653],{"type":23,"value":654},")\n",{"type":18,"tag":112,"props":656,"children":658},{"class":114,"line":657},23,[659],{"type":18,"tag":112,"props":660,"children":661},{"style":125},[662],{"type":23,"value":549},{"type":18,"tag":112,"props":664,"children":666},{"class":114,"line":665},24,[667],{"type":18,"tag":112,"props":668,"children":669},{"emptyLinePlaceholder":158},[670],{"type":23,"value":161},{"type":18,"tag":112,"props":672,"children":674},{"class":114,"line":673},25,[675,679,684],{"type":18,"tag":112,"props":676,"children":677},{"style":178},[678],{"type":23,"value":270},{"type":18,"tag":112,"props":680,"children":681},{"style":125},[682],{"type":23,"value":683}," finalLength",{"type":18,"tag":112,"props":685,"children":686},{"style":178},[687],{"type":23,"value":688}," =\n",{"type":18,"tag":112,"props":690,"children":692},{"class":114,"line":691},26,[693,698,703,708,713,717,722,726,731,735,739,744,748,752,756,761,765,770,775],{"type":18,"tag":112,"props":694,"children":695},{"style":125},[696],{"type":23,"value":697},"    length",{"type":18,"tag":112,"props":699,"children":700},{"style":178},[701],{"type":23,"value":702}," ||",{"type":18,"tag":112,"props":704,"children":705},{"style":189},[706],{"type":23,"value":707}," parseInt",{"type":18,"tag":112,"props":709,"children":710},{"style":125},[711],{"type":23,"value":712},"(response",{"type":18,"tag":112,"props":714,"children":715},{"style":441},[716],{"type":23,"value":444},{"type":18,"tag":112,"props":718,"children":719},{"style":125},[720],{"type":23,"value":721},"headers",{"type":18,"tag":112,"props":723,"children":724},{"style":441},[725],{"type":23,"value":444},{"type":18,"tag":112,"props":727,"children":728},{"style":189},[729],{"type":23,"value":730},"get",{"type":18,"tag":112,"props":732,"children":733},{"style":125},[734],{"type":23,"value":636},{"type":18,"tag":112,"props":736,"children":737},{"style":137},[738],{"type":23,"value":343},{"type":18,"tag":112,"props":740,"children":741},{"style":143},[742],{"type":23,"value":743},"Content-Length",{"type":18,"tag":112,"props":745,"children":746},{"style":137},[747],{"type":23,"value":343},{"type":18,"tag":112,"props":749,"children":750},{"style":178},[751],{"type":23,"value":702},{"type":18,"tag":112,"props":753,"children":754},{"style":137},[755],{"type":23,"value":140},{"type":18,"tag":112,"props":757,"children":758},{"style":143},[759],{"type":23,"value":760},"0",{"type":18,"tag":112,"props":762,"children":763},{"style":137},[764],{"type":23,"value":343},{"type":18,"tag":112,"props":766,"children":767},{"style":125},[768],{"type":23,"value":769},"),",{"type":18,"tag":112,"props":771,"children":772},{"style":608},[773],{"type":23,"value":774}," 10",{"type":18,"tag":112,"props":776,"children":777},{"style":125},[778],{"type":23,"value":654},{"type":18,"tag":112,"props":780,"children":782},{"class":114,"line":781},27,[783,787,792,796,800,804,809],{"type":18,"tag":112,"props":784,"children":785},{"style":178},[786],{"type":23,"value":270},{"type":18,"tag":112,"props":788,"children":789},{"style":125},[790],{"type":23,"value":791}," reader",{"type":18,"tag":112,"props":793,"children":794},{"style":178},[795],{"type":23,"value":280},{"type":18,"tag":112,"props":797,"children":798},{"style":125},[799],{"type":23,"value":570},{"type":18,"tag":112,"props":801,"children":802},{"style":441},[803],{"type":23,"value":444},{"type":18,"tag":112,"props":805,"children":806},{"style":189},[807],{"type":23,"value":808},"getReader",{"type":18,"tag":112,"props":810,"children":811},{"style":125},[812],{"type":23,"value":813},"()\n",{"type":18,"tag":112,"props":815,"children":817},{"class":114,"line":816},28,[818,822,827,831,836,840,845],{"type":18,"tag":112,"props":819,"children":820},{"style":178},[821],{"type":23,"value":270},{"type":18,"tag":112,"props":823,"children":824},{"style":125},[825],{"type":23,"value":826}," writer",{"type":18,"tag":112,"props":828,"children":829},{"style":178},[830],{"type":23,"value":280},{"type":18,"tag":112,"props":832,"children":833},{"style":125},[834],{"type":23,"value":835}," fs",{"type":18,"tag":112,"props":837,"children":838},{"style":441},[839],{"type":23,"value":444},{"type":18,"tag":112,"props":841,"children":842},{"style":189},[843],{"type":23,"value":844},"createWriteStream",{"type":18,"tag":112,"props":846,"children":847},{"style":125},[848],{"type":23,"value":849},"(targetFile)\n",{"type":18,"tag":112,"props":851,"children":853},{"class":114,"line":852},29,[854],{"type":18,"tag":112,"props":855,"children":856},{"emptyLinePlaceholder":158},[857],{"type":23,"value":161},{"type":18,"tag":112,"props":859,"children":861},{"class":114,"line":860},30,[862,867,872,877,882,887],{"type":18,"tag":112,"props":863,"children":864},{"style":131},[865],{"type":23,"value":866},"  await",{"type":18,"tag":112,"props":868,"children":869},{"style":189},[870],{"type":23,"value":871}," streamWithProgress",{"type":18,"tag":112,"props":873,"children":874},{"style":125},[875],{"type":23,"value":876},"(finalLength,",{"type":18,"tag":112,"props":878,"children":879},{"style":125},[880],{"type":23,"value":881}," reader,",{"type":18,"tag":112,"props":883,"children":884},{"style":125},[885],{"type":23,"value":886}," writer,",{"type":18,"tag":112,"props":888,"children":889},{"style":125},[890],{"type":23,"value":891}," progressCallback)\n",{"type":18,"tag":112,"props":893,"children":895},{"class":114,"line":894},31,[896,901,905,910],{"type":18,"tag":112,"props":897,"children":898},{"style":125},[899],{"type":23,"value":900},"  writer",{"type":18,"tag":112,"props":902,"children":903},{"style":441},[904],{"type":23,"value":444},{"type":18,"tag":112,"props":906,"children":907},{"style":189},[908],{"type":23,"value":909},"end",{"type":18,"tag":112,"props":911,"children":912},{"style":125},[913],{"type":23,"value":813},{"type":18,"tag":112,"props":915,"children":917},{"class":114,"line":916},32,[918],{"type":18,"tag":112,"props":919,"children":920},{"style":125},[921],{"type":23,"value":922},"}\n",{"type":18,"tag":112,"props":924,"children":926},{"class":114,"line":925},33,[927],{"type":18,"tag":112,"props":928,"children":929},{"emptyLinePlaceholder":158},[930],{"type":23,"value":161},{"type":18,"tag":112,"props":932,"children":934},{"class":114,"line":933},34,[935,940,944,948,952,957,962,966,970,974,978,983,987],{"type":18,"tag":112,"props":936,"children":937},{"style":178},[938],{"type":23,"value":939},"async",{"type":18,"tag":112,"props":941,"children":942},{"style":131},[943],{"type":23,"value":186},{"type":18,"tag":112,"props":945,"children":946},{"style":189},[947],{"type":23,"value":871},{"type":18,"tag":112,"props":949,"children":950},{"style":125},[951],{"type":23,"value":636},{"type":18,"tag":112,"props":953,"children":954},{"style":204},[955],{"type":23,"value":956},"length",{"type":18,"tag":112,"props":958,"children":959},{"style":125},[960],{"type":23,"value":961},",",{"type":18,"tag":112,"props":963,"children":964},{"style":204},[965],{"type":23,"value":791},{"type":18,"tag":112,"props":967,"children":968},{"style":125},[969],{"type":23,"value":961},{"type":18,"tag":112,"props":971,"children":972},{"style":204},[973],{"type":23,"value":826},{"type":18,"tag":112,"props":975,"children":976},{"style":125},[977],{"type":23,"value":961},{"type":18,"tag":112,"props":979,"children":980},{"style":204},[981],{"type":23,"value":982}," progressCallback",{"type":18,"tag":112,"props":984,"children":985},{"style":125},[986],{"type":23,"value":256},{"type":18,"tag":112,"props":988,"children":989},{"style":125},[990],{"type":23,"value":261},{"type":18,"tag":112,"props":992,"children":994},{"class":114,"line":993},35,[995,1000,1005,1009],{"type":18,"tag":112,"props":996,"children":997},{"style":178},[998],{"type":23,"value":999},"  let",{"type":18,"tag":112,"props":1001,"children":1002},{"style":125},[1003],{"type":23,"value":1004}," bytesDone",{"type":18,"tag":112,"props":1006,"children":1007},{"style":178},[1008],{"type":23,"value":280},{"type":18,"tag":112,"props":1010,"children":1011},{"style":608},[1012],{"type":23,"value":1013}," 0\n",{"type":18,"tag":112,"props":1015,"children":1017},{"class":114,"line":1016},36,[1018],{"type":18,"tag":112,"props":1019,"children":1020},{"emptyLinePlaceholder":158},[1021],{"type":23,"value":161},{"type":18,"tag":112,"props":1023,"children":1025},{"class":114,"line":1024},37,[1026,1031,1035,1040,1044],{"type":18,"tag":112,"props":1027,"children":1028},{"style":131},[1029],{"type":23,"value":1030},"  while",{"type":18,"tag":112,"props":1032,"children":1033},{"style":125},[1034],{"type":23,"value":428},{"type":18,"tag":112,"props":1036,"children":1037},{"style":608},[1038],{"type":23,"value":1039},"true",{"type":18,"tag":112,"props":1041,"children":1042},{"style":125},[1043],{"type":23,"value":256},{"type":18,"tag":112,"props":1045,"children":1046},{"style":125},[1047],{"type":23,"value":261},{"type":18,"tag":112,"props":1049,"children":1051},{"class":114,"line":1050},38,[1052,1057,1062,1066,1070,1074,1078,1083],{"type":18,"tag":112,"props":1053,"children":1054},{"style":178},[1055],{"type":23,"value":1056},"    const",{"type":18,"tag":112,"props":1058,"children":1059},{"style":125},[1060],{"type":23,"value":1061}," result",{"type":18,"tag":112,"props":1063,"children":1064},{"style":178},[1065],{"type":23,"value":280},{"type":18,"tag":112,"props":1067,"children":1068},{"style":131},[1069],{"type":23,"value":404},{"type":18,"tag":112,"props":1071,"children":1072},{"style":125},[1073],{"type":23,"value":791},{"type":18,"tag":112,"props":1075,"children":1076},{"style":441},[1077],{"type":23,"value":444},{"type":18,"tag":112,"props":1079,"children":1080},{"style":189},[1081],{"type":23,"value":1082},"read",{"type":18,"tag":112,"props":1084,"children":1085},{"style":125},[1086],{"type":23,"value":813},{"type":18,"tag":112,"props":1088,"children":1090},{"class":114,"line":1089},39,[1091,1096,1101,1105,1110],{"type":18,"tag":112,"props":1092,"children":1093},{"style":131},[1094],{"type":23,"value":1095},"    if",{"type":18,"tag":112,"props":1097,"children":1098},{"style":125},[1099],{"type":23,"value":1100}," (result",{"type":18,"tag":112,"props":1102,"children":1103},{"style":441},[1104],{"type":23,"value":444},{"type":18,"tag":112,"props":1106,"children":1107},{"style":125},[1108],{"type":23,"value":1109},"done)",{"type":18,"tag":112,"props":1111,"children":1112},{"style":125},[1113],{"type":23,"value":261},{"type":18,"tag":112,"props":1115,"children":1117},{"class":114,"line":1116},40,[1118,1123,1128,1133,1137,1141],{"type":18,"tag":112,"props":1119,"children":1120},{"style":131},[1121],{"type":23,"value":1122},"      if",{"type":18,"tag":112,"props":1124,"children":1125},{"style":125},[1126],{"type":23,"value":1127}," (progressCallback",{"type":18,"tag":112,"props":1129,"children":1130},{"style":178},[1131],{"type":23,"value":1132}," !=",{"type":18,"tag":112,"props":1134,"children":1135},{"style":608},[1136],{"type":23,"value":611},{"type":18,"tag":112,"props":1138,"children":1139},{"style":125},[1140],{"type":23,"value":256},{"type":18,"tag":112,"props":1142,"children":1143},{"style":125},[1144],{"type":23,"value":261},{"type":18,"tag":112,"props":1146,"children":1148},{"class":114,"line":1147},41,[1149,1154,1159,1164],{"type":18,"tag":112,"props":1150,"children":1151},{"style":189},[1152],{"type":23,"value":1153},"        progressCallback",{"type":18,"tag":112,"props":1155,"children":1156},{"style":125},[1157],{"type":23,"value":1158},"(length,",{"type":18,"tag":112,"props":1160,"children":1161},{"style":608},[1162],{"type":23,"value":1163}," 100",{"type":18,"tag":112,"props":1165,"children":1166},{"style":125},[1167],{"type":23,"value":654},{"type":18,"tag":112,"props":1169,"children":1171},{"class":114,"line":1170},42,[1172],{"type":18,"tag":112,"props":1173,"children":1174},{"style":125},[1175],{"type":23,"value":1176},"      }\n",{"type":18,"tag":112,"props":1178,"children":1180},{"class":114,"line":1179},43,[1181],{"type":18,"tag":112,"props":1182,"children":1183},{"style":131},[1184],{"type":23,"value":1185},"      return\n",{"type":18,"tag":112,"props":1187,"children":1189},{"class":114,"line":1188},44,[1190],{"type":18,"tag":112,"props":1191,"children":1192},{"style":125},[1193],{"type":23,"value":1194},"    }\n",{"type":18,"tag":112,"props":1196,"children":1198},{"class":114,"line":1197},45,[1199],{"type":18,"tag":112,"props":1200,"children":1201},{"emptyLinePlaceholder":158},[1202],{"type":23,"value":161},{"type":18,"tag":112,"props":1204,"children":1206},{"class":114,"line":1205},46,[1207,1211,1216,1220,1224,1228],{"type":18,"tag":112,"props":1208,"children":1209},{"style":178},[1210],{"type":23,"value":1056},{"type":18,"tag":112,"props":1212,"children":1213},{"style":125},[1214],{"type":23,"value":1215}," chunk",{"type":18,"tag":112,"props":1217,"children":1218},{"style":178},[1219],{"type":23,"value":280},{"type":18,"tag":112,"props":1221,"children":1222},{"style":125},[1223],{"type":23,"value":1061},{"type":18,"tag":112,"props":1225,"children":1226},{"style":441},[1227],{"type":23,"value":444},{"type":18,"tag":112,"props":1229,"children":1230},{"style":125},[1231],{"type":23,"value":1232},"value\n",{"type":18,"tag":112,"props":1234,"children":1236},{"class":114,"line":1235},47,[1237,1241,1246,1250,1254,1258],{"type":18,"tag":112,"props":1238,"children":1239},{"style":131},[1240],{"type":23,"value":1095},{"type":18,"tag":112,"props":1242,"children":1243},{"style":125},[1244],{"type":23,"value":1245}," (chunk",{"type":18,"tag":112,"props":1247,"children":1248},{"style":178},[1249],{"type":23,"value":605},{"type":18,"tag":112,"props":1251,"children":1252},{"style":608},[1253],{"type":23,"value":611},{"type":18,"tag":112,"props":1255,"children":1256},{"style":125},[1257],{"type":23,"value":256},{"type":18,"tag":112,"props":1259,"children":1260},{"style":125},[1261],{"type":23,"value":261},{"type":18,"tag":112,"props":1263,"children":1265},{"class":114,"line":1264},48,[1266,1271,1275,1279,1283,1288,1292],{"type":18,"tag":112,"props":1267,"children":1268},{"style":131},[1269],{"type":23,"value":1270},"      throw",{"type":18,"tag":112,"props":1272,"children":1273},{"style":189},[1274],{"type":23,"value":467},{"type":18,"tag":112,"props":1276,"children":1277},{"style":125},[1278],{"type":23,"value":636},{"type":18,"tag":112,"props":1280,"children":1281},{"style":137},[1282],{"type":23,"value":343},{"type":18,"tag":112,"props":1284,"children":1285},{"style":143},[1286],{"type":23,"value":1287},"Empty chunk received during download",{"type":18,"tag":112,"props":1289,"children":1290},{"style":137},[1291],{"type":23,"value":343},{"type":18,"tag":112,"props":1293,"children":1294},{"style":125},[1295],{"type":23,"value":654},{"type":18,"tag":112,"props":1297,"children":1299},{"class":114,"line":1298},49,[1300,1305,1310],{"type":18,"tag":112,"props":1301,"children":1302},{"style":125},[1303],{"type":23,"value":1304},"    }",{"type":18,"tag":112,"props":1306,"children":1307},{"style":131},[1308],{"type":23,"value":1309}," else",{"type":18,"tag":112,"props":1311,"children":1312},{"style":125},[1313],{"type":23,"value":261},{"type":18,"tag":112,"props":1315,"children":1317},{"class":114,"line":1316},50,[1318,1323,1327,1332,1337,1341,1345],{"type":18,"tag":112,"props":1319,"children":1320},{"style":125},[1321],{"type":23,"value":1322},"      writer",{"type":18,"tag":112,"props":1324,"children":1325},{"style":441},[1326],{"type":23,"value":444},{"type":18,"tag":112,"props":1328,"children":1329},{"style":189},[1330],{"type":23,"value":1331},"write",{"type":18,"tag":112,"props":1333,"children":1334},{"style":125},[1335],{"type":23,"value":1336},"(Buffer",{"type":18,"tag":112,"props":1338,"children":1339},{"style":441},[1340],{"type":23,"value":444},{"type":18,"tag":112,"props":1342,"children":1343},{"style":189},[1344],{"type":23,"value":134},{"type":18,"tag":112,"props":1346,"children":1347},{"style":125},[1348],{"type":23,"value":1349},"(chunk))\n",{"type":18,"tag":112,"props":1351,"children":1353},{"class":114,"line":1352},51,[1354,1358,1362,1366,1370,1374],{"type":18,"tag":112,"props":1355,"children":1356},{"style":131},[1357],{"type":23,"value":1122},{"type":18,"tag":112,"props":1359,"children":1360},{"style":125},[1361],{"type":23,"value":1127},{"type":18,"tag":112,"props":1363,"children":1364},{"style":178},[1365],{"type":23,"value":1132},{"type":18,"tag":112,"props":1367,"children":1368},{"style":608},[1369],{"type":23,"value":611},{"type":18,"tag":112,"props":1371,"children":1372},{"style":125},[1373],{"type":23,"value":256},{"type":18,"tag":112,"props":1375,"children":1376},{"style":125},[1377],{"type":23,"value":261},{"type":18,"tag":112,"props":1379,"children":1381},{"class":114,"line":1380},52,[1382,1387,1392,1396,1400],{"type":18,"tag":112,"props":1383,"children":1384},{"style":125},[1385],{"type":23,"value":1386},"        bytesDone",{"type":18,"tag":112,"props":1388,"children":1389},{"style":178},[1390],{"type":23,"value":1391}," +=",{"type":18,"tag":112,"props":1393,"children":1394},{"style":125},[1395],{"type":23,"value":1215},{"type":18,"tag":112,"props":1397,"children":1398},{"style":441},[1399],{"type":23,"value":444},{"type":18,"tag":112,"props":1401,"children":1402},{"style":125},[1403],{"type":23,"value":1404},"byteLength\n",{"type":18,"tag":112,"props":1406,"children":1408},{"class":114,"line":1407},53,[1409,1414,1419],{"type":18,"tag":112,"props":1410,"children":1411},{"style":178},[1412],{"type":23,"value":1413},"        const",{"type":18,"tag":112,"props":1415,"children":1416},{"style":125},[1417],{"type":23,"value":1418}," percent",{"type":18,"tag":112,"props":1420,"children":1421},{"style":178},[1422],{"type":23,"value":688},{"type":18,"tag":112,"props":1424,"children":1426},{"class":114,"line":1425},54,[1427,1432,1437,1442,1447,1451,1456,1461,1465,1470,1475,1480,1485,1490,1494],{"type":18,"tag":112,"props":1428,"children":1429},{"style":125},[1430],{"type":23,"value":1431},"          length",{"type":18,"tag":112,"props":1433,"children":1434},{"style":178},[1435],{"type":23,"value":1436}," ===",{"type":18,"tag":112,"props":1438,"children":1439},{"style":608},[1440],{"type":23,"value":1441}," 0",{"type":18,"tag":112,"props":1443,"children":1444},{"style":178},[1445],{"type":23,"value":1446}," ?",{"type":18,"tag":112,"props":1448,"children":1449},{"style":608},[1450],{"type":23,"value":611},{"type":18,"tag":112,"props":1452,"children":1453},{"style":178},[1454],{"type":23,"value":1455}," :",{"type":18,"tag":112,"props":1457,"children":1458},{"style":125},[1459],{"type":23,"value":1460}," Math",{"type":18,"tag":112,"props":1462,"children":1463},{"style":441},[1464],{"type":23,"value":444},{"type":18,"tag":112,"props":1466,"children":1467},{"style":189},[1468],{"type":23,"value":1469},"floor",{"type":18,"tag":112,"props":1471,"children":1472},{"style":125},[1473],{"type":23,"value":1474},"((bytesDone",{"type":18,"tag":112,"props":1476,"children":1477},{"style":178},[1478],{"type":23,"value":1479}," /",{"type":18,"tag":112,"props":1481,"children":1482},{"style":125},[1483],{"type":23,"value":1484}," length)",{"type":18,"tag":112,"props":1486,"children":1487},{"style":178},[1488],{"type":23,"value":1489}," *",{"type":18,"tag":112,"props":1491,"children":1492},{"style":608},[1493],{"type":23,"value":1163},{"type":18,"tag":112,"props":1495,"children":1496},{"style":125},[1497],{"type":23,"value":654},{"type":18,"tag":112,"props":1499,"children":1501},{"class":114,"line":1500},55,[1502,1506,1511],{"type":18,"tag":112,"props":1503,"children":1504},{"style":189},[1505],{"type":23,"value":1153},{"type":18,"tag":112,"props":1507,"children":1508},{"style":125},[1509],{"type":23,"value":1510},"(bytesDone,",{"type":18,"tag":112,"props":1512,"children":1513},{"style":125},[1514],{"type":23,"value":1515}," percent)\n",{"type":18,"tag":112,"props":1517,"children":1519},{"class":114,"line":1518},56,[1520],{"type":18,"tag":112,"props":1521,"children":1522},{"style":125},[1523],{"type":23,"value":1176},{"type":18,"tag":112,"props":1525,"children":1527},{"class":114,"line":1526},57,[1528],{"type":18,"tag":112,"props":1529,"children":1530},{"style":125},[1531],{"type":23,"value":1194},{"type":18,"tag":112,"props":1533,"children":1535},{"class":114,"line":1534},58,[1536],{"type":18,"tag":112,"props":1537,"children":1538},{"style":125},[1539],{"type":23,"value":549},{"type":18,"tag":112,"props":1541,"children":1543},{"class":114,"line":1542},59,[1544],{"type":18,"tag":112,"props":1545,"children":1546},{"style":125},[1547],{"type":23,"value":922},{"type":18,"tag":1549,"props":1550,"children":1551},"blockquote",{},[1552],{"type":18,"tag":19,"props":1553,"children":1554},{},[1555,1557],{"type":23,"value":1556},"A FlowType annotated version is ",{"type":18,"tag":57,"props":1558,"children":1561},{"href":1559,"rel":1560},"https://gist.github.com/damieng/157c0a0f9285d2fc78014a75cfc8f3e4",[61],[1562],{"type":23,"value":1563},"also available",{"type":18,"tag":45,"props":1565,"children":1567},{"id":1566},"using-it",[1568],{"type":23,"value":1569},"Using it",{"type":18,"tag":19,"props":1571,"children":1572},{},[1573],{"type":23,"value":1574},"Using it is simplicity. Call it with a URL to download and a local file name to save it, and an optional callback to receive download progress.",{"type":18,"tag":101,"props":1576,"children":1578},{"className":103,"code":1577,"language":105,"meta":106,"style":106},"Downloader.download(\n  \"https://dl.damieng.com/fonts/original/EnvyCodeR-PR7.zip\",\n  \"envy-code-r.zip\",\n  (bytes, percent) => console.log(`Downloaded ${bytes} (${percent})`)\n)\n",[1579],{"type":18,"tag":73,"props":1580,"children":1581},{"__ignoreMap":106},[1582,1603,1624,1644,1737],{"type":18,"tag":112,"props":1583,"children":1584},{"class":114,"line":115},[1585,1590,1594,1599],{"type":18,"tag":112,"props":1586,"children":1587},{"style":125},[1588],{"type":23,"value":1589},"Downloader",{"type":18,"tag":112,"props":1591,"children":1592},{"style":441},[1593],{"type":23,"value":444},{"type":18,"tag":112,"props":1595,"children":1596},{"style":189},[1597],{"type":23,"value":1598},"download",{"type":18,"tag":112,"props":1600,"children":1601},{"style":125},[1602],{"type":23,"value":197},{"type":18,"tag":112,"props":1604,"children":1605},{"class":114,"line":154},[1606,1611,1616,1620],{"type":18,"tag":112,"props":1607,"children":1608},{"style":137},[1609],{"type":23,"value":1610},"  \"",{"type":18,"tag":112,"props":1612,"children":1613},{"style":143},[1614],{"type":23,"value":1615},"https://dl.damieng.com/fonts/original/EnvyCodeR-PR7.zip",{"type":18,"tag":112,"props":1617,"children":1618},{"style":137},[1619],{"type":23,"value":343},{"type":18,"tag":112,"props":1621,"children":1622},{"style":125},[1623],{"type":23,"value":212},{"type":18,"tag":112,"props":1625,"children":1626},{"class":114,"line":164},[1627,1631,1636,1640],{"type":18,"tag":112,"props":1628,"children":1629},{"style":137},[1630],{"type":23,"value":1610},{"type":18,"tag":112,"props":1632,"children":1633},{"style":143},[1634],{"type":23,"value":1635},"envy-code-r.zip",{"type":18,"tag":112,"props":1637,"children":1638},{"style":137},[1639],{"type":23,"value":343},{"type":18,"tag":112,"props":1641,"children":1642},{"style":125},[1643],{"type":23,"value":212},{"type":18,"tag":112,"props":1645,"children":1646},{"class":114,"line":200},[1647,1652,1657,1662,1667,1672,1677,1682,1686,1691,1695,1700,1704,1708,1712,1716,1720,1724,1728,1733],{"type":18,"tag":112,"props":1648,"children":1649},{"style":125},[1650],{"type":23,"value":1651},"  (",{"type":18,"tag":112,"props":1653,"children":1654},{"style":204},[1655],{"type":23,"value":1656},"bytes",{"type":18,"tag":112,"props":1658,"children":1659},{"style":125},[1660],{"type":23,"value":1661},", ",{"type":18,"tag":112,"props":1663,"children":1664},{"style":204},[1665],{"type":23,"value":1666},"percent",{"type":18,"tag":112,"props":1668,"children":1669},{"style":125},[1670],{"type":23,"value":1671},") ",{"type":18,"tag":112,"props":1673,"children":1674},{"style":178},[1675],{"type":23,"value":1676},"=>",{"type":18,"tag":112,"props":1678,"children":1679},{"style":125},[1680],{"type":23,"value":1681}," console",{"type":18,"tag":112,"props":1683,"children":1684},{"style":441},[1685],{"type":23,"value":444},{"type":18,"tag":112,"props":1687,"children":1688},{"style":189},[1689],{"type":23,"value":1690},"log",{"type":18,"tag":112,"props":1692,"children":1693},{"style":125},[1694],{"type":23,"value":636},{"type":18,"tag":112,"props":1696,"children":1697},{"style":143},[1698],{"type":23,"value":1699},"`Downloaded ",{"type":18,"tag":112,"props":1701,"children":1702},{"style":483},[1703],{"type":23,"value":486},{"type":18,"tag":112,"props":1705,"children":1706},{"style":125},[1707],{"type":23,"value":1656},{"type":18,"tag":112,"props":1709,"children":1710},{"style":483},[1711],{"type":23,"value":504},{"type":18,"tag":112,"props":1713,"children":1714},{"style":143},[1715],{"type":23,"value":428},{"type":18,"tag":112,"props":1717,"children":1718},{"style":483},[1719],{"type":23,"value":486},{"type":18,"tag":112,"props":1721,"children":1722},{"style":125},[1723],{"type":23,"value":1666},{"type":18,"tag":112,"props":1725,"children":1726},{"style":483},[1727],{"type":23,"value":504},{"type":18,"tag":112,"props":1729,"children":1730},{"style":143},[1731],{"type":23,"value":1732},")`",{"type":18,"tag":112,"props":1734,"children":1735},{"style":125},[1736],{"type":23,"value":654},{"type":18,"tag":112,"props":1738,"children":1739},{"class":114,"line":215},[1740],{"type":18,"tag":112,"props":1741,"children":1742},{"style":125},[1743],{"type":23,"value":654},{"type":18,"tag":45,"props":1745,"children":1747},{"id":1746},"caveats",[1748],{"type":23,"value":1749},"Caveats",{"type":18,"tag":19,"props":1751,"children":1752},{},[1753],{"type":23,"value":1754},"Some servers do not send the Content-Length header. You have two options if this applies to you;",{"type":18,"tag":1756,"props":1757,"children":1758},"ol",{},[1759,1765],{"type":18,"tag":1760,"props":1761,"children":1762},"li",{},[1763],{"type":23,"value":1764},"Don't display a percentage - just the KB downloaded count (the percentage is null in the callback)",{"type":18,"tag":1760,"props":1766,"children":1767},{},[1768],{"type":23,"value":1769},"Bake-in the file size if it's a static URL - pass it in as the final parameter to the download function",{"type":18,"tag":19,"props":1771,"children":1772},{},[1773],{"type":23,"value":1774},"Enjoy!",{"type":18,"tag":19,"props":1776,"children":1777},{},[1778],{"type":18,"tag":1779,"props":1780,"children":1781},"em",{},[1782],{"type":23,"value":1783},"[)amien",{"type":18,"tag":1785,"props":1786,"children":1787},"style",{},[1788],{"type":23,"value":1789},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":106,"searchDepth":154,"depth":154,"links":1791},[1792,1793,1794,1795],{"id":47,"depth":154,"text":50},{"id":91,"depth":154,"text":94},{"id":1566,"depth":154,"text":1569},{"id":1746,"depth":154,"text":1749},"markdown","content:blog:2017:downloading-files-with-progress-in-electron.md","content","blog/2017/downloading-files-with-progress-in-electron.md","blog/2017/downloading-files-with-progress-in-electron","md","/blog/2017/downloading-files-with-progress-in-electron/",672,[1805,1809,1813],{"title":1806,"date":1807,"url":1808},"HTML5 Video Cheatsheet: Optimizing videos for the web","2025-12-05T00:00:00Z","/blog/2025/html5-video-cheatsheet/",{"title":1810,"date":1811,"url":1812},"Transactions in the MongoDB EF Core Provider","2025-10-25","/blog/2025/mongodb-explicit-transactions/",{"title":1814,"date":1815,"url":1816},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","/blog/2025/mongodb-queryable-encryption/",[1818],{"_path":1819,"_dir":1820,"_draft":6,"_partial":6,"_locale":7,"title":1821,"description":1822,"id":1823,"date":1824,"name":1825,"avatar":1826,"body":1827,"_type":1796,"_id":1845,"_source":1798,"_file":1846,"_stem":1847,"_extension":1801},"/comments/downloading-files-with-progress-in-electron/dc798450","downloading-files-with-progress-in-electron","Dc798450","Very handy!","dc798450","2021-10-20T07:14:19.1275652Z","Joel","https://github.com/joel1st.png",{"type":15,"children":1828,"toc":1843},[1829,1833,1838],{"type":18,"tag":19,"props":1830,"children":1831},{},[1832],{"type":23,"value":1822},{"type":18,"tag":19,"props":1834,"children":1835},{},[1836],{"type":23,"value":1837},"The built in electron 'will-download' manager does not provide error messages/feedback, and as you mention node specific packages often ignore system proxies etc.",{"type":18,"tag":19,"props":1839,"children":1840},{},[1841],{"type":23,"value":1842},"The other nice bonus with this approach is that network traffic shows up in the chrome dev tools.",{"title":106,"searchDepth":154,"depth":154,"links":1844},[],"content:comments:downloading-files-with-progress-in-electron:dc798450.md","comments/downloading-files-with-progress-in-electron/dc798450.md","comments/downloading-files-with-progress-in-electron/dc798450",1779264581942]