Optional
conjunction?: stringHow to join the last two elements.
Optional
stringify?: (el: any) => anyOptional function to control how elements are stringified. You are free to still return objects, etc. from this function and only stringify what you need. The returned values will still be passed through the default stringify function.
readable(["a", "b", new Animal()], {stringify: (el) => el instance of Animal ? "Animal" : el}) // a, b, and Animal
Returns an array in human readable format (with an oxford comma if there are 3 or more elements).
By default nested arrays and objects are turned into:
[...]
,{...}
,[]
or{}
depending on if they're empty or not. Functions are turned into[name] function
oranonymous function
if they have no name. Class instances are turned into[name] instance
. Classes themselves can't be differentiated from functions so the function format is used.If you need some custom behavior for some elements, see the stringify option.