FreeAllMedia/mrt

View on GitHub
es6/lib/component/component.properties.js

Summary

Maintainability
A
0 mins
Test Coverage
import privateData from "incognito";
import PropertyCollection from "./propertyCollection.js";

export default function properties(...propertyNames) {
    const _ = privateData(this);
    if (propertyNames.length > 0) {
        const propertyCollection = new PropertyCollection(this, propertyNames);
        _.propertyCollections.push(propertyCollection);

        return propertyCollection;
    } else {
        let propertyValues = {};

        _.propertyCollections.forEach(propertyCollection => {
            propertyValues = Object.assign(propertyValues, propertyCollection.properties);
        });

        return propertyValues;
    }
}