UNPKG

@aire-ux/aire-condensation

Version:

Client-side serialization library for Aire-UX

40 lines (39 loc) 985 B
/** * * @param invocation the invocation to perform * */ // export function invoke<T>( // invocation: Invocation // ) : T { // // let ctx = Condensation.defaultContext(); // let inv = invocation, // target = window; // while(inv.next) { // const qnamePath = inv.qualifiedName.split('.'); // target = locate(qnamePath, target); // if(typeof target === 'function') { // Condensation. // } // } // // // // } // export function locate(qnamePath, v) { let host = v, property = undefined, size = qnamePath.length; for (let i = 0; i < size; i++) { const pathSegment = qnamePath[i]; property = host[pathSegment]; if (!property) { throw new Error(`Error: no property ${property} on ${host}`); } if (i === size - 1) { return [host, property]; } host = property; } throw new Error(`Error: no property at ${qnamePath.join(".")} reachable from ${host}`); }