Sha256: 8557b836097be01091100a53b492494178a59a037142a9e7b1702830eb9b744b

Contents?: true

Size: 784 Bytes

Versions: 33

Compression:

Stored size: 784 Bytes

Contents

"use strict";

// StackOverflow: How to get object length
// http://stackoverflow.com/a/24457767/4209080

//noinspection JSUnusedGlobalSymbols
var fCalcObjSize = function (obj) {
    var count = 0;

    if (typeof obj == "object") {

        if (Object.keys) {
            count = Object.keys(obj).length;
        } else {
            //noinspection JSUnresolvedVariable
            if (window._) {
                //noinspection JSUnresolvedVariable
                count = _.keys(obj).length;
            } else if (window.$) {
                count = $.map(obj, function () {
                    return 1;
                }).length;
            } else {
                for (var key in obj) if (obj.hasOwnProperty(key)) count++;
            }
        }

    }

    return count;
};

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
c80_map_floors-0.2.2 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.1 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.8 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.7 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.6 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.5 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.4 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.3 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.2 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.1 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.2.0.0 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.25 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.24 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.23 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.22 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.21 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.20 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.19 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.18 app/assets/javascripts/lib/obj_size.js
c80_map_floors-0.1.0.17 app/assets/javascripts/lib/obj_size.js