@inversifyjs/core
Version:
InversifyJs core package
22 lines • 1.2 kB
JavaScript
import { buildPlanBindingConstraintsList } from '../calculations/buildPlanBindingConstraintsList.js';
import { LazyPlanServiceNode } from '../models/LazyPlanServiceNode.js';
import { addServiceNodeBindingIfContextFree } from './addServiceNodeBindingIfContextFree.js';
/**
* Attach a binding to the root service node if the binding is context-free.
* @param params The plan parameters.
* @param serviceNode The service node to attach the binding to.
* @param binding The binding to attach.
* @returns True if the binding requires ancestor metadata, false otherwise.
*/
export function addRootServiceNodeBindingIfContextFree(params, serviceNode, binding) {
if (LazyPlanServiceNode.is(serviceNode) && !serviceNode.isExpanded()) {
return {
isContextFreeBinding: true,
shouldInvalidateServiceNode: false,
};
}
const bindingConstraintsList = buildPlanBindingConstraintsList(params);
const chained = params.rootConstraints.isMultiple && params.rootConstraints.chained;
return addServiceNodeBindingIfContextFree(params, serviceNode, binding, bindingConstraintsList, chained);
}
//# sourceMappingURL=addRootServiceNodeBindingIfContextFree.js.map