Skip to content

Instantly share code, notes, and snippets.

@isaacd9
Created September 16, 2017 19:47
Show Gist options
  • Save isaacd9/c952f25c15f3a442775c337d35564702 to your computer and use it in GitHub Desktop.
Save isaacd9/c952f25c15f3a442775c337d35564702 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/node
const sort = (arr) => {
const sorted = [];
const sleep = (strNum) => {
return new Promise((resolve, reject) => {
num = parseInt(strNum);
setTimeout((num) => {
sorted.push(num);
resolve();
}, num, num);
});
};
return Promise.all(args.map(sleep)).then(() => Promise.resolve(sorted));
};
args = process.argv;
args.shift();
args.shift();
sort(args).then(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment