make writing async
This commit is contained in:
		
							parent
							
								
									ddce5b4320
								
							
						
					
					
						commit
						5c61411280
					
				
					 1 changed files with 15 additions and 17 deletions
				
			
		|  | @ -229,7 +229,7 @@ export async function search(SOURCE, TERM, ADDITIONAL_PLACES, STRICT = false) { | ||||||
| @param {object} DATA the new data to be written | @param {object} DATA the new data to be written | ||||||
| @param {int} CLOUD store in the cloud; otherwise set to automatic | @param {int} CLOUD store in the cloud; otherwise set to automatic | ||||||
| */ | */ | ||||||
| export function write(PATH, DATA, CLOUD = -1) { | export async function write(PATH, DATA, CLOUD = -1) { | ||||||
| 	let DATA_INJECTED = {}; | 	let DATA_INJECTED = {}; | ||||||
| 
 | 
 | ||||||
| 	/* Forcibly write the data to chrome database | 	/* Forcibly write the data to chrome database | ||||||
|  | @ -278,9 +278,8 @@ export function write(PATH, DATA, CLOUD = -1) { | ||||||
| 		return DATABASE; | 		return DATABASE; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	read(null, CLOUD).then((DATA_ALL) => { | 	let DATA_ALL = await read(null, CLOUD); | ||||||
| 		// handle empty collected data.
 | 	if ((DATA_ALL != null && (typeof DATA_ALL).includes(`obj`)) ? Object.keys(DATA_ALL).length <= 0 : true) { | ||||||
| 		if (!DATA_ALL) { |  | ||||||
| 		DATA_ALL = {}; | 		DATA_ALL = {}; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -297,7 +296,6 @@ export function write(PATH, DATA, CLOUD = -1) { | ||||||
| 
 | 
 | ||||||
| 	// Write!
 | 	// Write!
 | ||||||
| 	write_database(DATA_INJECTED, CLOUD); | 	write_database(DATA_INJECTED, CLOUD); | ||||||
| 	}); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Dangerous: Resets all data or a domain's data. | /* Dangerous: Resets all data or a domain's data. | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue