New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

json-summary

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-summary - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

dist/summarizer.css

2

dist/json-summary.esm.js

@@ -1,2 +0,2 @@

// https://andrewtburks.dev/json-summary v0.2.4 Copyright 2019 Andrew Burks
// https://andrewtburks.dev/json-summary v0.2.5 Copyright 2019 Andrew Burks
const summarizer = (function() {

@@ -3,0 +3,0 @@ let defaultOptions = {

@@ -1,2 +0,2 @@

// https://andrewtburks.dev/json-summary v0.2.4 Copyright 2019 Andrew Burks
// https://andrewtburks.dev/json-summary v0.2.5 Copyright 2019 Andrew Burks
(function (global, factory) {

@@ -3,0 +3,0 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

@@ -1,2 +0,2 @@

// https://andrewtburks.dev/json-summary v0.2.4 Copyright 2019 Andrew Burks
// https://andrewtburks.dev/json-summary v0.2.5 Copyright 2019 Andrew Burks
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).jsonSummary=t()}(this,function(){"use strict";return function(){let e={arraySampleCount:10,indentation:" ",indentCount:2,showExampleValue:!0,startExpanded:!1,theme:"dark"};return function({arraySampleCount:t=10,indentation:n=" ",indentCount:r=2,showExampleValue:a=!0,startExpanded:s=!1,theme:o="dark"}=e){let u={arraySampleCount:t,indentation:n,indentCount:r,showExampleValue:a,startExpanded:s,theme:o};function l(e){let t={Array:!0,Object:!0,boolean:!0,string:!0,number:!0},n=e.filter(e=>t[e.type]);if(n.length){let e=n[0].type;return function(e,t){return e=e.filter(e=>e.type===t),{string:function(e){let t=e.reduce((e,t)=>Math.min(e,t.range[0]),1/0),n=e.reduce((e,t)=>Math.max(e,t.range[1]),-1/0);return{type:"string",example:e[0].example,range:[t,n],count:e.reduce((e,t)=>e+t.count,0)}},number:function(e){let t=e.reduce((e,t)=>Math.min(e,t.range[0]),1/0),n=e.reduce((e,t)=>Math.max(e,t.range[1]),-1/0);return{type:"number",example:e[0].example,range:[t,n],count:e.reduce((e,t)=>e+t.count,0)}},boolean:function(e){return{type:"boolean",example:e[0].example,count:e.reduce((e,t)=>e+t.count,0)}},Object:function(e){let t={};for(let n of e)if(!n.circular)for(let e of n.keys)!t[e]&&(t[e]=[]),t[e].push(n.items[e]);let n={type:"Object",keys:[],items:{},count:e.length};for(let e of Object.keys(t))n.keys.push(e),n.items[e]=l(t[e]);return n},Array:function(e){let t=l(e.map(e=>e.items[0]).filter(e=>e));return{count:e.length,items:{0:t},length:t.count/e.length,type:"Array"}}}[t](e)}(n.filter(t=>t.type===e),e)}return{count:0}}function i(e,t,n){return{type:()=>`<span class="json-summary json-summary-type json-summary-type-${e}">&lt;${e}&gt;</span>`,value:()=>`<span class="json-summary json-summary-value json-summary-value-${n}">${e}</span>`,range:()=>`<span class="json-summary json-summary-range json-summary-range-${n}">[${e[0]}, ${e[1]}]</span>`,name:()=>`<span class="json-summary json-summary-name">${e}</span>`,length:()=>`<span class="json-summary json-summary-length">(${e})</span>`,circular:()=>`<span class="json-summary json-summary-circular">${e}</span>`,layer:()=>`<span class="json-summary json-summary-checkbox ${u.startExpanded?"checked":""}">\n <input type="checkbox" ${u.startExpanded?"checked":""}>\n <span class="json-summary-checkboxmarker" onclick="(function(me){\n me.parentNode.classList.toggle('checked');\n })(this)"></span>\n </span><div class="json-summary json-summary-layer">${e}</div>`,child:()=>`<div class="json-summary json-summary-child">${e}</div>`,keys:()=>`<span class="json-summary json-summary-keys">${e}</span>`}[t]()}return{summarize:function(e){let n=function e(n){let r={Array:n=>{let r={count:1,type:"Array",length:n.length};if(n.length)if(t>0){let a=Math.min(t,n.length),s={};for(;a>0;){let e=Math.floor(Math.random()*n.length);s.hasOwnProperty(e)||(s[e]=n[e],a--)}let o=[];for(let[t,n]of Object.entries(s))o.push(e(n));let u=l(o);r.items={0:u}}else r.items={0:e(n[0])};else r.items={0:void 0};return r},Object:t=>{let n={count:1,type:"Object",keys:Object.keys(t),items:{}};for(let r of n.keys)n.items[r]=e(t[r]);return n},Other:e=>{let t;return"string"==typeof e?t=[e.length,e.length]:"number"==typeof e&&(t=[e,e]),{type:typeof e,example:e,count:1,range:t}}},a="Other";return n instanceof Array?a="Array":n instanceof Object&&(a="Object"),n&&n["*snippets_mark*"]?{type:a,circular:!0}:("Other"!==a&&(Object.defineProperty(n,"*snippets_mark*",{enumerable:!1,writable:!0,configurable:!0}),n["*snippets_mark*"]=!0),r[a](n))}(e);return function e(t){if(t&&t["*snippets_mark*"])if(delete t["*snippets_mark*"],t instanceof Array&&t.length)e(t[0]);else if(t instanceof Object)for(let n of Object.keys(t))e(t[n])}(e),n},printSummary:function(e){return`<div class='json-summary-wrapper ${u.theme}'>`+function e(t,n,r){let a="";if(t.circular)a+=i("(circular reference)","circular");else if("Object"===t.type){a+="{";let r=t.keys.map(e=>`'${e}'`).join(", ");a+=i(r,"keys");let o=t.keys.map(r=>e(t.items[r],n+1,t.count));if(o.length){let e="\n";for(let r=0;r<t.keys.length;r++)e+=u.indentation.repeat((n+1)*u.indentCount),e+=i(t.keys[r],"name")+": ",t.count>1&&(e+=`<div class="json-summary json-summary-bar" title="${(s=t.items[t.keys[r]].count/t.count*100).toFixed(2)}%"><div class="json-summary json-summary-percentage" style="width:${s}%;"></div></div>`),e+=o[r],r<t.keys.length-1&&(e+=","),e+="\n";e+=u.indentation.repeat(n*u.indentCount),a+=i(e,"child")}a=i(a+="}","layer")}else if("Array"===t.type){if(a+=i(t.count>1?"μ = "+t.length.toFixed(1):t.length,"length")+" [",t.length){let r="Object"===t.items[0].type||"Array"===t.items[0].type;r&&(a+="\n"+u.indentation.repeat((n+1)*u.indentCount)),a+=e(t.items[0],n+1,t.count),r&&(a+="\n"+u.indentation.repeat(n*u.indentCount))}a+="]"}else null==t.example||null==t.example?a+=i("?","type"):a+=i(t.type,"type"),u.showExampleValue&&(a+=i(t.example,"value",t.type),t.count>1&&t.range&&(a+=i(t.range,"range",t.type)));var s;return a}(e,0)}}}}()});
{
"name": "json-summary",
"version": "0.2.4",
"version": "0.2.5",
"description": "A simple JSON summarizer to extract the structure from a JSON object",

@@ -15,2 +15,6 @@ "keywords": [

"browserMin": "dist/json-summary.min.js",
"files":[
"/dist",
"index.js"
],
"scripts": {

@@ -17,0 +21,0 @@ "jest": "jest",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc