(format, allowNull)
| 15 | }); |
| 16 | } |
| 17 | export function arrayOf(format, allowNull) { |
| 18 | return ((array) => { |
| 19 | if (allowNull && array == null) { |
| 20 | return null; |
| 21 | } |
| 22 | if (!Array.isArray(array)) { |
| 23 | throw new Error("not an array"); |
| 24 | } |
| 25 | return array.map((i) => format(i)); |
| 26 | }); |
| 27 | } |
| 28 | // Requires an object which matches a fleet of other formatters |
| 29 | // Any FormatFunc may return `undefined` to have the value omitted |
| 30 | // from the result object. Calls preserve `this`. |
no test coverage detected