const removeEmptyProperties = obj => pickBy(obj, identity)
export default function getMajorLanguage(languages) { const sumLinesOfCode = reduce((sum, linesOfCode) => sum + linesOfCode, 0)( languages, ) const highUsageLanguages = flow( pickBy((value, key) => (value > 10000 ? key : null)), keys, )(languages) const mostPopularLanguage = flow( mapValues((value, key) => value / sumLinesOfCode), obj => [keys(obj).reduce((a, b) => (obj[a] > obj[b] ? a : b), null)], filter(value => value), )(languages) return union([...highUsageLanguages, ...mostPopularLanguage]) }
pickBy(JSON.parse(JSON.stringify(body)), (value) => { return !(value === null || value === undefined || (typeof value === 'object' && Object.keys(value).length === 0)); })
mergedParams = pickBy(mergedParams, identity); // remove falsey values const mergedParamsString = new URLSearchParams(mergedParams).toString();
/** * execute query on xtream server * * @param {string} [action] * @param {{ [ key: string ]: string }} [filter] * @returns {Promise<any>} */ execute (action, filter) { const query = pickBy({ ...this.config.auth, action, ...filter }) return Promise.resolve() .then(() => fetch(`${this.config.baseUrl}/player_api.php?${qs.stringify(query)}`)) .then(T => T.json()) .then(data => { if (action && data.hasOwnProperty('user') && data.user.hasOwnProperty('status') && data.user_info.status === 'Disabled') { return Promise.reject(new Error('account disabled')) } return data }) }
/** * Retrieve and format all project data. */ async function getProjects () { /** * Get project details from frontmatter. */ const projectDetailsRaw = map(projectsMarkdown, processMarkdown) const projectDetails = await Promise.all(map(projectDetailsRaw, mapProjectFrontMatter)) /** * Get external project data. */ const projectDataRaw = await fetchArchive(projectDetails) const projectData = extractRelevantProjectData(projectDataRaw) /** * Combine project details from frontmatter and project data from * external sources, using the sluggified title as the link, since * the sluggified titles are used as top level keys in the collected * external data. */ const projects = projectDetails.map(project => { const slug = toSlug(project.title) const data = projectData[slug] return pickBy({ ...project, ...data }, val => val) }) return projects }
this._state.setAsUpdateStarted(); const opts = this._state.optionsManifest(); Transport.sendUpdate(query, pickBy(payload, (v, key) => opts[key]), this.transport_timeout) .then(response => {
schemaModel.fields = mapValues(pickBy(model.attributes, attribute => !attribute.model && !attribute.collection ), (value, attribute) => ({