const combineXPosts = ( postKeys ) => postKeys.reduce( ( accumulator, postKey ) => { const lastPostKey = last( accumulator ); if ( sameXPost( lastPostKey, postKey ) ) { accumulator[ accumulator.length - 1 ] = addDuplicateXPostToPostKey( lastPostKey, postKey ); } else { accumulator.push( postKey ); } return accumulator; }, [] )
processTransferRateResponse(transferRate = [], options) { this.emit(clientGatewayServiceEvents.PROCESS_TRANSFER_RATE_START); return transferRate.reduce((accumulator, value, index) => { const key = options.propLabels[index]; const transformValue = options.valueTransformations[index]; accumulator[key] = transformValue(value); return accumulator; }, {}); }
_getLongestLabel() { const {_types} = this; const labels = Object.keys(_types).map(x => _types[x].label); return labels.reduce((x, y) => x.length > y.length ? x : y); }
providers.reduce((memo, provider) => { if (!authData[provider]) { return memo; } const queryKey = `authData.${provider}.id`; const query = {}; query[queryKey] = authData[provider].id; memo.push(query); return memo; }, []).filter(q => { return typeof q !== 'undefined'; })
Object.keys(strapi.components).reduce((acc, entity) => { Object.keys(strapi.components[entity].attributes).forEach(attribute => { const attr = strapi.components[entity].attributes[attribute]; if ((attr.collection || attr.model || '').toLowerCase() === model.toLowerCase()) { acc.push(strapi.components[entity].globalId); } }); return acc; }, [])
const init = (initialState, permissions) => { const collapses = Object.keys(permissions) .sort() .reduce((acc, current, index) => { return acc.concat({ name: current, isOpen: index === 0, }); }, []); return { ...initialState, collapses }; }
/** * Utility function to compose validators */ const composeValidators = (...fns) => attr => { return fns.reduce((validator, fn) => { return fn(attr, validator); }, yup.mixed()); }
Object.keys(strapi.api || []).reduce((acc, key) => { for (let index in strapi.api[key].services) { acc[index] = strapi.api[key].services[index]; } return acc; }, {})
Object.keys(files).reduce((acc, key) => { const fullPath = _.toPath(key); if (fullPath.length <= 1 || fullPath[0] !== 'files') { throw strapi.errors.badRequest( `When using multipart/form-data you need to provide your files by prefixing them with the 'files'. For example, when a media file is named "avatar", make sure the form key name is "files.avatar"` ); } const path = _.tail(fullPath); acc[path.join('.')] = files[key]; return acc; }, {})
Object.keys(formErrors) .filter(key => key.includes('headers')) .reduce((obj, key) => { obj[key] = formErrors[key]; return obj; }, {})
Object.keys(strapi.plugins).reduce((acc, current) => { const isDocumentationNeeded = this.isPluginDocumentationNeeded(current); if (isDocumentationNeeded) { return acc.concat(current); } return acc; }, [])
['B', 'C', 'Q', 'P', 'F', 'p', 'D', 'E', 'H', 'S'].reduce((acc, x) => { const v = x.charCodeAt(0) acc[x] = () => { buffer[0] = v b.i = 5 return b } return acc }, {})
function trimNulls(obj: Record<string, any>): Record<string, any> { return Object.keys(obj).reduce((memo, key) => { if (obj[key] != null) { memo[key] = obj[key]; } return memo; }, {}); }
const removeNullKeys = obj => Object.keys(obj).reduce((acc, current) => { if (obj[current] !== null && current !== 'plugin') { acc[current] = obj[current]; } return acc; }, {})
const formatMessagesWithPluginId = (pluginId, messages) => { return Object.keys(messages).reduce((acc, current) => { acc[`${pluginId}.${current}`] = messages[current]; return acc; }, commonTrads); }