rdmurphy / node-copytext

:ledger::scissors: A module for accessing a XLSX spreadsheet as a JavaScript object.
https://www.npmjs.com/package/copytext
MIT License
16 stars 1 forks source link

Include sheets by RegEx? #39

Open mhkeller opened 5 years ago

mhkeller commented 5 years ago

What do you think of this feature? Sometimes I have sheets that I prefix with a _ that are internal. Or, you could only include final sheets with some other naming convention.

I'm finally getting around to adding xlsx reading to indian ocean and was thinking of adding that ability to also be consistent with that lib's other include/exclude api.

It adds the complexity of:

  1. You can have an array of strings or RegExs
  2. If you have multiple include and exclude conditions, do you handle them as ANDs, ORs or give the user the option? Having them be ORs seems easiest and most consistent with what a user would want.
rdmurphy commented 5 years ago

Hey @mhkeller!

node-copytext is in pretty serious need of a re-write/clean-up, so what I'm thinking is we could add the ability to pass in your own include or exclude function that gets used (right now it's just a filter emulating Array.includes) so users can go wild with whatever filtering logic they want. I'd prefer to try and keep it simple inside the library if possible! Then you could use Regex, globs, etc., anything that can act on an array of strings.

Re: 2 — I think it'd probably be best to either make it impossible to pass both (which is currently how it works) or to just guarantee that include will always be followed by exclude. I've seen a few glob libraries work this way and I think it's the only way to ensure sanity.