Skip to content

Instantly share code, notes, and snippets.

@voronianski
Last active April 25, 2016 23:10
Show Gist options
  • Save voronianski/50b48d3ae9f541a17738cabf9dc1e329 to your computer and use it in GitHub Desktop.
Save voronianski/50b48d3ae9f541a17738cabf9dc1e329 to your computer and use it in GitHub Desktop.
esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
import sizeof from 'object-sizeof';
const obj = {};
for (let i = 0, len = 20; i < len; i++) {
obj[i] = {[i]: 'i'};
}
// size obj with 20 keys and nested objects results in ~160 Bytes => ~0.16 Kbytes
console.log(sizeof(obj));
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"object-sizeof": "1.0.10",
"babel-runtime": "6.6.1"
}
}
'use strict';
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _objectSizeof = require('object-sizeof');
var _objectSizeof2 = _interopRequireDefault(_objectSizeof);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var obj = {};
for (var i = 0, len = 20; i < len; i++) {
obj[i] = (0, _defineProperty3.default)({}, i, 'i');
}
// size obj with 20 keys and nested objects results in ~160 Bytes => ~0.16 Kbytes
console.log((0, _objectSizeof2.default)(obj));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment