node-yahoo-finance2
node-yahoo-finance2 copied to clipboard
Set global defaults
Feature Request
Wanted Feature
A recommended method to set global defaults.
Use Cases
Currently we can override defaults per request. But's a bit weird for things like the queue, which affects all past and future requests too.
Potential Example Usage
// with run-time validation
yahooFinance.setConfig({ ... });
// perhaps to be clearer about what's a default for future requests
yahooFinance.setDefault({});
Timeline
- [X] API (#133) - thanks @PythonCreator27
- [ ] Update docs that mention
_opts
- [ ] Docs to explain difference between global options and global defaults? (e.g. queue opts are global opts, but maybe we have some fetch opts that are defaults used for each request and can be overriden)
- [ ] Change behaviour in
yf.*
funcs that any overrides should be just for that call, and should throw an error if trying to override a global option (like the queue, this isn't really make sense, as there is only one queue for all requests). NB: this WOULD be a breaking change but since the queue code is still only in devel and has not been released, we're all good!
@gadicc I absolutely agree. It would just involve setting properties on _opts
, right? If so, I can send a PR soon.
I think that setConfig
makes more sense, as it is more clear about what is being set. Maybe setGlobalConfig
would be better?
Would it make more sense to override the default config, or just merge them? I would go with merging, as it is usually a more predictable behavior. What do you think, @gadicc?