object-sizeof
Advanced tools
Comparing version 1.0.6 to 1.0.7
17
index.js
@@ -37,3 +37,3 @@ // Copyright 2014 Andrei Karpushonak | ||
* Calculates Bytes for the provided parameter | ||
* @param object - handles object/string/boolean | ||
* @param object - handles object/string/boolean/buffer | ||
* @returns {*} | ||
@@ -46,6 +46,11 @@ */ | ||
if (_.isObject(object)) { | ||
var stats = new Stats(); | ||
collectKeysValues(object, stats); | ||
// calculate size in Bytes based on ECMAScript Language Specs | ||
bytes = stats.calculateBytes(); | ||
if (Buffer.isBuffer(object)) { | ||
bytes = object.length; | ||
} | ||
else { | ||
var stats = new Stats(); | ||
collectKeysValues(object, stats); | ||
// calculate size in Bytes based on ECMAScript Language Specs | ||
bytes = stats.calculateBytes(); | ||
} | ||
} else if (_.isString(object)) { | ||
@@ -61,2 +66,2 @@ bytes = object.length * ECMA_SIZES.STRING; | ||
module.exports = sizeof; | ||
module.exports = sizeof; |
{ | ||
"name": "object-sizeof", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Sizeof of a JavaScript object in bytes", | ||
@@ -23,8 +23,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash": "^3.9.1" | ||
"lodash": "^3.10.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.19.0", | ||
"should": "~3.3.1" | ||
"mocha": "~2.3.4", | ||
"should": "~8.0.2" | ||
} | ||
} |
@@ -41,2 +41,6 @@ "use strict"; | ||
}); | ||
it('buffer size should be correct', function() { | ||
sizeof(new Buffer(3)).should.be.equal(3); | ||
}); | ||
@@ -60,2 +64,2 @@ it('nested objects shall be counted in full', function() { | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8118
153
Updatedlodash@^3.10.1