v4.1.0
feat: Support oneOfString()
copycat.oneOfString(input, values[, options])
Like oneOf()
, takes in an input
value and an array of values
, and returns an item in values
that corresponds to that input
. However, values
needs to be an array of string values, and only values within the character limit set by the limit
option will be picked.
copycat.oneOfString('foo', ['short', 'loooooooong'], { limit: 6 })
// => 'short'
options
limit
: If thevalues
are strings, the picked value will be constrained to be less thanlimit
's amount of charactersfallback: string | (input) => string
: Whenlimit
is specified but no values match the givenlimit
, fallback is called with the given input value.