This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Machine, interpret, assign } = require('xstate'); | |
| const firstService = () => new Promise(resolve => { | |
| setTimeout(() => { | |
| console.log('in first service'); | |
| resolve(); | |
| }, 3000); | |
| }) | |
| const secondService = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import './App.css'; | |
| import React, { useEffect, useState } from 'react'; | |
| const loadScript = script => new Promise(resolve => { | |
| const scriptTag = window.document.createElement('script'); | |
| scriptTag.src = script; | |
| scriptTag.setAttribute('defer', 'defer'); | |
| scriptTag.setAttribute('crossorigin', 'crossorigin'); | |
| window.document.body.appendChild(scriptTag); | |
| window.addEventListener('load', () => resolve()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { deviation, sum } = require('d3-array'); | |
| // the samples are like clicks per day | |
| const sample = [ | |
| [45, 40, 39, 80, 37, 34, 36], | |
| [15, 7, 6, 25, 9, 12] | |
| ] | |
| // z-score = ([current trend] - [average historic trends]) / [standard deviation of historic trends] | |
| const samplingAvg = sample => (sum(sample) / sample.length); | |
| const trend = (current, sample) => ((current - samplingAvg(sample)) / deviation(sample)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| class App extends Component { | |
| componentWillMount () { | |
| } | |
| componentDidMount () { | |
| const textFile = require('./text.md'); | |
| fetch(textFile) | |
| .then(response => { | |
| return response.text(); |