fvdm / nodejs-youtube

Access public YouTube data feeds from your Node.js apps
https://www.npmjs.com/package/youtube-feeds
The Unlicense
100 stars 15 forks source link

Error when using module #8

Closed nickvanw closed 11 years ago

nickvanw commented 11 years ago

Attempting to load the module running 0.10.5 results in this:

Uncaught Exception: [TypeError: Object function (e) {
    var t, _ref;

    if ((t = this.indexOf(e)) > -1) {
      return ([].splice.apply(this, [t, t - t + 1].concat(_ref = [])), _ref);
    }
  } has no method 'copy']

running the latest version from npm

When installing, this is given:

npm WARN engine youtube-feeds@2.2.1: wanted: {"node":"<=0.8.3 >=0.10.0"} (current: {"node":"v0.10.5","npm":"1.2.18"})

Which seems odd as I am >=0.10.0?

fvdm commented 11 years ago

Hi, thanks for your report.

The installation warning is something weird in npm. The version syntax matches the documentation but still it doesn't seem to like v0.10.x.

For the other error I need more details.

nickvanw commented 11 years ago

I installed by doing: npm install youtube-feeds

The bug appears due to a small (coffeescript) function I have in my code to allow removal of array objects:

Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1

This appears to conflict with

youtube-feeds.js:220
                data[d].copy( buf, pos )

Removing it fixes the issue, however renaming it does not.

fvdm commented 11 years ago

data[d] are Buffer instances as received from the http module. I can't help you with Coffeescript, but perhaps it converts data array elements to strings (or some other type) which then loose their copy method.

nickvanw commented 11 years ago

The Coffee function evaluates directly to this javascript:

(function() {
  Array.prototype.remove = function(e) {
    var t, _ref;

    if ((t = this.indexOf(e)) > -1) {
      return ([].splice.apply(this, [t, t - t + 1].concat(_ref = [])), _ref);
    }
  };

}).call(this);
fvdm commented 11 years ago

This line in the Buffer docs is probably the reason:

While more efficient, it introduces subtle incompatibilities with the typed arrays specification. ArrayBuffer#slice() makes a copy of the slice while Buffer#slice() creates a view.

fvdm commented 11 years ago

Long story short, I won't add support for CoffeeScript. But feel free to fork this repo and adjust to your own needs :)