const validateGranularConfigTypes = (longHandAccess, validationError) => { const errors = Object.entries(longHandAccess) .map(([accessType, accessConfig]) => validationError(getType(accessConfig), accessType)) .filter(error => error); if (errors.length) { throw new Error(errors.join('\n')); } return longHandAccess; }
Object.entries(args) .filter(([arg]) => arg !== '_') .map(([arg, value]) => `${arg}=${value}`) .join(' ') .trim()
Object.entries(providers).map(([provider, providerConfig]) => { result[provider] = { id: provider, name: providerConfig.name, type: providerConfig.type, signinUrl: providerConfig.signinUrl, callbackUrl: providerConfig.callbackUrl } })
Object.fromEntries( Object.entries(unicorn.configs.recommended.rules) .filter(([id, options]) => id.startsWith('unicorn/') && options === 'off') .map(([id]) => [id, 'error']) )
/** * Loads the effects onto the unit. * * @param {Unit} unit The unit. * @param {Object} effects The effects to load. */ function loadEffects(unit, effects = {}) { Object.entries(effects).forEach(([effectName, effectCreator]) => { const effect = effectCreator(unit); unit.addEffect(effectName, effect); }); }
const deepTrimObject = attribute => { if (Array.isArray(attribute)) { return attribute.map(deepTrimObject); } if (typeof attribute === 'object') { return Object.entries(attribute).reduce((acc, [key, value]) => { const trimmedObject = deepTrimObject(value); return { ...acc, [key]: trimmedObject }; }, {}); } return typeof attribute === 'string' ? attribute.trim() : attribute; }
const getRecursivePermissionsBySubject = (subject, contentTypesPermissions) => { return Object.entries(get(contentTypesPermissions, [subject, 'attributes'], {})).reduce( (acc, current) => { if (current[1].actions.length > 0) { return acc + current[1].actions.length; } return acc; }, 0 ); }
Promise.all(Object.entries(appIcon).map(async ([type, icon]) => { if (baseDiskIcons[type]) { return composeIcon(type, icon, baseDiskIcons[type], composedIcon); } console.warn('There is no base image for this type', type); }))
const filterValues = (obj, predicate) => Object.entries(obj).reduce( (acc, [key, value]) => (predicate(value) ? { ...acc, [key]: value } : acc), {} )
const buildMetadataCollector = ( metadata = {} ) => { return ( reporter ) => { Object.entries( metadata ).forEach( ( [ key, value ] ) => reporter.data.set( key, value ) ); }; }
const mapKeyNames = (obj, func) => Object.entries(obj).reduce( (acc, [key, value]) => ({ ...acc, [func(key, value, obj)]: value }), {} )
const mockFiles = ( filesToMock ) => { Object.entries( filesToMock ).forEach( ( [ file, content ] ) => { jest.mock( file, () => content, { virtual: true } ); } ); }
/** * Loads the effects onto the unit. * * @param {Unit} unit The unit. * @param {Object} effects The effects to load. */ function loadEffects(unit, effects = {}) { Object.entries(effects).forEach(([effectName, effectCreator]) => { const effect = effectCreator(unit); unit.addEffect(effectName, effect); }); }
const filterValues = (obj, predicate) => Object.entries(obj).reduce( (acc, [key, value]) => (predicate(value) ? { ...acc, [key]: value } : acc), {} )
Object.entries(args) .filter(([arg]) => arg !== '_') .map(([arg, value]) => `${arg}=${value}`) .join(' ') .trim()