1.0.3 • Published 2 years ago

foreach-sync-callback v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago