(obj, path)
| 79 | * Reads a (possibly deep) path off of an object. |
| 80 | */ |
| 81 | const get = (obj, path) => { |
| 82 | let fallback = ''; |
| 83 | if (Array.isArray(path)) { |
| 84 | [path, fallback] = path; |
| 85 | } |
| 86 | const parts = path.split('.'); |
| 87 | while (obj && parts.length) { |
| 88 | obj = obj[parts.shift()]; |
| 89 | } |
| 90 | return obj == null || obj === '' ? fallback : obj; |
| 91 | }; |
| 92 | |
| 93 | /** |
| 94 | * Renders a table of data, plucking the given properties from each item in |