Skip to content

An asyncForEach method with some handy feature such as break and redo

License

Notifications You must be signed in to change notification settings

bannostookaylo/super-asyncforeach

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

super-asyncforeach

An asyncForEach method with some handy feature such as break and redo

const asyncForEach = require('super-asyncforeach');

let values = [1,2,3,4,5];

await asyncForEach(values, async ( value, index, array ) => {
});

Special Returns

Break

Allows the user to break out of the foreach loop

let values = [1,2,3,4,5];

await asyncForEach(values, async ( value, index, array ) => {

	if ( value === 3 ) {
		return 'break';
	}
	
});

Redo

Allows the user to repeat an index if necessary

let values = [1,2,3,4,5];
let redo = 1;

await asyncForEach(values, async ( value, index, array ) => {

	console.log( value );

	if	( redo === 1 && value === 2 )	{

		redo = 2;
		return 'redo';

	}
	
});

About

An asyncForEach method with some handy feature such as break and redo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published