Skip to content

Instantly share code, notes, and snippets.

View zheeeng's full-sized avatar
🎈
blowing balloons

Zheeeng zheeeng

🎈
blowing balloons
View GitHub Profile
@zheeeng
zheeeng / fetchProgress.md
Last active March 31, 2021 07:43
fetchProgress.md

Fetch: Download progress

The fetch method allows to track download progress.

Please note: there’s currently no way for fetch to track upload progress. For that purpose, please use XMLHttpRequest, we’ll cover it later.

To track download progress, we can use response.body property. It’s ReadableStream – a special object that provides body chunk-by-chunk, as it comes. Readable streams are described in the Streams API specification.

Unlike response.text(), response.json() and other methods, response.body gives full control over the reading process, and we can count how much is consumed at any moment.

@zheeeng
zheeeng / index.js
Created November 6, 2021 02:37 — forked from jadenlemmon/index.js
Example A/B Test Gatsby v4 SSR Cookies
import { sample } from 'lodash';
import React from 'react';
import cookie from 'cookie';
import Layout from '../components/layout';
import HomeV1 from '../components/scenes/home/v1';
import HomeV2 from '../components/scenes/home/v2';
const EXPERIMENT_OPTIONS = {
v1: HomeV1,
v2: HomeV2,