##// END OF EJS Templates
added safe.firstWhere
added safe.firstWhere

File last commit:

r49:1a91da7b15f7 di-typescript
r75:682bf9cf6f0c default
Show More
AggregateDescriptor.ts
37 lines | 967 B | video/mp2t | TypeScriptLexer
/ src / main / ts / di / AggregateDescriptor.ts
import { Descriptor, isDescriptor } from "./interfaces";
import { ActivationContext } from "./ActivationContext";
import { isPrimitive } from "../safe";
export class AggregateDescriptor implements Descriptor {
_value: object;
constructor(value: object) {
this._value = value;
}
activate(context: ActivationContext) {
return this._parse(this._value, context, "$value");
}
// TODO: make async
_parse(value, context: ActivationContext, path: string) {
if (isPrimitive(value))
return value;
if (isDescriptor(value))
return context.activate(value, path);
if (value instanceof Array)
return value.map((x, i) => this._parse(x, context, `${path}[${i}]`));
const t = {};
for (const p of Object.keys(value))
t[p] = this._parse(value[p], context, `${path}.${p}`);
return t;
}
toString() {
return "@walk";
}
}