All files / datamodel/src/operator get-common-schema.js

100% Statements 8/8
100% Branches 2/2
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                  16x 16x 16x 64x   16x 54x 20x     16x    
/**
 * The helper function that returns an array of common schema
 * from two fieldStore instances.
 *
 * @param {FieldStore} fs1 - The first FieldStore instance.
 * @param {FieldStore} fs2 - The second FieldStore instance.
 * @return {Array} An array containing the common schema.
 */
export function getCommonSchema (fs1, fs2) {
    const retArr = [];
    const fs1Arr = [];
    fs1.fields.forEach((field) => {
        fs1Arr.push(field.schema.name);
    });
    fs2.fields.forEach((field) => {
        if (fs1Arr.indexOf(field.schema.name) !== -1) {
            retArr.push(field.schema.name);
        }
    });
    return retArr;
}