Skip to content

Commit

Permalink
Add browser build
Browse files Browse the repository at this point in the history
  • Loading branch information
genintho committed Jul 9, 2018
1 parent e3dbfe0 commit e0c3c1c
Show file tree
Hide file tree
Showing 6 changed files with 879 additions and 1 deletion.
22 changes: 22 additions & 0 deletions dist/json-size-explorer.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use strict";

const isPlainObject = require("lodash/isPlainObject");
const Stats = require("./stats");

function _main(obj, stats, path) {
const keys = Object.keys(obj);

keys.forEach((key) => {
const value = obj[key];
stats.addKeyValue(key, value);
if (isPlainObject(value)) {
_main(obj[key], stats, path + "." + key);
}
});
}

module.exports = function main(raw) {
const stat = new Stats(raw.length);
_main(JSON.parse(raw), stat, "");
return stat;
};
20 changes: 20 additions & 0 deletions dist/json-size-explorer.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const isPlainObject = require("lodash/isPlainObject");
const Stats = require("./stats");

function _main(obj, stats, path) {
const keys = Object.keys(obj);

keys.forEach((key) => {
const value = obj[key];
stats.addKeyValue(key, value);
if (isPlainObject(value)) {
_main(obj[key], stats, path + "." + key);
}
});
}

module.exports = function main(raw) {
const stat = new Stats(raw.length);
_main(JSON.parse(raw), stat, "");
return stat;
};

0 comments on commit e0c3c1c

Please sign in to comment.