Code coverage report for web3/lib/web3/extend.js

Statements: 100% (26 / 26)      Branches: 87.5% (7 / 8)      Functions: 100% (4 / 4)      Lines: 100% (26 / 26)      Ignored: none     

All files » web3/lib/web3/ » extend.js
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 491 1 1 1       1   154   157 157 1 1   1   156     157 2 2 2       157 156 618 618         154 154 154 154   154         1    
var formatters = require('./formatters');
var utils = require('./../utils/utils');
var Method = require('./method');
var Property = require('./property');
 
// TODO: refactor, so the input params are not altered.
// it's necessary to make same 'extension' work with multiple providers
var extend = function (web3) {
    /* jshint maxcomplexity:5 */
    var ex = function (extension) {
 
        var extendedObject;
        if (extension.property) {
            Eif (!web3[extension.property]) {
                web3[extension.property] = {};
            }
            extendedObject = web3[extension.property];
        } else {
            extendedObject = web3;
        }
 
        if (extension.methods) {
            extension.methods.forEach(function (method) {
                method.attachToObject(extendedObject);
                method.setRequestManager(web3._requestManager);
            });
        }
 
        if (extension.properties) {
            extension.properties.forEach(function (property) {
                property.attachToObject(extendedObject);
                property.setRequestManager(web3._requestManager);
            });
        }
    };
 
    ex.formatters = formatters; 
    ex.utils = utils;
    ex.Method = Method;
    ex.Property = Property;
 
    return ex;
};
 
 
 
module.exports = extend;