foreach-sync-callback
v1.0.3
Published
forEach sync callback function
Downloads
3
Maintainers
Readme
for-each-sync-callback
- This npm module provides you synchronize callback forEach function
Install
- npm install foreach-sync-callback
Test
const forEachSyncCallBack = require('foreach-sync-callback')
let arr = [1, 2, 3, 4, 5, 6, 7]
// You have to pass array and callback function into this function
// Callback function has parameter in below sequence
// 1. res 2. element 3. element Index 4. array
forEachSyncCallBack(arr, (res, e, i) => {
// Adding time out to check sync forEach
setTimeout(() => {
console.log(e)
//You must have to call "res()" at end of your callback function
res()
}, 1000);
})
// Function will print all element one by one in console after 1 sec