medialab/artoo

Arrow Function Shorthand Syntax

stephancasas opened this issue · 1 comments

Looking at the documentation, arrow functions can be used in artoo.scrape() in lieu of the extended function($) syntax:

artoo.scrape('ul > li', {
  text: ($, el) => $(el).text(),
  nb: ($, el) => +$(el).attr('data-nb')
})

I can't seem to get this to work without breaking-down each collected attribute into an object and assigning a method property:

artoo.scrape('ul > li', {
  text: {
    method: ($, el) => $(el).text()
  }
});

I've tested in the browser with jQuery and in a Node environment with Cheerio, and am seeing the same behavior in both cases. Am I missing something?

Cheers

Good catch @stephancasas. I have published a fix along with version v0.4.4