Created
June 15, 2018 08:33
-
-
Save kvasdopil/3212dc1f55a4b2fa0763b893e005b160 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function filter(args, func, cb) { | |
| const results = args.map(i => null); | |
| const count = 0; | |
| const error = null; | |
| args.map((item, j) => | |
| func(item, (err, res) => { | |
| count++; | |
| if (err) { | |
| error = err; | |
| } else { | |
| results[j] = res; | |
| } | |
| if(count === args.length) { | |
| cb(error, results.filter(r => r)); | |
| } | |
| }); | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment