mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-30 18:17:55 +00:00 
			
		
		
		
	 e32cf520f4
			
		
	
	e32cf520f4
	
	
	
		
			
			* add integer-to-string helper * rename and add test * add role test * finish tests * pass options so values are only converted if the type matches * okay lets hit it with the loose-equal instead * add changelog
		
			
				
	
	
		
			23 lines
		
	
	
		
			614 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			614 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| /**
 | |
|  * Copyright (c) HashiCorp, Inc.
 | |
|  * SPDX-License-Identifier: MPL-2.0
 | |
|  */
 | |
| 
 | |
| import { helper } from '@ember/component/helper';
 | |
| 
 | |
| /* 
 | |
|  * use sparingly *
 | |
|   ex: logic for an HTML element's selected boolean because <select> values are strings
 | |
|   strict equal (===) will fail if the API param is a number
 | |
|   <option selected={{loose-equal model.someAttr someOption)}} value={{someOption}}>
 | |
| */
 | |
| export function looseEqual([a, b]) {
 | |
|   // loose equal 0 == '' returns true, we don't want that
 | |
|   if ((a === 0 && b === '') || (a === '' && b === 0)) {
 | |
|     return false;
 | |
|   }
 | |
|   return a == b;
 | |
| }
 | |
| 
 | |
| export default helper(looseEqual);
 |