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

dr-js

Package Overview
Dependencies
Maintainers
1
Versions
243
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dr-js - npm Package Compare versions

Comparing version 0.22.1-dev.0 to 0.22.1

55

library/common/format.js

@@ -1,9 +0,8 @@

exports.describe=t=>{const e=typeof t
let o
if("function"===e)o="()=>{...}"
else try{o=JSON.stringify(t)}catch(t){o="{...}"}return`<${e}> ${o}`}
const t=t=>JSON.stringify(t).slice(1,-1)
exports.describe=e=>{const n=Object.prototype.toString.call(e).slice(8,-1)
return`<${n}> ${"String"===n?JSON.stringify(e):"Object"===n?`{${t(Object.keys(e))}}`:"Array"===n?`[#${e.length}]`:"Function"===n?"()=>{...}":"AsyncFunction"===n?"async()=>{...}":"RegExp"===n?String(e):t(String(e))}`}
exports.percent=t=>`${(100*t).toFixed(2)}%`
const t=t=>String(Math.floor(t)).padStart(2,"0")
exports.mediaTime=e=>{const o=Math.abs(e)
return`${e<0?"-":""}${t(o/60)}:${t(o%60)}`}
const e=t=>String(Math.floor(t)).padStart(2,"0")
exports.mediaTime=t=>{const n=Math.abs(t)
return`${t<0?"-":""}${e(n/60)}:${e(n%60)}`}
exports.decimal=t=>{const e=.75*Math.abs(t)

@@ -15,32 +14,32 @@ return 0===e?"0":e<1e-9?`${(t/1e-12).toFixed(2)}pico`:e<1e-6?`${(t/1e-9).toFixed(2)}nano`:e<.001?`${(t/1e-6).toFixed(2)}micro`:e<1?`${(t/.001).toFixed(2)}milli`:e<1e3?`${(t/1).toFixed(2)}`:e<1e6?`${(t/1e3).toFixed(2)}kilo`:e<1e9?`${(t/1e6).toFixed(2)}mega`:e<1e12?`${(t/1e9).toFixed(2)}giga`:e<1e15?`${(t/1e12).toFixed(2)}tera`:e<1e18?`${(t/1e15).toFixed(2)}peta`:`${(t/1e18).toFixed(2)}exa`}

return e<1024?`${Math.floor(t)}`:e<1048576?`${(t/1024).toFixed(2)}Ki`:e<1073741824?`${(t/1048576).toFixed(2)}Mi`:e<1099511627776?`${(t/1073741824).toFixed(2)}Gi`:`${(t/1099511627776).toFixed(2)}Ti`}
exports.padTable=({table:t,padFuncList:e=[],cellPad:o=" | ",rowPad:n="\n",widthMaxList:i=t.reduce((t,e)=>{e.forEach((e,o)=>{t[o]=Math.max(String(e).length,t[o]||0)})
return t},[])})=>t.map(t=>t.map((t,o)=>{const n=String(t)
const r=e[o]
const s=i[o]
return r&&"L"!==r?"R"===r?n.padStart(s):r(n,s):n.padEnd(s)}).join(o)).join(n)
exports.prettyStringifyJSON=(t,e=2,o=" ")=>{const n=(t,e,o,n)=>{if(o>=1&&e){if(Array.isArray(e))return r(t,e,o,n)
if("object"==typeof e)return i(t,e,o,n)}const s=JSON.stringify(e)
const a=void 0===s
!a&&t.push(s)
return a}
exports.padTable=({table:t,padFuncList:e=[],cellPad:n=" | ",rowPad:o="\n",widthMaxList:i=t.reduce((t,e)=>{e.forEach((e,n)=>{t[n]=Math.max(String(e).length,t[n]||0)})
return t},[])})=>t.map(t=>t.map((t,n)=>{const o=String(t)
const r=e[n]
const s=i[n]
return r&&"L"!==r?"R"===r?o.padStart(s):r(o,s):o.padEnd(s)}).join(n)).join(o)
exports.prettyStringifyJSON=(t,e=2,n=" ")=>{const o=(t,e,n,o)=>{if(n>=1&&e){if(Array.isArray(e))return r(t,e,n,o)
if("object"==typeof e)return i(t,e,n,o)}const s=JSON.stringify(e)
const c=void 0===s
!c&&t.push(s)
return c}
const i=(t,e,i,r)=>{const s=Object.keys(e)
t.push("{\n")
const a=i-1
const c=`${r}${o}`
for(let o=0,i=s.length;o<i;o++){const i=s[o]
const c=i-1
const a=`${r}${n}`
for(let n=0,i=s.length;n<i;n++){const i=s[n]
const r=e[i]
const d=t.length
const $=t.length
t.push("")
if(n(t,r,a,c))t.length--
else{t[d]=`${c}${JSON.stringify(i)}: `
if(o(t,r,c,a))t.length--
else{t[$]=`${a}${JSON.stringify(i)}: `
t.push(",\n")}}t[t.length-1]=1===t.length?"{}":`\n${r}}`}
const r=(t,e,i,r)=>{t.push("[\n")
const s=i-1
const a=`${r}${o}`
for(let o=0,i=e.length;o<i;o++){const i=e[o]
t.push(a)
n(t,i,s,a)&&t.push("null")
const c=`${r}${n}`
for(let n=0,i=e.length;n<i;n++){const i=e[n]
t.push(c)
o(t,i,s,c)&&t.push("null")
t.push(",\n")}t[t.length-1]=1===t.length?"[]":`\n${r}]`}
const s=[]
n(s,t,Math.max(e,0)||0,"")
o(s,t,Math.max(e,0)||0,"")
return s.join("")}

@@ -0,10 +1,5 @@

const escapeString = string => JSON.stringify(string).slice(1, -1);
const describe = value => {
const valueType = typeof value;
let valueString;
if ("function" === valueType) valueString = "()=>{...}"; else try {
valueString = JSON.stringify(value);
} catch (error) {
valueString = "{...}";
}
return `<${valueType}> ${valueString}`;
const valueType = Object.prototype.toString.call(value).slice(8, -1);
return `<${valueType}> ${"String" === valueType ? JSON.stringify(value) : "Object" === valueType ? `{${escapeString(Object.keys(value))}}` : "Array" === valueType ? `[#${value.length}]` : "Function" === valueType ? "()=>{...}" : "AsyncFunction" === valueType ? "async()=>{...}" : "RegExp" === valueType ? String(value) : escapeString(String(value))}`;
};

@@ -11,0 +6,0 @@ const percent = value => `${(100 * value).toFixed(2)}%`;

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

{"name":"dr-js","version":"0.22.1-dev.0","description":"A collection of strange functions","author":"dr-js","license":"MIT","repository":"github:dr-js/dr-js","bin":"bin/index.js","browser":"library/Dr.browser.js","engines":{"node":">=10.15","npm":">=6"},"sideEffects":false}
{"name":"dr-js","version":"0.22.1","description":"A collection of strange functions","author":"dr-js","license":"MIT","repository":"github:dr-js/dr-js","bin":"bin/index.js","browser":"library/Dr.browser.js","engines":{"node":">=10.15","npm":">=6"},"sideEffects":false}

Sorry, the diff of this file is too big to display

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