// eslint-disable-next-line require-jsdoc constructor(name, aggType) { if (isEmpty(aggType)) throw new Error('Aggregation `aggType` cannot be empty'); this._name = name; this.aggType = aggType; this._aggs = {}; this._aggsDef = this._aggs[aggType] = {}; this._nestedAggs = []; }
async count({ req, response }) { const count = await this._model.count({ where: !isEmpty(req.where) ? JSON.parse(req.where) : undefined }) response.res = { count } return response.res }
function filterColumn(columns, checkedKeys = []) { if (!columns) return; return columns .map(c => { const children = filterColumn(c.children, checkedKeys); if (children) { return { ...c, children }; } return c; }) .filter(c => checkedKeys.includes(c.key) || !isEmpty(c.children)); }
export function injectReducerFactory(store: LifeStore) { return function injectReducer(key: string, reducer: Reducer<object>) { invariant( isString(key) && !isEmpty(key) && isFunction(reducer), '(app/utils...) injectReducer: Expected `reducer` to be a reducer function' ); if (Reflect.has(store.injectedReducers, key) && store.injectedReducers[key] === reducer) return; store.injectedReducers[key] = reducer; store.replaceReducer(createReducer(store.injectedReducers)); }; }
componentDidUpdate(prevProps) { // Show required error if the input's value is received after the compo is mounted if (!isEmpty(this.props.value) && !this.state.hasInitialValue) { this.setInit(); } // Check if errors have been updated during validations if (prevProps.didCheckErrors !== this.props.didCheckErrors) { // Remove from the state the errors that have already been set const errors = isEmpty(this.props.errors) ? [] : this.props.errors; this.setErrors(errors); } }
async getOrder(orderBy) { const queryOrder = {} if (!isEmpty(orderBy)) { if (orderBy.trim().charAt(0) === '-') { Object.assign(queryOrder, { orderBy: [orderBy.trim().substr(1), 'DESC'] }) } else { Object.assign(queryOrder, { orderBy: [orderBy.trim(), 'ASC'] }) } } return queryOrder }
/** * * @param {InjectionToken} token * @param {Provider|Provider[]} notFoundProviders * @returns {{readonly provide?: *}[]} */ getOverrideProviders(token, notFoundProviders = []) { const overrideProviders = this.platformProvidersOverride.filter(({ provide }) => provide === token); return isEmpty(overrideProviders) ? toArray(notFoundProviders) : overrideProviders; }
/** * Override default `toJSON` to return DSL representation for the `aggregation` query. * * @override * @returns {Object} returns an Object which maps to the elasticsearch query DSL */ toJSON() { if (isEmpty(this._aggsDef.ranges)) { throw new Error('`ranges` cannot be empty.'); } return super.toJSON(); }
get firstChild() { if (isEmpty(this.childNodes)) return null; return first(this.childNodes); }
componentDidMount() { if (__isBrowser__) { if (isEmpty(this.props.jobs)) { this.props.fetchAction(); } } }
// eslint-disable-next-line require-jsdoc constructor(valueSrcType, refUrl, name, field) { if (isEmpty(valueSrcType)) throw new Error('ValuesSourceBase `valueSrcType` cannot be empty'); this._name = name; this._valueSrcType = valueSrcType; this._refUrl = refUrl; this._body = {}; this._opts = this._body[valueSrcType] = {}; if (!isNil(field)) this._opts.field = field; }
// eslint-disable-next-line require-jsdoc constructor(suggesterType, name, field) { if (isEmpty(suggesterType)) throw new Error('Suggester `suggesterType` cannot be empty'); if (isEmpty(name)) throw new Error('Suggester `name` cannot be empty'); this.name = name; this.suggesterType = suggesterType; this._body = {}; this._opts = this._body[name] = {}; this._suggestOpts = this._opts[suggesterType] = {}; if (!isNil(field)) this._suggestOpts.field = field; }
async destroy({ req, response }) { const count = await this._model.destroy({ where: !isEmpty(req.where) ? JSON.parse(req.where) : {} }) response.res = { count } return response.res }
get lastChild() { if (isEmpty(this.childNodes)) return null; return last(this.childNodes); }