export function loggedOut( context, next ) { if ( context.isServerSide && ! isEmpty( context.query ) ) { // Don't server-render URLs with query params return next(); } const props = getProps( context ); context.primary = <LoggedOutComponent { ...props } />; next(); }
connect( ( state ) => { const productsList = getAvailableProductsList( state ); const productsLoaded = ! isEmpty( productsList ); return { isLoggedIn: !! getCurrentUserId( state ), productsList, productsLoaded, }; }, { submitSignupStep } )( localize( SiteOrDomain ) )
const removeBlock = function (dom: DOMUtils, block: Element, root: Node) { const parentBlock = dom.getParent(block.parentNode, dom.isBlock, root); dom.remove(block); if (parentBlock && dom.isEmpty(parentBlock)) { dom.remove(parentBlock); } }
_(files) .flatMap(file => traverseUp(path.resolve(startFrom, file))) .sortBy().reverse() .filter(file => fs.existsSync(file) && path.isAbsolute(file)) .thru(files => _.isEmpty(files) ? [] : [_.first(files)]) .flatMap(dirFile => _.map(files, file => path.join(path.dirname(dirFile), file))) .filter(file => fs.existsSync(file)) .value()
// Categorize and colorize URLS if and as appropriate _.forEach(app.info, info => { if (_.has(info, 'urls') && !_.isEmpty(info.urls)) { urls[info.service] = _.filter(app.urls, item => { item.theme = chalk[item.color](item.url); return _.includes(info.urls, item.url); }); } });
UNSAFE_componentWillReceiveProps(nextProps) { // Show required error if the input's value is received after the compo is mounted if (!isEmpty(nextProps.value) && !this.state.hasInitialValue) { this.setState({ hasInitialValue: true }); } // Check if errors have been updated during validations if (nextProps.didCheckErrors !== this.props.didCheckErrors) { // Remove from the state the errors that have already been set const errors = isEmpty(nextProps.errors) ? [] : nextProps.errors; this.setState({ errors }); } }
const mergeForward = function (editor: Editor, rng: DomRange, fromLi: HTMLLIElement, toLi: HTMLLIElement) { const dom = editor.dom; if (dom.isEmpty(toLi)) { mergeIntoEmptyLi(editor, fromLi, toLi); } else { const bookmark = Bookmark.createBookmark(rng); mergeLiElements(dom, fromLi, toLi); editor.selection.setRng(Bookmark.resolveBookmark(bookmark)); } }
// Helper to get sites for autocomplete const getAutoCompleteRepos = (answers, Promise, input = null) => { if (!_.isEmpty(gitHubRepos)) { return Promise.resolve(gitHubRepos).filter(site => _.startsWith(site.name, input)); } else { return getRepos(answers, Promise).then(sites => { gitHubRepos = sites; return gitHubRepos; }); }; }
const checkKey = key => invariant( isString(key) && !isEmpty(key), '(app/utils...) injectSaga: Expected `key` to be a non empty string' )
constructor(data, {border = true, keyColor = 'cyan', joiner = '\n', sort = false} = {}, opts = {}) { // Inherit the table const tableDefaults = border ? {} : noBorderOpts; super(_.merge({}, tableDefaults, opts)); // Add new opts this.border = border; this.joiner = joiner; this.keyColor = keyColor; this.sort = sort; // Add data if we have it if (!_.isEmpty(data)) this.add(data); }
/** * Validates a plugin name format */ const isValidPluginName = plugin => { return _.isString(plugin) && !_.isEmpty(plugin) && PLUGIN_NAME_REGEX.test(plugin); }
componentDidMount() { const { value, errors } = this.props; // Prevent the input from displaying an error when the user enters and leaves without filling it if (!isEmpty(value)) { this.setState({ hasInitialValue: true }); } // Display input error if it already has some if (!isEmpty(errors)) { this.setState({ errors }); } }
UNSAFE_componentWillReceiveProps(nextProps) { // Show required error if the input's value is received after the compo is mounted if (!isEmpty(nextProps.value) && !this.state.hasInitialValue) { this.setState({ hasInitialValue: true }); } // Check if errors have been updated during validations if (nextProps.didCheckErrors !== this.props.didCheckErrors) { // Remove from the state the errors that have already been set const errors = isEmpty(nextProps.errors) ? [] : nextProps.errors; this.setState({ errors }); } }