/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
scripts/bench/benchmarks/hacker-news/generate.js
33 строки
742 B
Jack Hou
use different eslint config for es6 and es5 (#11794)
11 дек 2017, 18:52
11 дек 2017, 18:52
e8e62eb
Код
Авторство
О чём код?
'use strict'; const fetch = require('node-fetch'); const {writeFileSync} = require('fs'); const stories = 50; async function getStory(id) { const storyRes = await fetch( `https://hacker-news.firebaseio.com/v0/item/${id}.json` ); return await storyRes.json(); } async function getTopStories() { const topStoriesRes = await fetch( 'https://hacker-news.firebaseio.com/v0/topstories.js' ); const topStoriesIds = await topStoriesRes.json(); const topStories = []; for (let i = 0; i < stories; i++) { const topStoriesId = topStoriesIds[i]; topStories.push(await getStory(topStoriesId)); } writeFileSync( 'top-stories.json', `window.stories = ${JSON.stringify(topStories)}` ); } getTopStories();