const doesComponentHaveAComponentField = component => { const attributes = get(component, ['schema', 'attributes'], {}); return Object.keys(attributes).some(attributeName => { const type = get(attributes, [attributeName, 'type'], ''); return type === 'component'; }); }
/** * Are tracking pixels forbidden from the given URL for better performance (except for Google Analytics)? * * @returns {boolean} true if the current URL is excluded. */ export default function isUrlExcludedForPerformance() { const { href } = document.location; const match = ( pattern ) => href.indexOf( pattern ) !== -1; const result = excludedRoutes.some( match ); debug( `Is URL Excluded for Performance: ${ result }` ); return result; }
/** * Determines if a path is a legacy route, and should be ignored by Calypso * * @param path The path to check * @returns True if legacy path, false otherwise */ export function isLegacyRoute( path: URLString ): boolean { return legacyRoutes.some( ( { match, noMatch = { test: () => false }, predicate = () => true } ) => predicate( path ) && match.test( path ) && ! noMatch.test( path ) ); }
/** * Whether the current URL can potentially contain personally identifiable info. * * @returns {boolean} true if the current URL can potentially contain personally identifiable info. */ export default function isPiiUrl() { const href = document.location.href; const match = ( pattern ) => href.indexOf( pattern ) !== -1; const result = forbiddenPiiPatterns.some( match ) || forbiddenPiiPatternsEnc.some( match ); debug( `Is PII URL: ${ result }` ); return result; }
const isPermissionEnabled = (permission, role) => DEFAULT_PERMISSIONS.some( defaultPerm => (defaultPerm.action === null || permission.action === defaultPerm.action) && (defaultPerm.controller === null || permission.controller === defaultPerm.controller) && (defaultPerm.type === null || permission.type === defaultPerm.type) && (defaultPerm.roleType === null || role.type === defaultPerm.roleType) )
isSelected(choice) { if (Array.isArray(this.initial)) { return this.initial.some(value => this.isChoice(choice, value)); } return this.isChoice(choice, this.initial); }
verifyDependencies() { const isDependencyLoading = Object.keys(this.dependencies).some(id => this.dependencies[id].satisfied === false); if (!isDependencyLoading) { this.haveUIDependenciesResolved = true; this.emit(EventTypes.UI_DEPENDENCIES_LOADED); } }
isDisabled(choice = this.focused) { let keys = ['disabled', 'collapsed', 'hidden', 'completing', 'readonly']; if (choice && keys.some(key => choice[key] === true)) { return true; } return choice && choice.role === 'heading'; }
/** * @desc TRUE if platform supports single precision} * @returns {boolean} */ static get isSinglePrecisionSupported() { return kernelOrder.some(Kernel => Kernel.isSupported && Kernel.features.isFloatRead && Kernel.features.isTextureFloat); }
useCallback( dzName => { const doesDZHaveError = Object.keys(formErrors).some(key => key.split('.')[0] === dzName); const shouldCheckErrors = !isEmpty(formErrors) && doesDZHaveError; return shouldCheckErrors; }, [formErrors] )
Object.keys(data).some(function(name) { var item = data[name]; return item && item.changed; })
/** * * @returns {boolean} */ static get isKernelMapSupported() { return kernelOrder.some(Kernel => Kernel.isSupported && Kernel.features.kernelMap); }
const isPermissionEnabled = (permission, role) => DEFAULT_PERMISSIONS.some( defaultPerm => (defaultPerm.action === null || permission.action === defaultPerm.action) && (defaultPerm.controller === null || permission.controller === defaultPerm.controller) && (defaultPerm.type === null || permission.type === defaultPerm.type) && (defaultPerm.roleType === null || role.type === defaultPerm.roleType) )
useCallback( dzName => { const doesDZHaveError = Object.keys(formErrors).some(key => key.split('.')[0] === dzName); const shouldCheckErrors = !isEmpty(formErrors) && doesDZHaveError; return shouldCheckErrors; }, [formErrors] )
const doesComponentHaveAComponentField = component => { const attributes = get(component, ['schema', 'attributes'], {}); return Object.keys(attributes).some(attributeName => { const type = get(attributes, [attributeName, 'type'], ''); return type === 'component'; }); }