_(loadCacheFile(config.toolingRouter)) .map(route => _.merge({}, route, { closeness: _.indexOf(pathsToRoot(), route.route), })) .filter(route => route.closeness !== -1) .orderBy('closeness') .thru(routes => routes[0]) .value()
_(applications) // Get the basics .map(app => _.merge({}, app, { application: true, appMountDir: getAppMount(app, appRoot, applicationFiles), closeness: _.indexOf(traverseUp(), getAppMount(app, appRoot, applicationFiles)), // @TODO: can we assume the 0? is this an index value? // @NOTE: probably not relevant until we officially support multiapp? hostname: `${app.name}.0`, sourceDir: _.has(app, 'source.root') ? path.join('/app', app.source.root) : '/app', webroot: utils.getDocRoot(app), })) // And the webPrefix .map(app => _.merge({}, app, { webPrefix: _.difference(app.appMountDir.split(path.sep), appRoot.split(path.sep)).join(path.sep), })) // Return .value()
{roles.map((role)=> <td key={`role${role.id}-permission${permission.id}`} className={`role${role.id}-permission${permission.id}`}> {_.indexOf(this.getRolePermissions(role.id), permission.id) > -1 ? <RoleToggle role={role.id} permission={permission.id} onChange={this.handleTogglePermission} checked={true}/>: <RoleToggle role={role.id} permission={permission.id} onChange={this.handleTogglePermission} checked={false}/>
function isBoolean(v) { const arr = ['t', 'true', 'f', 'false']; return _.indexOf(arr, v.toLowerCase()) !== -1; }
function getSchemaProperties (schema) { var properties = _.keys(schema.properties); // Start with the defined properties // Add properties defined in the parent _.forEach(schema.allOf, function (parent) { _.forEach(getSchemaProperties(parent), function (property) { if (_.indexOf(properties, property) === -1) { properties.push(property); } }); }); return properties; }
_.forEach(apiDefinition.definitionFullyResolved.paths, function (pathDef, name) { var pPath = ['paths', name]; _.forEach(pathDef.security, createSecurityProcessor(pPath.concat('security'))); _.forEach(pathDef, function (operationDef, method) { // Do not process non-operations if (_.indexOf(supportedHttpMethods, method) === -1) { return; } _.forEach(operationDef.security, createSecurityProcessor(pPath.concat([method, 'security']))); }); });
QUnit.test("#3711 - remove's `update` event returns multiple removed models", function(assert) { var model = new Backbone.Model({id: 1, title: 'First Post'}); var model2 = new Backbone.Model({id: 2, title: 'Second Post'}); var collection = new Backbone.Collection([model, model2]); collection.on('update', function(context, options) { var changed = options.changes; assert.deepEqual(changed.added, []); assert.deepEqual(changed.merged, []); assert.ok(changed.removed.length === 2); assert.ok(_.indexOf(changed.removed, model) > -1 && _.indexOf(changed.removed, model2) > -1); }); collection.remove([model, model2]); });
//var redisClient = redis.createClient(parsedUrl.port || 6379, parsedUrl.hostname || 'localhost'); function unsubscribe(socket, channel) { console.log('unsubscribing from ' + channel); // Get listeners for channel. Remove socket for list. If // channel listeners becomes empty then unsubscribe from redis // channel and remove channel from internal subsciptions hash var channelListeners = _subscriptions[channel]; if (channelListeners) { channelListeners.splice(_.indexOf(channelListeners, socket), 1); if (channelListeners.length === 0) { //redisClient.unsubscribe(channel); delete _subscriptions[channel]; } } }
_.forEach(apiDefinition.definitionFullyResolved.securityDefinitions, function (def, name) { var sPath = ['securityDefinitions', name]; referenceable.push(JsonRefs.pathToPtr(sPath)); _.forEach(def.scopes, function (description, scope) { var ptr = JsonRefs.pathToPtr(sPath.concat(['scopes', scope])); if (_.indexOf(referenceable, ptr) === -1) { referenceable.push(ptr); } }); });
// Unlink OAuth provider const unlinkProvider = (req, res, next) => { const provider = req.params.provider; const validProviders = ['facebook']; // check if provider is valid if (!_.isEmpty(provider) && _.indexOf(validProviders, provider) === -1) { req.flash('error', { msg: 'Invalid OAuth Provider' }); return res.redirect('/profile'); } const data = {}; data[provider] = ''; data.picture = ''; User.query() .patchAndFetchById(req.user.id, data) .then((user) => { req.flash('success', { msg: `Your ${provider} account has been unlinked.` }); return res.redirect('/profile'); }) .catch(next); }
Dispatcher.register(function(action) { switch (action.actionType) { case ActionTypes.INITIALISE: _authors = action.initialData.authors; AuthorStore.emitChange(); break; case ActionTypes.CREATE_AUTHOR: _authors.push(action.author); AuthorStore.emitChange(); break; case ActionTypes.UPDATE_AUTHOR: var existingAuthor = _.find(_authors, {id: action.author.id}); var existingAuthorIndex = _.indexOf(_authors, existingAuthor); _authors.splice(existingAuthorIndex, 1, action.author); AuthorStore.emitChange(); break; default: //nothing } });
validateContentType (contentType, supportedTypes) { const rawContentType = contentType if (!_.isUndefined(contentType)) { // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 contentType = contentType.split(';')[0] // Strip the parameter(s) from the content type } // Check for exact match or mime-type only match if (_.indexOf(supportedTypes, rawContentType) === -1 && _.indexOf(supportedTypes, contentType) === -1) { return { code: 'INVALID_CONTENT_TYPE', message: 'Invalid Content-Type (' + contentType + '). These are supported: ' + supportedTypes.join(', '), path: [] } } }
_.forEach(apis, api => { const modelsPath = path.join(apiPath, api, 'models'); let models; try { models = fs.readdirSync(modelsPath); const modelIndex = _.indexOf(_.map(models, model => _.toLower(model)), searchFileName); if (modelIndex !== -1) searchFilePath = `${modelsPath}/${models[modelIndex]}`; } catch (e) { errors.push({ id: 'request.error.folder.read', params: { folderPath: modelsPath } }); } });
/** * Get the reader options * @param {String} key - The key of options * @return {Any} * @since 2.2.0 * @example * const reader = client.query('http').set({ * limit: 10, * }); * console.info(reader.get('limit')); * // => 10 */ get(k) { if (_.indexOf(qlKeys, k) !== -1) { return this[k]; } return internal(this).options[k]; }