super-asyncforeach

1.0.2 • Public • Published

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';

	}
	
});

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i super-asyncforeach

      Weekly Downloads

      55

      Version

      1.0.2

      License

      MIT

      Unpacked Size

      3.42 kB

      Total Files

      5

      Last publish

      Collaborators

      • banning