One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
| const trackTime = timing => { | |
| const now = performance.now(); | |
| if (!timing.startTime) timing.startTime = now; | |
| const elapsed = now - timing.startTime; | |
| const {duration} = timing; | |
| if (duration != null && duration <= elapsed) timing.startTime = null; | |
| return elapsed; | |
| }; | |
| const delay = (callback, duration) => { |
| axios({ | |
| url: 'http://localhost:5000/static/example.pdf', | |
| method: 'GET', | |
| responseType: 'blob', // important | |
| }).then((response) => { | |
| const url = window.URL.createObjectURL(new Blob([response.data])); | |
| const link = document.createElement('a'); | |
| link.href = url; | |
| link.setAttribute('download', 'file.pdf'); | |
| document.body.appendChild(link); |
| const immutable = (() => { | |
| const getValue = obj => key => obj[key]; | |
| const isObject = obj => Object(obj) === obj; | |
| const isMutable = obj => isObject(obj) && !Object.isFrozen(obj); | |
| return obj => { | |
| Object.keys(obj).map(getValue(obj)).filter(isMutable).forEach(immutable); | |
| return Object.freeze(obj); | |
| }; | |
| })(); |
| const shuffle = (arr, mixed = [], pool = arr.slice()) => { | |
| const remaining = pool.length; | |
| if (!remaining) return mixed; | |
| const index = Math.floor(Math.random() * remaining); | |
| const el = pool.splice(index, 1).pop(); | |
| mixed.push(el); | |
| return shuffle(arr, mixed, pool); | |
| }; |
| // Promise.all is good for executing many promises at once | |
| Promise.all([ | |
| promise1, | |
| promise2 | |
| ]); | |
| // Promise.resolve is good for wrapping synchronous code | |
| Promise.resolve().then(function () { | |
| if (somethingIsNotRight()) { | |
| throw new Error("I will be rejected asynchronously!"); |
| // array utils | |
| // ================================================================================================= | |
| const combine = (...arrays) => [].concat(...arrays); | |
| const compact = arr => arr.filter(Boolean); | |
| const contains = (() => Array.prototype.includes | |
| ? (arr, value) => arr.includes(value) | |
| : (arr, value) => arr.some(el => el === value) |