* Compiles a reference expression for single-row evaluation
(ref: PropRef)
| 214 | * Compiles a reference expression for single-row evaluation |
| 215 | */ |
| 216 | function compileSingleRowRef(ref: PropRef): CompiledSingleRowExpression { |
| 217 | const propertyPath = ref.path |
| 218 | |
| 219 | // This function works for all path lengths including empty path |
| 220 | return (item) => { |
| 221 | let value: any = item |
| 222 | for (const prop of propertyPath) { |
| 223 | if (value == null) { |
| 224 | return value |
| 225 | } |
| 226 | value = value[prop] |
| 227 | } |
| 228 | return value |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Compiles a function expression for both namespaced and single-row evaluation |
no outgoing calls
no test coverage detected