This package has been deprecated

Author message:

This package is no longer supported

asynkron

1.1.0 • Public • Published

Asynkron :

asynkron is utility module to make async loops and reduces

Features :

Install :

just require it in node environment but in browser environment use unpkg src

<script src='https://unpkg.com/asynkron'></script>

Usage :

just pass Array / object what you want to make loop

asynkron return promise so you can use async / await with it

const asynkron = require('asynkron');
const fs = require('fs');

asynkron(['./file1', './file2', './file3'], (filepath, index, done, result) => {
    // done( item, index? )
    fs.readFile(filepath, (err, file) => {
        if ( err ) {
            // pass item and index false to break loop
            done(false, false)
        } else {
            done(file)
        }
    })
}).then(files => console.log( files ))

to use asynkron with object and change key name of it just pass result value

const asynkron = require('asynkron');
const fs = require('fs');
asynkron(['./file1', './file2', './file3'], (filepath, index, done, result) => {
     // done( item, index? )
     fs.readFile(filepath, (err, file) => {
         if ( err ) {
             // pass item and index false to break loop
             done(false, false)
         } else {
             done(file, filepath)
         }
     })
}, {} /* Result */ ).then(files => console.log( files ))
// asynkron will resolve
{
    './file1' : { ... },
    ...
}

Readme

Keywords

none

Package Sidebar

Install

npm i asynkron

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

6.46 kB

Total Files

5

Last publish

Collaborators

  • bemocode