Skip to content

Instantly share code, notes, and snippets.

@vovk1805
Last active July 23, 2021 16:33
Show Gist options
  • Save vovk1805/ff960d3127331f6f7c57be68b57164f2 to your computer and use it in GitHub Desktop.
Save vovk1805/ff960d3127331f6f7c57be68b57164f2 to your computer and use it in GitHub Desktop.
Async filter JS
const promise = new Promise((res) => res('lol'));
const arr = [1, 2, 3, 4, 5];
const result = arr.filter(async (el) => {
const res = await promise;
if (res !== 'lol') {
return el;
}
});
// після фільтрації тут мав би бути пустий масив
console.log('result ↓↓↓↓↓↓↓↓↓↓↓↓↓');
console.dir(result, { depth: 10000, colors: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment