UNPKG

1.1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const iterare_1 = require("iterare");
4/**
5 * Returns the instances which are transient
6 * @param instances The instances which should be checked whether they are transcient
7 */
8function getTransientInstances(instances) {
9 return iterare_1.default(instances)
10 .filter(([_, wrapper]) => wrapper.isDependencyTreeStatic())
11 .map(([_, wrapper]) => wrapper.getStaticTransientInstances())
12 .flatten()
13 .filter(item => !!item)
14 .map(({ instance }) => instance)
15 .toArray();
16}
17exports.getTransientInstances = getTransientInstances;
18/**
19 * Returns the instances which are not transient
20 * @param instances The instances which should be checked whether they are transcient
21 */
22function getNonTransientInstances(instances) {
23 return iterare_1.default(instances)
24 .filter(([key, wrapper]) => wrapper.isDependencyTreeStatic() && !wrapper.isTransient)
25 .map(([key, { instance }]) => instance)
26 .toArray();
27}
28exports.getNonTransientInstances = getNonTransientInstances;