The snip doesn't need to be a private variable
This commit is contained in:
		
							parent
							
								
									1cc23ec2ec
								
							
						
					
					
						commit
						cae1d7ca4d
					
				
					 1 changed files with 3 additions and 4 deletions
				
			
		|  | @ -11,7 +11,6 @@ import {URLs} from "/scripts/utils/URLs.js"; | ||||||
| // Don't forget to set the class as export default.
 | // Don't forget to set the class as export default.
 | ||||||
| export default class product { | export default class product { | ||||||
| 	// Create private variables for explicit use for the storage.
 | 	// Create private variables for explicit use for the storage.
 | ||||||
| 	#snip; |  | ||||||
| 	#options; | 	#options; | ||||||
| 
 | 
 | ||||||
| 	/* Initialize a new product with its details. | 	/* Initialize a new product with its details. | ||||||
|  | @ -42,10 +41,10 @@ export default class product { | ||||||
| 	async read() { | 	async read() { | ||||||
| 		if (this.details) { | 		if (this.details) { | ||||||
| 			// Add the data digest.
 | 			// Add the data digest.
 | ||||||
| 			this.#snip = (await hash.digest(this.details, {"output": "Array"})); | 			this.snip = (await hash.digest(this.details, {"output": "Array"})); | ||||||
| 	 | 	 | ||||||
| 			// Add the status about this data.
 | 			// Add the status about this data.
 | ||||||
| 			this.status[`update`] = !(await (compare([`sites`, this.URL, `snip`], this.#snip))); | 			this.status[`update`] = !(await (compare([`sites`, this.URL, `snip`], this.snip))); | ||||||
| 		}; | 		}; | ||||||
| 
 | 
 | ||||||
| 		if (!this.status.update && Object.hasOwn(this.status, `update`)) {this.analysis = await global.read([`sites`, this.URL, `analysis`]);}; | 		if (!this.status.update && Object.hasOwn(this.status, `update`)) {this.analysis = await global.read([`sites`, this.URL, `analysis`]);}; | ||||||
|  | @ -58,7 +57,7 @@ export default class product { | ||||||
| 		// There is only a need to save the data if an update is needed. 
 | 		// There is only a need to save the data if an update is needed. 
 | ||||||
| 		if (Object.hasOwn(this.status, `update`) ? this.status[`update`] : true) {	 | 		if (Object.hasOwn(this.status, `update`) ? this.status[`update`] : true) {	 | ||||||
| 			// Save the snip data. 
 | 			// Save the snip data. 
 | ||||||
| 			(this.#snip) ? await global.write([`sites`, this.URL, `snip`], this.#snip, 1) : false; | 			(this.snip) ? await global.write([`sites`, this.URL, `snip`], this.snip, 1) : false; | ||||||
| 	 | 	 | ||||||
| 			// Write the analysis data to the storage.
 | 			// Write the analysis data to the storage.
 | ||||||
| 			return((this[`analysis`]) ? global.write([`sites`, this.URL, `analysis`], this.analysis, 1) : false); | 			return((this[`analysis`]) ? global.write([`sites`, this.URL, `analysis`], this.analysis, 1) : false); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue