(format, altNames)
| 34 | // Any FormatFunc may return `undefined` to have the value omitted |
| 35 | // from the result object. Calls preserve `this`. |
| 36 | function object(format, altNames) { |
| 37 | return ((value) => { |
| 38 | const result = {}; |
| 39 | for (const key in format) { |
| 40 | let srcKey = key; |
| 41 | if (altNames && key in altNames && !(srcKey in value)) { |
| 42 | for (const altKey of altNames[key]) { |
| 43 | if (altKey in value) { |
| 44 | srcKey = altKey; |
| 45 | break; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | try { |
| 50 | const nv = format[key](value[srcKey]); |
| 51 | if (nv !== undefined) { |
| 52 | result[key] = nv; |
| 53 | } |
| 54 | } |
| 55 | catch (error) { |
| 56 | const message = (error instanceof Error) ? error.message : "not-an-error"; |
| 57 | (0, index_js_4.assert)(false, `invalid value for value.${key} (${message})`, "BAD_DATA", { value }); |
| 58 | } |
| 59 | } |
| 60 | return result; |
| 61 | }); |
| 62 | } |
| 63 | exports.object = object; |
| 64 | function formatBoolean(value) { |
| 65 | switch (value) { |
no outgoing calls
no test coverage detected