parser icon indicating copy to clipboard operation
parser copied to clipboard

feat: Add transform function to selector

Open saar opened this issue 6 years ago • 0 comments

If the array includes a callback function as 3rd element, all the results pass through that transformer. Returned values are the result of selector. For example:

date_published: {
    selectors: [[
        'meta[name="article:published_time"]',
         'value',
          (item) => moment.from(convertNumbersToEnglish(item), 'fa',
            'YYYY/MM/DD - HH:mm').toISOString();
    ]]
}


extend: {
  tags: {
    selectors: [[
        'meta[name=\'article:tag\']', 'value', (item) => {
        return item.split(/\s*,\s*/);
      }]],
    allowMultiple: true
  }
}

saar avatar May 30 '19 12:05 saar