const invalidateStep = ( state, { step, errors } ) => { const newStepState = { ...step, errors, status: 'invalid' }; return has( state, step.stepName ) ? updateStep( state, newStepState ) : addStep( state, newStepState ); }
/** * Whether the channel is deletable by the client user * @type {boolean} * @readonly */ get deletable() { return super.deletable && this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false); }
/** * Gets an {@link Array} of bitfield names based on the bits available. * @param {...*} hasParams Additional parameters for the has method, if any * @returns {string[]} */ toArray(...hasParams) { return Object.keys(this.constructor.FLAGS).filter(bit => this.has(bit, ...hasParams)); }
const getSize = function (parentSize, itemPosition) { const position = normalizePosition(itemPosition.position); if (_.has(position, "size")) { return position.size; } // Prevent last growing view from overflowing screen const round = itemPosition.offset.grow + position.grow === itemPosition.summary.grow ? Math.floor : Math.ceil; return round( (parentSize - itemPosition.summary.size) * position.grow / itemPosition.summary.grow ); }
/* * Helper to load in all app plugins */ const loadPlugins = (app, lando) => Promise.resolve(app.plugins.registry) // Filter out .filter(plugin => _.has(plugin, 'app')) // LOADEM! .map(plugin => app.plugins.load(plugin, plugin.app, app, lando)) // Remove any naughty shit .map(plugin => _.pick(plugin.data, ['config', 'composeData', 'env', 'labels'])) // Merge minotaur .each(result => _.merge(app, result))
function assertEventName(eventName, eventNames) { assert( `Invalid event name provided. Expected string, received: "${typeof eventName}".`, typeof eventName === 'string' ); assert( `Invalid event name provided: "${eventName}". Possible events: ${[ ...eventNames ].join(', ')}.`, eventNames.has(eventName) ); }
// 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); }); } });
/* * Parse docker-compose options */ const parseOptions = (opts = {}) => { const flags = _.map(composeFlags, (value, key) => _.get(opts, key, false) ? value : ''); const environment = _.flatMap(opts.environment, (value, key) => ['--env', `${key}=${value}`]); const user = (_.has(opts, 'user')) ? ['--user', opts.user] : []; const workdir = (_.has(opts, 'workdir')) ? ['--workdir', opts.workdir] : []; const entrypoint = _.map(opts.entrypoint, entrypoint => ['--entrypoint', entrypoint]); return _.compact(_.flatten([flags, environment, user, workdir, entrypoint])); }
/** * Number of times `startTyping` has been called * @type {number} * @readonly */ get typingCount() { if (this.client.user._typing.has(this.id)) return this.client.user._typing.get(this.id).count; return 0; }
function getDb(user) { const userId = user._id; if (databases.has(userId)) { return databases.get(userId); } const database = new Datastore({ autoload: true, filename: path.join(config.dbPath, userId, 'settings', 'settings.db'), }); databases.set(userId, database); return database; }
const submitStep = ( state, { step } ) => { const stepHasApiRequestFunction = get( stepsConfig, [ step.stepName, 'apiRequestFunction' ] ); const status = stepHasApiRequestFunction ? 'pending' : 'completed'; return has( state, step.stepName ) ? updateStep( state, { ...step, status } ) : addStep( state, { ...step, status } ); }
_.forEach(all, one => { if (_.has(one, 'options')) { _.forEach(one.options(lando), (option, key) => { // @TODO: get auto conflict assignment to work properly // @NOTE: maybe it doesn't and we should just do this manually? // _.set(options, `${key}.conflicts`, getConflicts(one.name, all, lando)); }); options = _.merge({}, one.options(lando), options); } });
_callListenersWith(methodName, target) { if (this[LISTENERS].has(target)) { const listeners = this[LISTENERS].get(target); for (const eventName in listeners) { target[methodName].apply(target, [eventName, listeners[eventName]]); } } }
/** * Whether the channel is joinable by the client user * @type {boolean} * @readonly */ get joinable() { if (browser) return false; if (!this.viewable) return false; if (!this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false)) return false; if (this.full && !this.permissionsFor(this.client.user).has(Permissions.FLAGS.MOVE_MEMBERS, false)) return false; return true; }
/** * Checks whether the bitfield has a permission, or multiple permissions. * @param {PermissionResolvable} permission Permission(s) to check for * @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override * @returns {boolean} */ has(permission, checkAdmin = true) { return (checkAdmin && super.has(this.constructor.FLAGS.ADMINISTRATOR)) || super.has(permission); }