chore: remove unused deprecate.fnToProperty() (#24069)
This commit is contained in:
		
					parent
					
						
							
								9c7d73c6d6
							
						
					
				
			
			
				commit
				
					
						673169a7ba
					
				
			
		
					 3 changed files with 0 additions and 42 deletions
				
			
		|  | @ -76,23 +76,6 @@ const deprecate: ElectronInternal.DeprecationUtil = { | ||||||
|     }); |     }); | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   // deprecate a getter/setter function pair in favor of a property
 |  | ||||||
|   fnToProperty: (prototype: any, prop: string, getter: string, setter?: string) => { |  | ||||||
|     const withWarnOnce = function (obj: any, key: any, oldName: string, newName: string) { |  | ||||||
|       const warn = warnOnce(oldName, newName); |  | ||||||
|       const method = obj[key]; |  | ||||||
|       return function (this: any, ...args: any) { |  | ||||||
|         warn(); |  | ||||||
|         return method.apply(this, args); |  | ||||||
|       }; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     prototype[getter.substr(1)] = withWarnOnce(prototype, getter, `${getter.substr(1)} function`, `${prop} property`); |  | ||||||
|     if (setter) { |  | ||||||
|       prototype[setter.substr(1)] = withWarnOnce(prototype, setter, `${setter.substr(1)} function`, `${prop} property`); |  | ||||||
|     } |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   // remove a property with no replacement
 |   // remove a property with no replacement
 | ||||||
|   removeProperty: (o, removedName, onlyForValues) => { |   removeProperty: (o, removedName, onlyForValues) => { | ||||||
|     // if the property's already been removed, warn about it
 |     // if the property's already been removed, warn about it
 | ||||||
|  |  | ||||||
|  | @ -169,30 +169,6 @@ describe('deprecate', () => { | ||||||
|     }).to.throw(/this is deprecated/); |     }).to.throw(/this is deprecated/); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   it('warns when a function is deprecated in favor of a property', () => { |  | ||||||
|     const warnings: string[] = []; |  | ||||||
|     deprecate.setHandler(warning => warnings.push(warning)); |  | ||||||
| 
 |  | ||||||
|     const newProp = 'newProp'; |  | ||||||
|     const mod: any = { |  | ||||||
|       _oldGetterFn () { return 'getter'; }, |  | ||||||
|       _oldSetterFn () { return 'setter'; } |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     deprecate.fnToProperty(mod, 'newProp', '_oldGetterFn', '_oldSetterFn'); |  | ||||||
| 
 |  | ||||||
|     mod.oldGetterFn(); |  | ||||||
|     mod.oldSetterFn(); |  | ||||||
| 
 |  | ||||||
|     expect(warnings).to.have.lengthOf(2); |  | ||||||
| 
 |  | ||||||
|     expect(warnings[0]).to.include('oldGetterFn'); |  | ||||||
|     expect(warnings[0]).to.include(newProp); |  | ||||||
| 
 |  | ||||||
|     expect(warnings[1]).to.include('oldSetterFn'); |  | ||||||
|     expect(warnings[1]).to.include(newProp); |  | ||||||
|   }); |  | ||||||
| 
 |  | ||||||
|   describe('moveAPI', () => { |   describe('moveAPI', () => { | ||||||
|     beforeEach(() => { |     beforeEach(() => { | ||||||
|       deprecate.setHandler(null); |       deprecate.setHandler(null); | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								typings/internal-electron.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								typings/internal-electron.d.ts
									
										
									
									
										vendored
									
									
								
							|  | @ -102,7 +102,6 @@ declare namespace ElectronInternal { | ||||||
|     removeFunction(fn: Function, removedName: string): Function; |     removeFunction(fn: Function, removedName: string): Function; | ||||||
|     renameFunction(fn: Function, newName: string | Function): Function; |     renameFunction(fn: Function, newName: string | Function): Function; | ||||||
|     event(emitter: NodeJS.EventEmitter, oldName: string, newName: string): void; |     event(emitter: NodeJS.EventEmitter, oldName: string, newName: string): void; | ||||||
|     fnToProperty(module: any, prop: string, getter: string, setter?: string): void; |  | ||||||
|     removeProperty<T, K extends (keyof T & string)>(object: T, propertyName: K, onlyForValues?: any[]): T; |     removeProperty<T, K extends (keyof T & string)>(object: T, propertyName: K, onlyForValues?: any[]): T; | ||||||
|     renameProperty<T, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T; |     renameProperty<T, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T; | ||||||
|     moveAPI(fn: Function, oldUsage: string, newUsage: string): Function; |     moveAPI(fn: Function, oldUsage: string, newUsage: string): Function; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Milan Burda
				Milan Burda