Created
April 20, 2019 11:20
-
-
Save Den1al/a35cc5aad4b4beaea5d6ac7b69adf3fe to your computer and use it in GitHub Desktop.
converting the old callback based DNS lookup in NodeJS to modern Async function
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
| import { lookup } from 'dns'; | |
| export default async function(name) { | |
| return new Promise((resolve, reject) => { | |
| lookup(name, (err, ips) => { | |
| if (err) { | |
| reject(err); | |
| } else { | |
| resolve(ips); | |
| } | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment