Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add promise support #28

Open
vjpr opened this issue Aug 5, 2019 · 3 comments
Open

Add promise support #28

vjpr opened this issue Aug 5, 2019 · 3 comments
Labels
Milestone

Comments

@vjpr
Copy link

vjpr commented Aug 5, 2019

No description provided.

@danielkrainas danielkrainas added this to the Version 2 milestone Aug 5, 2019
@danielkrainas
Copy link
Owner

Thanks for the suggestion! I will be including promises with the next major revision

@vjpr
Copy link
Author

vjpr commented Aug 5, 2019

Workaround

const netstatP = opts =>
  new Promise((resolve, reject) => {
    const res = []
    netstat(
      {
        ...opts,
        done: err => {
          if (err) return reject(err)
          return resolve(res)
        },
      },
      data => res.push(data),
    )
    return res
  })

EDIT: Couldn't get it to work.

@richardeschloss
Copy link

richardeschloss commented Nov 12, 2019

For what it's worth, @vjpr snippet worked for me when running:

netstatP({ filter: { protocol: 'tcp' } }).then((data) => {
    console.log('data', data)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants