@kibalabs/core 0.6.3-next.0 → 0.6.3-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/util/objectUtil.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addMinutes as N}from"date-fns/addMinutes";import{isValid as L}from"date-fns/isValid";import{parse as V}from"date-fns/parse";import{parseISO as W}from"date-fns/parseISO";import{format as _}from"date-fns-tz";import a from"fs";import l from"path";import*as w from"deepmerge";import x from"fast-deep-equal";var d=class extends Error{statusCode;constructor(e,t){super(e),this.name=this.constructor.name,this.statusCode=t||500}};let c=function(e){return e.DELETE="delete",e.GET="get",e.HEAD="head",e.OPTIONS="options",e.PATCH="patch",e.POST="post",e.PUT="put",e}({});var u=class{method;url;headers;data;formData;date;timeoutSeconds;constructor(e,t,n,r,s,i,o){this.method=e,this.url=t,this.headers=n||{},this.data=r||null,this.formData=s||null,this.date=i||new Date,this.timeoutSeconds=o&&o>0?o:null}},y=class{status;headers={};date;content="";constructor(e,t,n,r){this.status=e,this.headers=t,this.date=n,this.content=r}};const b=(e,t)=>new Promise((n,r)=>{const s=setTimeout(()=>{r(new d("TIMEOUT"))},e*1e3);t.then(i=>{clearTimeout(s),n(i)},i=>{clearTimeout(s),r(i)})}),K=e=>{let t=e;for(t.startsWith("http://")&&(t=t.slice(7)),t.startsWith("https://")&&(t=t.slice(8));t.endsWith("/");)t=t.slice(0,t.length-1);return t},z=e=>{let t=e;return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`http://${t}`),t},J=e=>e.startsWith("ipfs://")?e.replace("ipfs://","https://pablo-images.kibalabs.com/v1/ipfs/"):e,R=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([n,r])=>{Array.isArray(r)?r.forEach(s=>{t.append(n,s)}):t.append(n,r)}),t},Z=(e,t)=>{const n=new URL(e);return Object.keys(t).forEach(r=>{n.searchParams.set(r,String(t[r]))}),n.toString()};var G=class{modifyRequest(e){return e}modifyResponse(e){return e}},X=class{headers;modifiers;shouldIncludeCrossSiteCredentials;constructor(e,t,n=!0){this.headers=e||{},this.modifiers=t||[],this.shouldIncludeCrossSiteCredentials=n}addModifier=e=>{this.modifiers.push(e)};modifyRequest=e=>this.modifiers.reduce((t,n)=>n.modifyRequest(t),e);modifyResponse=e=>this.modifiers.reduce((t,n)=>n.modifyResponse(t),e);getRequest=async(e,t,n,r)=>{const s=new u(c.GET,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};postRequest=async(e,t,n,r)=>{const s=new u(c.POST,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};putRequest=async(e,t,n,r)=>{const s=new u(c.PUT,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};deleteRequest=async(e,t,n,r)=>{const s=new u(c.DELETE,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};makeRequest=async(e,t,n,r,s)=>{const i=new u(e,t,r,n,void 0,new Date,s);return this.makeRequestInternal(i)};makeFormRequest=async(e,t,n,r)=>{const s=new u(c.POST,e,n,void 0,t,new Date,r);return this.makeRequestInternal(s)};makeFormPutRequest=async(e,t,n,r)=>{const s=new u(c.PUT,e,n,void 0,t,new Date,r);return this.makeRequestInternal(s)};makeRequestInternal=async e=>{const t=this.modifyRequest(e);let n=await this.makeFetchRequest(t);if(n=this.modifyResponse(n),n.status>=400&&n.status<600){let r=null;try{r=JSON.parse(n.content)}catch{}throw r&&"message"in r?new d(r.message,n.status):new d(n.content,n.status)}return n};makeFetchRequest=async e=>{const t=new URL(e.url),n=new Headers({...this.headers,...e.headers||{}}),r={method:e.method.toUpperCase(),headers:n,credentials:this.shouldIncludeCrossSiteCredentials?"include":"same-origin"};if(e.method===c.GET||e.method===c.DELETE){if(e.data){const o={...e.data};Object.keys(o).forEach(f=>{o[f]===void 0&&delete o[f]}),t.search=R(o).toString()}}else{const o=n.get("Content-Type");e.data?(r.body=JSON.stringify(e.data),o&&o!=="application/json"&&console.warn(`Overwriting content-type header for request from ${o} to application/json`),n.set("content-type","application/json")):e.formData&&(r.body=e.formData)}const s=fetch(t.toString(),r).catch(o=>{throw new d(`The request was made but no response was received: [${o.code}] "${o.message}"`)}).then(async o=>{if(!o)throw new d("The request was made but no response was received.");const f=await o.text(),h={};return o.headers.forEach((j,m)=>{h[m]&&console.warn(`key ${m} will be overwritten. TODO(krish): Implement joining keys!`),h[m]=j}),new y(o.status,h,new Date,f)});return await(e.timeoutSeconds?b(e.timeoutSeconds,s):s)}},Y=class{toObject=()=>({})},Q=class{},v=class{requester;baseUrl;constructor(e,t){this.requester=e,this.baseUrl=t}makeRequest=async(e,t,n,r)=>{const s=`${this.baseUrl}/${t}`,i=await this.requester.makeRequest(e,s,n?.toObject());return r?r.fromObject(JSON.parse(i.content)):null}},ee=class{localStorage;constructor(e){this.localStorage=e}getValue(e){return this.localStorage.getItem(e)}setValue(e,t){t==null?this.removeValue(e):this.localStorage.setItem(e,t)}getBoolean(e){const t=this.getValue(e);return t==="1"?!0:t==="0"?!1:null}setBoolean(e,t){t==null?this.removeValue(e):this.setValue(e,t?"1":"0")}removeValue(e){this.localStorage.removeItem(e)}clear(){this.localStorage.clear()}};const te=e=>new Promise(t=>{setTimeout(t,e)}),T=()=>typeof document<"u",ne=async(e,t)=>{const n=new Blob([t]),r=await URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s)},re=()=>{if(!T())return!1;let e;return document.hidden!==void 0?e="hidden":document.msHidden!==void 0?e="msHidden":document.webkitHidden!==void 0&&(e="webkitHidden"),e?!document[e]:!0},se=()=>typeof navigator>"u"?!1:[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i].some(t=>t.test(navigator.userAgent)),oe=e=>e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),D=e=>e>=1e9?`${(e/1e9).toFixed(0)}B`:e>=1e7?`${(e/1e6).toFixed(0)}M`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${(e/1e3).toFixed(0)}K`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e>100?e.toFixed(0):e>1?e.toFixed(1):e.toFixed(2),E=(e,t=2,n=!1,r=!1)=>{let s=e.toFixed(t);if(n){for(;s.charAt(s.length-1)===",";)s=s.slice(0,-1);s.endsWith(".0")&&(s=s.replace(".0",""))}if(r){const i=s.split("."),o=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");s=i.length===1?o:`${o}.${i[1]}`}return`${s.toLocaleString()}`},C=BigInt("1000000000000000000"),g=e=>Number(e*1000000n/C)/1e6,ie=e=>`\u039E${D(g(e))}`,ae=(e,t=2,n=!1,r=!1)=>`\u039E${E(g(e),t,n,r)}`,ce=(...e)=>{const t=[];e.forEach(r=>{r&&t.push(String(r).trim().split(" "))});let n=t.reduce((r,s)=>r.concat(s),[]);return n=n.reverse(),n=Array.from(new Set(n)),n=n.reverse(),n.join(" ")},A="yyyy-MM-dd'T'HH:mm:ss.SSSXXX",ue=(e,t)=>{let n;if(!t)n=W(e);else try{n=V(e,t,new Date)}catch{}if(!n||!L(n))throw new d(`Invalid date string ${e} passed to dateFromString`);return n},de=(e,t=A,n=!1)=>{let r=e;return n&&(r=N(r,r.getTimezoneOffset())),_(r,t,n?{timeZone:"UTC"}:{})},p=(e,t)=>e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear(),le=e=>p(e,new Date),fe=e=>{const t=new Date;return t.setDate(t.getDate()-1),p(e,t)},he=(e,t)=>{const n=new Date(e.getTime());return n.setTime(n.getTime()+t*60*60*1e3),n},me=(e,t)=>{const n=new Date(e.getTime());return n.setDate(n.getDate()+t),n},ge=e=>{const t=Math.floor((new Date().valueOf()-e.valueOf())/1e3);let n,r=Math.floor(t/31536e3);return r>=1?n="year":(r=Math.floor(t/2592e3),r>=1?n="month":(r=Math.floor(t/86400),r>=1?n="day":(r=Math.floor(t/3600),r>=1?n="hour":(r=Math.floor(t/60),r>=1?n="minute":(r=t,n="second"))))),(r>1||r===0)&&(n+="s"),`${r} ${n} ago`},pe=e=>{const t=Math.floor((new Date().valueOf()-e.valueOf())/1e3);let n,r=Math.floor(t/31536e3);return r>=1?n="y":(r=Math.floor(t/2592e3),r>=1?n="m":(r=Math.floor(t/86400),r>=1?n="d":(r=Math.floor(t/3600),r>=1?n="h":(r=Math.floor(t/60),r>=1?n="m":(r=t,n="s"))))),`${r}${n} ago`},Se=e=>{const t=new Date(e.getTime());return t.setHours(0,0,0,0),t},we=e=>{const t=new Date(e.getTime());return t.setHours(23,59,59,999),t},ye=(e,t=1)=>{if(e===0)return"0 B";const n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**r).toFixed(t<0?0:t))} ${n[r]}`},F=(e,t)=>{let n=t;a.existsSync(t)&&a.lstatSync(t).isDirectory()&&(n=l.join(t,l.basename(e)));const r=l.dirname(n);a.existsSync(r)||a.mkdirSync(r,{recursive:!0}),a.writeFileSync(n,a.readFileSync(e))},O=(e,t)=>{if(!a.lstatSync(e).isDirectory())throw new Error(`copyDirectorySync must be called with a directory. source ${e} is not a directory`);if(!a.existsSync(t))a.mkdirSync(t,{recursive:!0});else if(!a.lstatSync(e).isDirectory())throw new Error(`copyDirectorySync must be called with a directory. target ${t} is not a directory`);a.readdirSync(e).forEach(n=>{const r=l.join(e,n),s=l.join(t,n);a.lstatSync(r).isDirectory()?O(r,s):F(r,s)})},be=(e,t)=>Array(t-e).fill(null).map((n,r)=>e+r),Re=(e,t)=>e.reduce((n,r,s)=>{const i=Math.floor(s/t);return n[i]||(n[i]=[]),n[i].push(r),n},[]);function Te(e,...t){return w(e,M(...t))}function M(...e){let t={};return e.forEach(n=>{n&&(t=w(t,n))}),t}function De(e,t){return x(e,t)}const Ee=e=>{if(e!==void 0)return e===null?null:JSON.stringify(e)},Ce=e=>{if(e!==void 0)return e===null?null:JSON.parse(e)},Ae=e=>{if(e!==void 0)return e===null?null:e?"1":"0"},Fe=e=>{if(e!==void 0)return e===null?null:e==="1"||e==="true"},q=e=>{if(e!==void 0)return e===null?null:String(e)},$=e=>{if(e===void 0)return;if(e===null)return null;const t=Number(e);return Number.isNaN(t)?null:t},Oe=e=>e?String(Math.round(e)):q(e),Me=e=>{const t=$(e);return t&&Math.round(t)},qe=(e,t=",")=>{if(e!==void 0)return e===null?"":e.join(t)},$e=(e,t=",")=>{if(e!==void 0)return e===null?[]:e?e.split(t):[]},S="1234567890",I="abcdefghijklmnopqrstuvwxyz",P="ABCDEFGHIJKLMNOPQRSTUVWXYZ",k=`${I}${P}`,H=`${k}${S}`,U=`${S}abcdef`,B=(e,t=H)=>{let n="";for(let r=0;r<e;r+=1)n+=t[Math.floor(Math.random()*t.length)];return n},Ie=(e=!0)=>{let t=B(32,U);return e&&(t=[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20)].join("-")),t},Pe=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e),ke=e=>e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),He=(e,t)=>{if(e.length-t>0){const r=e.substring(0,Math.ceil(t/2)),s=e.substring(e.length-Math.floor(t/2),e.length);return`${r}...${s}`}return e},Ue=(e,t)=>e.length-t>0?`${e.substring(0,t)}...`:e,Be=(e,t)=>e.length-t>0?`${e.substring(0,t)}...`:e,je=e=>{const t=atob(e).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join("");return decodeURIComponent(t)};export{k as CHARACTERS_ALPHA,H as CHARACTERS_ALPHANUMERIC,I as CHARACTERS_ALPHA_LOWERCASE,P as CHARACTERS_ALPHA_UPPERCASE,U as CHARACTERS_HEX,S as CHARACTERS_NUMERIC,C as ETHER,A as JSON_DATE_FORMAT,d as KibaException,u as KibaRequest,y as KibaResponse,ee as LocalStorageClient,Y as RequestData,X as Requester,G as RequesterModifier,Q as ResponseData,c as RestMethod,v as ServiceClient,me as addDays,he as addHours,be as arrayWithRange,te as asyncSleep,je as base64DecodeUnicode,Fe as booleanFromString,Ae as booleanToString,ke as camelCaseToKebabCase,O as copyDirectorySync,F as copyFileSync,R as createSearchParams,ue as dateFromString,pe as dateToRelativeShortString,ge as dateToRelativeString,de as dateToString,De as deepCompare,ne as downloadFileFromBrowser,we as endOfDay,g as etherToNumber,B as generateRandomString,Ie as generateUUID,Re as getChunks,ce as getClassName,z as getLinkableUrl,K as getUrlDisplayString,ye as humanFileSize,Me as integerFromString,Oe as integerToString,T as isBrowser,re as isDocumentVisible,se as isMobile,p as isSameDay,le as isToday,Pe as isValidEmail,fe as isYesterday,ae as longFormatEther,E as longFormatNumber,Te as merge,M as mergePartial,$ as numberFromString,q as numberToString,oe as numberWithCommas,Ce as objectFromString,Ee as objectToString,J as resolveUrl,ie as shortFormatEther,D as shortFormatNumber,Se as startOfDay,$e as stringListFromString,qe as stringListToString,b as timeoutPromise,Be as truncateEnd,He as truncateMiddle,Ue as truncateStart,Z as updateQueryString};
|
|
1
|
+
import{addMinutes as N}from"date-fns/addMinutes";import{isValid as L}from"date-fns/isValid";import{parse as V}from"date-fns/parse";import{parseISO as W}from"date-fns/parseISO";import{format as _}from"date-fns-tz";import a from"fs";import l from"path";import w from"deepmerge";import x from"fast-deep-equal";var d=class extends Error{statusCode;constructor(e,t){super(e),this.name=this.constructor.name,this.statusCode=t||500}};let c=function(e){return e.DELETE="delete",e.GET="get",e.HEAD="head",e.OPTIONS="options",e.PATCH="patch",e.POST="post",e.PUT="put",e}({});var u=class{method;url;headers;data;formData;date;timeoutSeconds;constructor(e,t,n,r,s,i,o){this.method=e,this.url=t,this.headers=n||{},this.data=r||null,this.formData=s||null,this.date=i||new Date,this.timeoutSeconds=o&&o>0?o:null}},y=class{status;headers={};date;content="";constructor(e,t,n,r){this.status=e,this.headers=t,this.date=n,this.content=r}};const b=(e,t)=>new Promise((n,r)=>{const s=setTimeout(()=>{r(new d("TIMEOUT"))},e*1e3);t.then(i=>{clearTimeout(s),n(i)},i=>{clearTimeout(s),r(i)})}),K=e=>{let t=e;for(t.startsWith("http://")&&(t=t.slice(7)),t.startsWith("https://")&&(t=t.slice(8));t.endsWith("/");)t=t.slice(0,t.length-1);return t},z=e=>{let t=e;return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`http://${t}`),t},J=e=>e.startsWith("ipfs://")?e.replace("ipfs://","https://pablo-images.kibalabs.com/v1/ipfs/"):e,R=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([n,r])=>{Array.isArray(r)?r.forEach(s=>{t.append(n,s)}):t.append(n,r)}),t},Z=(e,t)=>{const n=new URL(e);return Object.keys(t).forEach(r=>{n.searchParams.set(r,String(t[r]))}),n.toString()};var G=class{modifyRequest(e){return e}modifyResponse(e){return e}},X=class{headers;modifiers;shouldIncludeCrossSiteCredentials;constructor(e,t,n=!0){this.headers=e||{},this.modifiers=t||[],this.shouldIncludeCrossSiteCredentials=n}addModifier=e=>{this.modifiers.push(e)};modifyRequest=e=>this.modifiers.reduce((t,n)=>n.modifyRequest(t),e);modifyResponse=e=>this.modifiers.reduce((t,n)=>n.modifyResponse(t),e);getRequest=async(e,t,n,r)=>{const s=new u(c.GET,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};postRequest=async(e,t,n,r)=>{const s=new u(c.POST,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};putRequest=async(e,t,n,r)=>{const s=new u(c.PUT,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};deleteRequest=async(e,t,n,r)=>{const s=new u(c.DELETE,e,n,t,void 0,new Date,r);return this.makeRequestInternal(s)};makeRequest=async(e,t,n,r,s)=>{const i=new u(e,t,r,n,void 0,new Date,s);return this.makeRequestInternal(i)};makeFormRequest=async(e,t,n,r)=>{const s=new u(c.POST,e,n,void 0,t,new Date,r);return this.makeRequestInternal(s)};makeFormPutRequest=async(e,t,n,r)=>{const s=new u(c.PUT,e,n,void 0,t,new Date,r);return this.makeRequestInternal(s)};makeRequestInternal=async e=>{const t=this.modifyRequest(e);let n=await this.makeFetchRequest(t);if(n=this.modifyResponse(n),n.status>=400&&n.status<600){let r=null;try{r=JSON.parse(n.content)}catch{}throw r&&"message"in r?new d(r.message,n.status):new d(n.content,n.status)}return n};makeFetchRequest=async e=>{const t=new URL(e.url),n=new Headers({...this.headers,...e.headers||{}}),r={method:e.method.toUpperCase(),headers:n,credentials:this.shouldIncludeCrossSiteCredentials?"include":"same-origin"};if(e.method===c.GET||e.method===c.DELETE){if(e.data){const o={...e.data};Object.keys(o).forEach(f=>{o[f]===void 0&&delete o[f]}),t.search=R(o).toString()}}else{const o=n.get("Content-Type");e.data?(r.body=JSON.stringify(e.data),o&&o!=="application/json"&&console.warn(`Overwriting content-type header for request from ${o} to application/json`),n.set("content-type","application/json")):e.formData&&(r.body=e.formData)}const s=fetch(t.toString(),r).catch(o=>{throw new d(`The request was made but no response was received: [${o.code}] "${o.message}"`)}).then(async o=>{if(!o)throw new d("The request was made but no response was received.");const f=await o.text(),h={};return o.headers.forEach((j,m)=>{h[m]&&console.warn(`key ${m} will be overwritten. TODO(krish): Implement joining keys!`),h[m]=j}),new y(o.status,h,new Date,f)});return await(e.timeoutSeconds?b(e.timeoutSeconds,s):s)}},Y=class{toObject=()=>({})},Q=class{},v=class{requester;baseUrl;constructor(e,t){this.requester=e,this.baseUrl=t}makeRequest=async(e,t,n,r)=>{const s=`${this.baseUrl}/${t}`,i=await this.requester.makeRequest(e,s,n?.toObject());return r?r.fromObject(JSON.parse(i.content)):null}},ee=class{localStorage;constructor(e){this.localStorage=e}getValue(e){return this.localStorage.getItem(e)}setValue(e,t){t==null?this.removeValue(e):this.localStorage.setItem(e,t)}getBoolean(e){const t=this.getValue(e);return t==="1"?!0:t==="0"?!1:null}setBoolean(e,t){t==null?this.removeValue(e):this.setValue(e,t?"1":"0")}removeValue(e){this.localStorage.removeItem(e)}clear(){this.localStorage.clear()}};const te=e=>new Promise(t=>{setTimeout(t,e)}),T=()=>typeof document<"u",ne=async(e,t)=>{const n=new Blob([t]),r=await URL.createObjectURL(n),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s)},re=()=>{if(!T())return!1;let e;return document.hidden!==void 0?e="hidden":document.msHidden!==void 0?e="msHidden":document.webkitHidden!==void 0&&(e="webkitHidden"),e?!document[e]:!0},se=()=>typeof navigator>"u"?!1:[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i].some(t=>t.test(navigator.userAgent)),oe=e=>e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","),D=e=>e>=1e9?`${(e/1e9).toFixed(0)}B`:e>=1e7?`${(e/1e6).toFixed(0)}M`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${(e/1e3).toFixed(0)}K`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e>100?e.toFixed(0):e>1?e.toFixed(1):e.toFixed(2),E=(e,t=2,n=!1,r=!1)=>{let s=e.toFixed(t);if(n){for(;s.charAt(s.length-1)===",";)s=s.slice(0,-1);s.endsWith(".0")&&(s=s.replace(".0",""))}if(r){const i=s.split("."),o=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");s=i.length===1?o:`${o}.${i[1]}`}return`${s.toLocaleString()}`},C=BigInt("1000000000000000000"),g=e=>Number(e*1000000n/C)/1e6,ie=e=>`\u039E${D(g(e))}`,ae=(e,t=2,n=!1,r=!1)=>`\u039E${E(g(e),t,n,r)}`,ce=(...e)=>{const t=[];e.forEach(r=>{r&&t.push(String(r).trim().split(" "))});let n=t.reduce((r,s)=>r.concat(s),[]);return n=n.reverse(),n=Array.from(new Set(n)),n=n.reverse(),n.join(" ")},A="yyyy-MM-dd'T'HH:mm:ss.SSSXXX",ue=(e,t)=>{let n;if(!t)n=W(e);else try{n=V(e,t,new Date)}catch{}if(!n||!L(n))throw new d(`Invalid date string ${e} passed to dateFromString`);return n},de=(e,t=A,n=!1)=>{let r=e;return n&&(r=N(r,r.getTimezoneOffset())),_(r,t,n?{timeZone:"UTC"}:{})},p=(e,t)=>e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear(),le=e=>p(e,new Date),fe=e=>{const t=new Date;return t.setDate(t.getDate()-1),p(e,t)},he=(e,t)=>{const n=new Date(e.getTime());return n.setTime(n.getTime()+t*60*60*1e3),n},me=(e,t)=>{const n=new Date(e.getTime());return n.setDate(n.getDate()+t),n},ge=e=>{const t=Math.floor((new Date().valueOf()-e.valueOf())/1e3);let n,r=Math.floor(t/31536e3);return r>=1?n="year":(r=Math.floor(t/2592e3),r>=1?n="month":(r=Math.floor(t/86400),r>=1?n="day":(r=Math.floor(t/3600),r>=1?n="hour":(r=Math.floor(t/60),r>=1?n="minute":(r=t,n="second"))))),(r>1||r===0)&&(n+="s"),`${r} ${n} ago`},pe=e=>{const t=Math.floor((new Date().valueOf()-e.valueOf())/1e3);let n,r=Math.floor(t/31536e3);return r>=1?n="y":(r=Math.floor(t/2592e3),r>=1?n="m":(r=Math.floor(t/86400),r>=1?n="d":(r=Math.floor(t/3600),r>=1?n="h":(r=Math.floor(t/60),r>=1?n="m":(r=t,n="s"))))),`${r}${n} ago`},Se=e=>{const t=new Date(e.getTime());return t.setHours(0,0,0,0),t},we=e=>{const t=new Date(e.getTime());return t.setHours(23,59,59,999),t},ye=(e,t=1)=>{if(e===0)return"0 B";const n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**r).toFixed(t<0?0:t))} ${n[r]}`},F=(e,t)=>{let n=t;a.existsSync(t)&&a.lstatSync(t).isDirectory()&&(n=l.join(t,l.basename(e)));const r=l.dirname(n);a.existsSync(r)||a.mkdirSync(r,{recursive:!0}),a.writeFileSync(n,a.readFileSync(e))},O=(e,t)=>{if(!a.lstatSync(e).isDirectory())throw new Error(`copyDirectorySync must be called with a directory. source ${e} is not a directory`);if(!a.existsSync(t))a.mkdirSync(t,{recursive:!0});else if(!a.lstatSync(e).isDirectory())throw new Error(`copyDirectorySync must be called with a directory. target ${t} is not a directory`);a.readdirSync(e).forEach(n=>{const r=l.join(e,n),s=l.join(t,n);a.lstatSync(r).isDirectory()?O(r,s):F(r,s)})},be=(e,t)=>Array(t-e).fill(null).map((n,r)=>e+r),Re=(e,t)=>e.reduce((n,r,s)=>{const i=Math.floor(s/t);return n[i]||(n[i]=[]),n[i].push(r),n},[]);function Te(e,...t){return w(e,M(...t))}function M(...e){let t={};return e.forEach(n=>{n&&(t=w(t,n))}),t}function De(e,t){return x(e,t)}const Ee=e=>{if(e!==void 0)return e===null?null:JSON.stringify(e)},Ce=e=>{if(e!==void 0)return e===null?null:JSON.parse(e)},Ae=e=>{if(e!==void 0)return e===null?null:e?"1":"0"},Fe=e=>{if(e!==void 0)return e===null?null:e==="1"||e==="true"},q=e=>{if(e!==void 0)return e===null?null:String(e)},$=e=>{if(e===void 0)return;if(e===null)return null;const t=Number(e);return Number.isNaN(t)?null:t},Oe=e=>e?String(Math.round(e)):q(e),Me=e=>{const t=$(e);return t&&Math.round(t)},qe=(e,t=",")=>{if(e!==void 0)return e===null?"":e.join(t)},$e=(e,t=",")=>{if(e!==void 0)return e===null?[]:e?e.split(t):[]},S="1234567890",I="abcdefghijklmnopqrstuvwxyz",P="ABCDEFGHIJKLMNOPQRSTUVWXYZ",k=`${I}${P}`,H=`${k}${S}`,U=`${S}abcdef`,B=(e,t=H)=>{let n="";for(let r=0;r<e;r+=1)n+=t[Math.floor(Math.random()*t.length)];return n},Ie=(e=!0)=>{let t=B(32,U);return e&&(t=[t.substring(0,8),t.substring(8,12),t.substring(12,16),t.substring(16,20),t.substring(20)].join("-")),t},Pe=e=>/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e),ke=e=>e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase(),He=(e,t)=>{if(e.length-t>0){const r=e.substring(0,Math.ceil(t/2)),s=e.substring(e.length-Math.floor(t/2),e.length);return`${r}...${s}`}return e},Ue=(e,t)=>e.length-t>0?`${e.substring(0,t)}...`:e,Be=(e,t)=>e.length-t>0?`${e.substring(0,t)}...`:e,je=e=>{const t=atob(e).split("").map(n=>`%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`).join("");return decodeURIComponent(t)};export{k as CHARACTERS_ALPHA,H as CHARACTERS_ALPHANUMERIC,I as CHARACTERS_ALPHA_LOWERCASE,P as CHARACTERS_ALPHA_UPPERCASE,U as CHARACTERS_HEX,S as CHARACTERS_NUMERIC,C as ETHER,A as JSON_DATE_FORMAT,d as KibaException,u as KibaRequest,y as KibaResponse,ee as LocalStorageClient,Y as RequestData,X as Requester,G as RequesterModifier,Q as ResponseData,c as RestMethod,v as ServiceClient,me as addDays,he as addHours,be as arrayWithRange,te as asyncSleep,je as base64DecodeUnicode,Fe as booleanFromString,Ae as booleanToString,ke as camelCaseToKebabCase,O as copyDirectorySync,F as copyFileSync,R as createSearchParams,ue as dateFromString,pe as dateToRelativeShortString,ge as dateToRelativeString,de as dateToString,De as deepCompare,ne as downloadFileFromBrowser,we as endOfDay,g as etherToNumber,B as generateRandomString,Ie as generateUUID,Re as getChunks,ce as getClassName,z as getLinkableUrl,K as getUrlDisplayString,ye as humanFileSize,Me as integerFromString,Oe as integerToString,T as isBrowser,re as isDocumentVisible,se as isMobile,p as isSameDay,le as isToday,Pe as isValidEmail,fe as isYesterday,ae as longFormatEther,E as longFormatNumber,Te as merge,M as mergePartial,$ as numberFromString,q as numberToString,oe as numberWithCommas,Ce as objectFromString,Ee as objectToString,J as resolveUrl,ie as shortFormatEther,D as shortFormatNumber,Se as startOfDay,$e as stringListFromString,qe as stringListToString,b as timeoutPromise,Be as truncateEnd,He as truncateMiddle,Ue as truncateStart,Z as updateQueryString};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectUtil.d.ts","sourceRoot":"","sources":["../../src/util/objectUtil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"objectUtil.d.ts","sourceRoot":"","sources":["../../src/util/objectUtil.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,CAAC,CAGrF;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAUrG;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAE9D"}
|