_.findIndex(process.argv, function (arg) { return arg === '--port' || arg === '-p'; })
handleTogglePermission(data){ let self = this; let index = _.findIndex(self.state.permissionMap, function (role) { return role.role_id == data.role; }); let currentPermissions = self.state.permissionMap[index].permission_ids; if(!data.yes){ //removing permission from state let removePermissions = _.remove(currentPermissions, function (pid) { return (pid == data.permission); }); let newPermissions = _.difference(currentPermissions, removePermissions); let newPermissionMap = self.state.permissionMap; newPermissionMap[index].permission_ids = newPermissions; self.setState({changed: true, permissionMap: newPermissionMap}); }else{ //adding permission to state let newPermissions = _.concat(currentPermissions, data.permission); let newPermissionMap = self.state.permissionMap; newPermissionMap[index].permission_ids = newPermissions; self.setState({changed: true, permissionMap: newPermissionMap}); } }
vipAddresses.forEach(function (vipAddress) { var alreadyContains = (0, _lodash.findIndex)(cache.vip[vipAddress], (0, _deltaUtils.findInstance)(instance)) > -1; if (alreadyContains) return; if (!cache.vip[vipAddress]) { cache.vip[vipAddress] = []; } cache.vip[vipAddress].push(instance); });
lionRouter.put('/:id', function(req, res) { var update = req.body; if (update.id) { delete update.id } var lion = _.findIndex(lions, {id: req.params.id}); if (!lions[lion]) { res.send(); } else { var updatedLion = _.assign(lions[lion], update); res.json(updatedLion); } });
function* explainInvalid(values, predicates, via) { if (values.length !== predicates.length) return; const pairs = _.zip(predicates, values); const isInvalid = _.negate(_.spread(isValid)); const index = _.findIndex(pairs, isInvalid); if (index !== -1) { const [spec, val] = pairs[index]; yield* firstProblem(spec, val, {path: [index], via, _in: [index]}); } }
app.get('/todos/:id', function (req, res) { var id = req.param("id"); var index = _.findIndex(todos, function (e) { return e.id == id }); // id is a string! if (index !== -1) { res.status(200).json({data: todos[index]}); } else { res.status(500).send('No todo with id: ' + id); } });
_checkConsoleTransport() { const consoleTypeFirstIndex = _.findIndex(this.transportConfig, function(n) { return n.type && n.type.toLocaleLowerCase() === "console"; }); if(consoleTypeFirstIndex === -1) { this.transportConfig.push(defaultLogger); } else { _.remove(this.transportConfig, function(n, index) { return n.type && n.type === "console" && index !== consoleTypeFirstIndex; }); } }
lionRouter.delete('/:id', function(req, res) { var lion = _.findIndex(lions, {id: req.params.id}); lions.splice(lion, 1); res.json(req.lion); });
function* explainInvalid(values, specs, via) { if (values.length !== specs.length) return; // Looks a lot like implementation of Tuple! const pairs = _.zip(specs, values); const isInvalid = ([[, spec], value]) => !isValid(spec, value); const index = _.findIndex(pairs, isInvalid); if (index !== -1) { const [[key, spec], val] = pairs[index]; yield* firstProblem(spec, val, {path: [key], via, _in: [index]}); } }
// Looks through the list to find any matching event // _filterForLatestEvent :: (Element, Index, Array) -> Boolean function _filterForLatestEvents(currentEvent, currentIndex, list) { const mostRecentIndex = _.findIndex(list, e => e.id === currentEvent.id); // If the current item index is equal or less than the most recentIndex, keep it (true) return (currentIndex <= mostRecentIndex); }
vipAddresses.forEach(function (vipAddress) { var index = (0, _lodash.findIndex)(cache.vip[vipAddress], (0, _deltaUtils.findInstance)(instance)); if (index > -1) cache.vip[vipAddress].splice(index, 1, instance);else _this13.addInstance(cache, instance); });
_.findIndex( vstore.downloadQueue, o => o.id == dataObj.id )
vipAddresses.forEach(function (vipAddress) { var index = (0, _lodash.findIndex)(cache.vip[vipAddress], (0, _deltaUtils.findInstance)(instance)); if (index > -1) cache.vip[vipAddress].splice(index, 1); });
app.get('/todos/:id', function (req, res) { var id = req.param("id"); var index = _.findIndex(todos, function (e) { return e.id == id }); // id is a string! if (index !== -1) { res.status(200).json({data: todos[index]}); } else { res.status(500).send('No todo with id: ' + id); } });
_.findIndex(download_queue, function (o) { return o.id == dataObj.id })