Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add transform function to selector #430

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saar
Copy link

@saar saar commented May 30, 2019

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
  }
}

If 3rd element of the selector's array is a function, all result forward to it as first parameter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants