remove redundancies while ensuring PATH can be convertible to an array
This commit is contained in:
		
							parent
							
								
									ff318d464b
								
							
						
					
					
						commit
						f1b70f7c1f
					
				
					 1 changed files with 11 additions and 5 deletions
				
			
		|  | @ -365,7 +365,7 @@ class global { | ||||||
| 
 | 
 | ||||||
| class session { | class session { | ||||||
| 	/* Recall session storage data. */ | 	/* Recall session storage data. */ | ||||||
| 	static async read(PATH) { | 	static async read(path) { | ||||||
| 		/* Recursively find through each data, returning either that value or null when the object is not found. | 		/* Recursively find through each data, returning either that value or null when the object is not found. | ||||||
| 
 | 
 | ||||||
| 		@param {dictionary} DATA_ALL the data | 		@param {dictionary} DATA_ALL the data | ||||||
|  | @ -376,7 +376,7 @@ class session { | ||||||
| 			let DATA = DATA_ALL; | 			let DATA = DATA_ALL; | ||||||
| 
 | 
 | ||||||
| 			// Pull the data out.
 | 			// Pull the data out.
 | ||||||
| 			if (DATA_ALL != null && (Array.isArray(DATA_PATH) && DATA_PATH != null) ? DATA_PATH.length > 0 : false) { | 			if (DATA_ALL != null && (Array.isArray(DATA_PATH)) ? DATA_PATH.length > 0 : false) { | ||||||
| 				let DATA_PATH_SELECTED = String(DATA_PATH.shift()).trim(); | 				let DATA_PATH_SELECTED = String(DATA_PATH.shift()).trim(); | ||||||
| 
 | 
 | ||||||
| 				// Get the selected data.
 | 				// Get the selected data.
 | ||||||
|  | @ -393,11 +393,17 @@ class session { | ||||||
| 
 | 
 | ||||||
| 			// Now return the data.
 | 			// Now return the data.
 | ||||||
| 			return DATA; | 			return DATA; | ||||||
| 		} | 		}; | ||||||
| 
 | 
 | ||||||
|  | 		// Change PATH to array if it isn't. 
 | ||||||
|  | 		let PATH = (!(Array.isArray(path)) && path && path != undefined) | ||||||
|  | 			? String(path).trim().split(",") | ||||||
|  | 			: ((path != null) ? path : []); | ||||||
|  | 
 | ||||||
|  | 		// Prepare data. 
 | ||||||
| 		let DATA = {}; | 		let DATA = {}; | ||||||
| 		DATA[`all`] = await chrome.storage.session.get(null); | 		DATA[`all`] = await chrome.storage.session.get(null); | ||||||
| 		(DATA[`all`]) ? DATA[`selected`] = find_data(DATA[`all`], PATH) : false; | 		(DATA[`all`]) ? DATA[`selected`] = find_data(DATA[`all`], [...PATH]) : false; | ||||||
| 		 | 		 | ||||||
| 		return (DATA[`selected`]); | 		return (DATA[`selected`]); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue