matthewmueller / x-ray

The next web scraper. See through the <html> noise.
MIT License
5.87k stars 349 forks source link

Warn if constructor is misused #133

Closed jspri closed 5 years ago

jspri commented 8 years ago

Love the library. A few times out of habbit instead of doing

var Xray = require('x-ray');
var x = Xray();

x(url, selector)(fn)...

I've found myself forgetting to call the constructor (line 2) and instead doing Xray(url, selector).... This can be a bit of a pain to debug as whatever callback you pass into the constructor is never called. Often I've thought I've parsed some strange combination of parameters and broken x-ray. As currently the constructor takes no arguments it may be useful to throw an error when arguments are passed to prevent other people from making the same mistake.

I'm not sure if calling throw from within an addon is the done thing, so if someone can outline the best way to do this then I'll write up a PR.

lathropd commented 5 years ago

Closing for now. Sorry nobody ever got back to you.