mirror of
				https://github.com/n8n-io/n8n-nodes-starter.git
				synced 2025-10-28 14:12:24 -05:00 
			
		
		
		
	⚡ General improvements
Improve explanatory comments, correct typings, make param names consistent, and simplify execute block.
This commit is contained in:
		
					parent
					
						
							
								6f348e240e
							
						
					
				
			
			
				commit
				
					
						82b2552d10
					
				
			
		
					 4 changed files with 36 additions and 42 deletions
				
			
		|  | @ -10,20 +10,18 @@ export class ExampleNode implements INodeType { | |||
| 		description: 'Basic Example Node', | ||||
| 		defaults: { | ||||
| 			name: 'Example Node', | ||||
| 			color: '#772244', | ||||
| 		}, | ||||
| 		inputs: ['main'], | ||||
| 		outputs: ['main'], | ||||
| 		properties: [ | ||||
| 			// Node properties which the user gets displayed and
 | ||||
| 			// can change on the node.
 | ||||
| 			// Node properties that the user can see and change on the node.
 | ||||
| 			{ | ||||
| 				displayName: 'My String', | ||||
| 				name: 'myString', | ||||
| 				type: 'string', | ||||
| 				default: '', | ||||
| 				placeholder: 'Placeholder value', | ||||
| 				description: 'The description text', | ||||
| 				description: 'This is a description', | ||||
| 			}, | ||||
| 		], | ||||
| 	}; | ||||
|  | @ -31,15 +29,12 @@ export class ExampleNode implements INodeType { | |||
| 	async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> { | ||||
| 		const items = this.getInputData(); | ||||
| 
 | ||||
| 		let item: INodeExecutionData; | ||||
| 		let myString: string; | ||||
| 
 | ||||
| 		// Iterates over all input items and add the key "myString" with the
 | ||||
| 		// value the parameter "myString" resolves to.
 | ||||
| 		// (This could be a different value for each item in case it contains an expression)
 | ||||
| 		// The node iterates over all input items and adds the key "myString" with the
 | ||||
| 		// value the parameter "myString" resolves to. (This could be a different value
 | ||||
| 		// for each item in case it contains an expression.)
 | ||||
| 		for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { | ||||
| 			myString = this.getNodeParameter('myString', itemIndex, '') as string; | ||||
| 			item = items[itemIndex]; | ||||
| 			const myString = this.getNodeParameter('myString', itemIndex, '') as string; | ||||
| 			const item = items[itemIndex]; | ||||
| 
 | ||||
| 			item.json['myString'] = myString; | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue