UNPKG

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