All files / wdclib Utilities.js

100% Statements 8/8
50% Branches 1/2
100% Functions 5/5
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75                    1x 1x 1x                                                 1x   2x       4x     1x               1x                                        
/**
 * WARNING - copies are BY REFERENCE
 *
 * @param {Object} src Source Object
 * @param {Object} dest Target Object
 *
 * @returns {Undefined}
 */
export function copyFunctions (src, dest) {
 
    for (let key in src) {
        Eif (typeof src[key] === 'function') {
            dest[key] = src[key];
        }
    }
}
 
/**
* This function will link the given list of properties using getter/setter referencing
* the source. It's designed for 'by value' properties related to the qt.webchannel implementation for the new WebEngine
* 
* Important:
* The target object will be mutated
*             
* 
* @param {Object} source 
* @param {Object} target
* @param {Array} propertyList
* @returns {Undefined}
*/
export function linkObjectProperties (source, target, propertyList) {
 
    /**
     * Array.forEach ( supported by Edge )
     * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
    */
 
    propertyList.forEach(function (propertyName) {
 
        Object.defineProperty(target, propertyName, {
            enumerable: true,
            configurable: true,
            get: function () {
                return source[propertyName];
            },
            set: function (value) {
                source[propertyName] = value;
            }
        });
 
    });
 
}
 
export let tableauProperties = [
    'authPurpose',
    'authType',
    'connectionData',
    'connectionName',
    'language',
    'locale',
    'logLevel',
    'password',
    'phase',
    'platformBuildNumber',
    'platformEdition',
    'platformOs',
    'platformVersion',
    'propertiesReady',
    'scriptVersion',
    'username',
    'usernameAlias',
    'APIVersion'
];