| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2017-03-12 10:52:39 +08:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | module.exports = function removeAndDo(collection, thing, action) { | 
					
						
							| 
									
										
										
										
											2017-03-12 10:52:39 +08:00
										 |  |  | 	const idx = this[collection].indexOf(thing); | 
					
						
							|  |  |  | 	const hasThingInCollection = idx >= 0; | 
					
						
							|  |  |  | 	if(hasThingInCollection) { | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 		this[collection].splice(idx, 1); | 
					
						
							|  |  |  | 		thing[action](this); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-12 10:52:39 +08:00
										 |  |  | 	return hasThingInCollection; | 
					
						
							| 
									
										
										
										
											2015-07-08 20:39:02 +08:00
										 |  |  | }; |