Comparing version 0.22.0 to 0.22.1-dev.0
@@ -15,26 +15,32 @@ exports.describe=t=>{const e=typeof t | ||
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:i="\n",widthMaxList:r=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 i=String(t) | ||
const n=e[o] | ||
const s=r[o] | ||
return n&&"L"!==n?"R"===n?i.padStart(s):n(i,s):i.padEnd(s)}).join(o)).join(i) | ||
const e=(t,o,i,r)=>{if(i>=1&&o){if(Array.isArray(o))return((t,o,i,r)=>{if(0===o.length)return t.push("[]") | ||
t.push("[\n") | ||
const n=i-1 | ||
const s=`${r} ` | ||
o.forEach(o=>{t.push(s) | ||
e(t,o,n,s) | ||
t.push(",\n")}) | ||
t[t.length-1]=`\n${r}]`})(t,o,i,r) | ||
if("object"==typeof o)return((t,o,i,r)=>{const n=Object.entries(o) | ||
if(0===n.length)return t.push("{}") | ||
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} | ||
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 r=e[i] | ||
const d=t.length | ||
t.push("") | ||
if(n(t,r,a,c))t.length-- | ||
else{t[d]=`${c}${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} ` | ||
n.forEach(([o,i])=>{t.push(a,JSON.stringify(o),": ") | ||
e(t,i,s,a) | ||
t.push(",\n")}) | ||
t[t.length-1]=`\n${r}}`})(t,o,i,r)}t.push(JSON.stringify(o))} | ||
exports.prettyStringifyJSON=(t,o=2)=>{const i=[] | ||
e(i,t,Math.max(o,0)||0,"") | ||
return i.join("")} | ||
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") | ||
t.push(",\n")}t[t.length-1]=1===t.length?"[]":`\n${r}]`} | ||
const s=[] | ||
n(s,t,Math.max(e,0)||0,"") | ||
return s.join("")} |
@@ -6,3 +6,3 @@ exports.objectSet=(e,t,r)=>e[t]!==r?Object.assign({},e,{[t]:r}):e | ||
return r} | ||
exports.objectMerge=(e,t)=>{for(const[r,o]of Object.entries(t))if(e[r]!==o)return Object.assign({},e,t) | ||
exports.objectMerge=(e,t)=>{for(const[r,o]of Object.entries(t))if(e[r]!==o)return Object.assign({},e,{},t) | ||
return e} | ||
@@ -9,0 +9,0 @@ exports.objectMap=(e,t)=>{const r={} |
@@ -12,3 +12,3 @@ var e=require("../verify") | ||
exports.createStateStore=s | ||
exports.createStateStoreLite=e=>({getState:()=>e,setState:t=>e=Object.assign({},e,t)}) | ||
exports.createStateStoreLite=e=>({getState:()=>e,setState:t=>e=Object.assign({},e,{},t)}) | ||
exports.createStateStoreEnhanced=({initialState:t,enhancer:r,reducer:c})=>{(0,e.basicFunction)(r,"enhancer function required");(0,e.basicFunction)(c,"reducer function required") | ||
@@ -15,0 +15,0 @@ const{subscribe:n,unsubscribe:a,getState:u,setState:i}=s(t) |
@@ -7,3 +7,3 @@ var e=require("../time") | ||
const l=(e,t)=>{const s=k(e) | ||
s&&T.set(e,Object.assign({},s,t))} | ||
s&&T.set(e,Object.assign({},s,{},t))} | ||
const i=e=>T.delete(e) | ||
@@ -10,0 +10,0 @@ return{clear:()=>{c() |
@@ -14,3 +14,3 @@ var t=require("path") | ||
exports.INITIAL_FACT_INFO=F | ||
exports.createFactDatabase=async e=>{let{initialFactInfo:c,initialState:n=l,applyFact:u=((t,e)=>Object.assign({},t,e)),encodeFact:h=JSON.stringify,decodeFact:p=JSON.parse,pathFactDirectory:g,nameFactLogFile:y=s,nameFactCacheFile:I=f,onError:m}=e,S=function(t,e){if(null==t)return{} | ||
exports.createFactDatabase=async e=>{let{initialFactInfo:c,initialState:n=l,applyFact:u=((t,e)=>Object.assign({},t,{},e)),encodeFact:h=JSON.stringify,decodeFact:p=JSON.parse,pathFactDirectory:g,nameFactLogFile:y=s,nameFactCacheFile:I=f,onError:m}=e,S=function(t,e){if(null==t)return{} | ||
var a={} | ||
@@ -17,0 +17,0 @@ var c=Object.keys(t) |
@@ -31,3 +31,3 @@ var t=require("../../../common/string") | ||
const s=()=>!0 | ||
const o=(t,a,s)=>{t=Object.assign({},e,t) | ||
const o=(t,a,s)=>{t=Object.assign({},e,{},t) | ||
!r.test(t.name)&&m(`name '${t.name}'`,t,a,s) | ||
@@ -34,0 +34,0 @@ t.shortName&&!i.test(t.shortName)&&m(`shortName '${t.shortName}'`,t,a,s) |
@@ -31,3 +31,3 @@ var e=require("path") | ||
const c=p?"env"===p?g(o(process.env),process.cwd()):g(n((0,t.tryRequire)((0,e.resolve)(process.cwd(),p))||i(`failed to load config: ${p}`)),(0,e.dirname)((0,e.resolve)(process.cwd(),p))):null | ||
return a(Object.assign({},c,s))} | ||
return a(Object.assign({},c,{},s))} | ||
exports.parseOptionMap=m | ||
@@ -34,0 +34,0 @@ const g=(t,r)=>{Object.values(t).forEach(({format:{isPath:t},argumentList:o})=>t&&o.forEach((t,n)=>o[n]=(0,e.resolve)(r,t))) |
@@ -17,3 +17,3 @@ var e=require("crypto") | ||
r.indexOf(n)>=0||(t[n]=e[n])}return t}(e,["protocol"]) | ||
if(!l.has(o))throw new Error(`invalid protocol: ${o}`);(s=Object.assign({},"https:"===o?a:i,s)).baseUrl=`${o}//${s.hostname}:${s.port}` | ||
if(!l.has(o))throw new Error(`invalid protocol: ${o}`);(s=Object.assign({},"https:"===o?a:i,{},s)).baseUrl=`${o}//${s.hostname}:${s.port}` | ||
const c=s.isSecure?(0,t.createServer)(s):(0,r.createServer)() | ||
@@ -20,0 +20,0 @@ s.isSecure&&(e=>{const r=(0,n.createCacheMap)({valueSizeSumMax:4096,eventHub:null}) |
@@ -40,37 +40,46 @@ const describe = value => { | ||
}).join(cellPad)).join(rowPad); | ||
const prettyStringifyJSONSwitch = (resultList, value, level, padString) => { | ||
if (level >= 1 && value) { | ||
if (Array.isArray(value)) return ((resultList, array, level, padString) => { | ||
if (0 === array.length) return resultList.push("[]"); | ||
resultList.push("[\n"); | ||
const nextLevel = level - 1; | ||
const nextPadString = `${padString} `; | ||
array.forEach(value => { | ||
resultList.push(nextPadString); | ||
prettyStringifyJSONSwitch(resultList, value, nextLevel, nextPadString); | ||
const prettyStringifyJSON = (value, unfoldLevel = 2, pad = " ") => { | ||
const stringifySwitch = (resultList, value, level, padString) => { | ||
if (level >= 1 && value) { | ||
if (Array.isArray(value)) return stringifyArray(resultList, value, level, padString); | ||
if ("object" == typeof value) return stringifyObject(resultList, value, level, padString); | ||
} | ||
const result = JSON.stringify(value); | ||
const isSkippedResult = void 0 === result; | ||
!isSkippedResult && resultList.push(result); | ||
return isSkippedResult; | ||
}; | ||
const stringifyObject = (resultList, object, level, padString) => { | ||
const keyList = Object.keys(object); | ||
resultList.push("{\n"); | ||
const nextLevel = level - 1; | ||
const nextPadString = `${padString}${pad}`; | ||
for (let index = 0, indexMax = keyList.length; index < indexMax; index++) { | ||
const key = keyList[index]; | ||
const value = object[key]; | ||
const startIndex = resultList.length; | ||
resultList.push(""); | ||
if (stringifySwitch(resultList, value, nextLevel, nextPadString)) resultList.length--; else { | ||
resultList[startIndex] = `${nextPadString}${JSON.stringify(key)}: `; | ||
resultList.push(",\n"); | ||
}); | ||
resultList[resultList.length - 1] = `\n${padString}]`; | ||
})(resultList, value, level, padString); | ||
if ("object" == typeof value) return ((resultList, object, level, padString) => { | ||
const entryList = Object.entries(object); | ||
if (0 === entryList.length) return resultList.push("{}"); | ||
resultList.push("{\n"); | ||
const nextLevel = level - 1; | ||
const nextPadString = `${padString} `; | ||
entryList.forEach(([key, value]) => { | ||
resultList.push(nextPadString, JSON.stringify(key), ": "); | ||
prettyStringifyJSONSwitch(resultList, value, nextLevel, nextPadString); | ||
resultList.push(",\n"); | ||
}); | ||
resultList[resultList.length - 1] = `\n${padString}}`; | ||
})(resultList, value, level, padString); | ||
} | ||
resultList.push(JSON.stringify(value)); | ||
}; | ||
const prettyStringifyJSON = (value, level = 2) => { | ||
} | ||
} | ||
resultList[resultList.length - 1] = 1 === resultList.length ? "{}" : `\n${padString}}`; | ||
}; | ||
const stringifyArray = (resultList, array, level, padString) => { | ||
resultList.push("[\n"); | ||
const nextLevel = level - 1; | ||
const nextPadString = `${padString}${pad}`; | ||
for (let index = 0, indexMax = array.length; index < indexMax; index++) { | ||
const value = array[index]; | ||
resultList.push(nextPadString); | ||
stringifySwitch(resultList, value, nextLevel, nextPadString) && resultList.push("null"); | ||
resultList.push(",\n"); | ||
} | ||
resultList[resultList.length - 1] = 1 === resultList.length ? "[]" : `\n${padString}]`; | ||
}; | ||
const resultList = []; | ||
prettyStringifyJSONSwitch(resultList, value, Math.max(level, 0) || 0, ""); | ||
stringifySwitch(resultList, value, Math.max(unfoldLevel, 0) || 0, ""); | ||
return resultList.join(""); | ||
}; | ||
export { describe, percent, mediaTime, decimal, time, binary, padTable, prettyStringifyJSON }; |
@@ -1,1 +0,1 @@ | ||
{"name":"dr-js","version":"0.22.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-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} |
Sorry, the diff of this file is too big to display
430129
9952