Skip to content

Commit 248aa5d

Browse files
authored
Merge pull request #85 from Sykander/async-map-sort-specs
Async Map Sort Specs
2 parents 1d03d94 + 339d44c commit 248aa5d

File tree

10 files changed

+410
-75
lines changed

10 files changed

+410
-75
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ An Array class with additional async array methods.
3838
| **asyncFindIndex** | Find an item's index in an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Find-Index) |
3939
| **asyncForEach** | Loop over an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-For-Each) |
4040
| **asyncMap** | Map an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Map) |
41+
| **asyncMapSort** | Map an iterable object asynchronously and then resolve when it's sorted, this method is much more efficient than running a regular `asyncSort` when done with a synchronous comparison function | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Map-Sort) |
4142
| **asyncSort** | Sort an iterable object asynchronously | [wiki](https://github.com/Sykander/iterable-async/wiki/Async-Sort) |
4243

4344
## Development

docs/playground.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ const users = [1, 2, 3, 4, 5].map(() => ({
88
}));
99

1010
// Async Sort
11-
await AsyncArray.asyncSort(
11+
const sortedUsers = await AsyncArray.asyncSort(
1212
users,
13-
async ({ email: emailA }, { email: emailB }) => await emailA.localeCompare(emailB)
14-
).then(sortedUsers => {
15-
console.log('Asynchronously sorted users');
16-
console.table(sortedUsers);
17-
});
13+
async ({ email: emailA }, { email: emailB }) =>
14+
await emailA.localeCompare(emailB)
15+
);
16+
17+
console.log('Asynchronously sorted users');
18+
console.table(sortedUsers);

0 commit comments

Comments
 (0)