DylanPiercey / local-devices

🔮 Find devices connected to the current local network.
MIT License
139 stars 27 forks source link

Unclear documentation #4

Closed kounelios13 closed 5 years ago

kounelios13 commented 5 years ago

Hello.I tried to use this module for a simple script.I tried to copy paste your code.However import statement is not supported.So I had to do the following:


const find = require('local-devices');

// Find all local network devices.
find().then(devices => {
    console.log('dev')
    console.log(devices)
  devices /*
  [
    { name: '?', ip: '192.168.0.10', mac: '...' },
    { name: '...', ip: '192.168.0.17', mac: '...' },
    { name: '...', ip: '192.168.0.21', mac: '...' },
    { name: '...', ip: '192.168.0.22', mac: '...' }
  ]
  */
})const find = require('local-devices');

// Find all local network devices.
find().then(devices => {
    console.log('dev')
    console.log(devices)
  devices /*
  [
    { name: '?', ip: '192.168.0.10', mac: '...' },
    { name: '...', ip: '192.168.0.17', mac: '...' },
    { name: '...', ip: '192.168.0.21', mac: '...' },
    { name: '...', ip: '192.168.0.22', mac: '...' }
  ]
  */
})

Would you accept a pull request for that?

DylanPiercey commented 5 years ago

If you plan on using import you will have to use a transpiler like Babel, or a bundler like rollup/webpack. This is the way it is for all es modules short of running them in native browsers which most are not doing.

I’d accept a PR for showing both examples in the docs, but I am happy with it using es modules as it stands.

kounelios13 commented 5 years ago

Thanks.Added an example in my pull request