_.shuffle( Object.entries(questionsBySubcategory).flatMap(([, subQuestions]) => _.sampleSize(subQuestions, numQuestions[category]) ) )
const getAllTimerRequests = async function(t, fixtureName, flags = {}) { const { host, port, requests, stopServer } = await startUdpServer() try { await runFixture(t, fixtureName, { flags: { statsd: { host, port }, ...flags }, snapshot: false }) } finally { await stopServer() } const timerRequests = requests.flatMap(flattenRequest) return timerRequests }
private async calculateRating(beaches: Beach[]): Promise<BeachForecast[]> { logger.info(`Preparing the forecast for ${beaches.length} beaches`); const response: ForecastPoint[][] = await Promise.all( beaches.map((beach) => this.stormGlass.fetchPoints(beach.lat, beach.lng)) ); return response.flatMap((point: ForecastPoint[], index: number) => { const ratingService = new this.RatingService(beaches[index]); return this.enrichBeachData(point, beaches[index], ratingService); }); }
this.Menu.flatMap((objectKey) => { if (objectKey.category) { return objectKey.inputs; } return [objectKey]; })
/* globals proclaim */ it('is a function', function () { proclaim.isFunction(Array.prototype.flatMap); });
function encodeObject(object) { const keys = Object.keys(object).sort(); return [ OBJ, // encodeInteger(keys.length), ...keys.flatMap((key) => [ STR, encodeString(key), END, ...encodeParts(object[key]), ]), END, ]; }
// Sort plugin commands by event order. const sortCommands = function(commands) { return EVENTS.flatMap(event => commands.filter(command => command.event === event)) }
const parse = function (symbolic) { const tokens = tokenize(symbolic) if (tokens === undefined || hasDuplicates({ tokens })) { return } const nodes = tokens .map(addDefaultCategories) .map(normalizeX) .flatMap(splitCategories) .flatMap(splitAll) .flatMap(normalizeOperator) .flatMap(splitPermissions) return nodes }
const getCliFlags = function(mainFlags, prefix = []) { return Object.entries(mainFlags) .flatMap(([name, value]) => getCliFlag({ name, value, prefix })) .join(' ') }
it('has correct arity', function () { proclaim.arity(Array.prototype.flatMap, 1); });
it('has correct name', function () { proclaim.hasName(Array.prototype.flatMap, 'flatMap'); });
const getAllTimerRequests = async function(t, fixtureName, flags = {}) { const { host, port, requests, stopServer } = await startUdpServer() try { await runFixture(t, fixtureName, { flags: { statsd: { host, port }, ...flags }, snapshot: false }) } finally { await stopServer() } const timerRequests = requests.flatMap(flattenRequest) return timerRequests }
this.Menu.flatMap((objectKey) => { if (objectKey.category) { return objectKey.inputs; } return [objectKey]; })
const getCliFlags = function(mainFlags, prefix = []) { return Object.entries(mainFlags) .flatMap(([name, value]) => getCliFlag({ name, value, prefix })) .join(' ') }
// Sort plugin commands by event order. const sortCommands = function(commands) { return EVENTS.flatMap(event => commands.filter(command => command.event === event)) }