Passed
Pull Request — master (#3)
by Alberto
02:16 queued 28s
created

lib/Document.js   A

Complexity

Total Complexity 8
Complexity/F 2

Size

Lines of Code 26
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 21
mnd 4
bc 4
fnc 4
dl 0
loc 26
bpm 1
cpm 2
noi 3
c 0
b 0
f 0
rs 10
1
"use strict";
2
var __assign = (this && this.__assign) || function () {
3
    __assign = Object.assign || function(t) {
4
        for (var s, i = 1, n = arguments.length; i < n; i++) {
5
            s = arguments[i];
6
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
                t[p] = s[p];
8
        }
9
        return t;
10
    };
11
    return __assign.apply(this, arguments);
12
};
13
Object.defineProperty(exports, "__esModule", { value: true });
14
var CompoundDocument_1 = require("./CompoundDocument");
15
var RelationshipsCache_1 = require("./RelationshipsCache");
16
var fromCompoundDocument = function (w) {
17
    var _a = w(), data = _a[0], relationships = _a[1];
18
    var cache = RelationshipsCache_1.RelationshipsCache.fromRelationships(relationships);
19
    var included = Object.values(RelationshipsCache_1.RelationshipsCache.lens.global.get(cache));
20
    return __assign({ data: data }, (included.length > 0 ? { included: included } : null));
21
};
22
var fromJson = function (u) { return fromCompoundDocument(CompoundDocument_1.CompoundDocument.fromJson(u, true)); };
23
exports.Document = {
24
    fromCompoundDocument: fromCompoundDocument,
25
    fromJson: fromJson
26
};
27