Skip to content

v4.1.0

Compare
Choose a tag to compare
@justinvdm justinvdm released this 08 Feb 16:37
· 13 commits to main since this release

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 the values are strings, the picked value will be constrained to be less than limit's amount of characters
  • fallback: string | (input) => string: When limit is specified but no values match the given limit, fallback is called with the given input value.