drewbrokke / chance-token-replacer

A simple utility to replace tokens in a string with generations from the chance random generator helper
GNU General Public License v3.0
8 stars 2 forks source link

Support passing multiple arguments to `chance` methods. #2

Open drewbrokke opened 4 years ago

drewbrokke commented 4 years ago

Right now, there is no way to call this method with both the array and quantity arguments:

// usage
chance.pickset(array, quantity)

(https://chancejs.com/helpers/pickset.html)

We should provide support for multiple arguments so we can call any method necessary.

A possible implementation idea is to just re-use the # separator that currently separates the chance method name from the configuration object (it's really just an argument). We could also make this separator configurable to any string.

The other problem to solve is to allow passing something like a raw number. I think we can solve this by going through this fallback process:

This should cover a majority of argument types a user might want to use.

drewbrokke commented 4 years ago

See https://github.com/drewbrokke/chance-token-replacer/pull/1#issue-452560411 for the original idea. Thank you @nvhoanganh.