localtunnel.js 498 B

1234567891011121314
  1. const Tunnel = require('./lib/Tunnel');
  2. module.exports = function localtunnel(arg1, arg2, arg3) {
  3. const options = typeof arg1 === 'object' ? arg1 : { ...arg2, port: arg1 };
  4. const callback = typeof arg1 === 'object' ? arg2 : arg3;
  5. const client = new Tunnel(options);
  6. if (callback) {
  7. client.open(err => (err ? callback(err) : callback(null, client)));
  8. return client;
  9. }
  10. return new Promise((resolve, reject) =>
  11. client.open(err => (err ? reject(err) : resolve(client)))
  12. );
  13. };