@tikkhun/utils-core
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var e="_",t="__",i="."; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var o="_",n="__",r=".";var e="user",t="admin",s=[e,t]; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function s(n,e){return Object.values(e).includes(n)} |
@@ -15,3 +15,3 @@ export { ROLES } from './consts/index.js'; | ||
export { formatSizeUnits } from './size.js'; | ||
export { capitalize, toBigCamelCase, toCamelCase, toConstCase } from './text.js'; | ||
export { capitalize, replaceParams, toBigCamelCase, toCamelCase, toConstCase } from './text.js'; | ||
export { sleep } from './time.js'; | ||
@@ -18,0 +18,0 @@ export { TreeNode, buildTree, findNodeByIdBFS, findNodeByIdDFS } from './tree.js'; |
@@ -11,44 +11,45 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
var T=Object.defineProperty,h=Object.defineProperties;var J=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var d=(t,r,e)=>r in t?T(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,a=(t,r)=>{for(var e in r||(r={}))b.call(r,e)&&d(t,e,r[e]);if(l)for(var e of l(r))j.call(r,e)&&d(t,e,r[e]);return t},f=(t,r)=>h(t,J(r));var g=(t,r,e)=>new Promise((n,o)=>{var i=c=>{try{p(e.next(c));}catch(u){o(u);}},s=c=>{try{p(e.throw(c));}catch(u){o(u);}},p=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,s);p((e=e.apply(t,r)).next());});var v="_",G="__",q=".";var I="user",N="admin",V=[I,N];function Q(t,r){return Object.values(r).includes(t)}var m={delimiter:".",data:{},prefix:""};function x(t){let{data:r,delimiter:e,prefix:n}=Object.assign({},m,t);return Object.entries(r).reduce((o={},[i,s])=>{let p=n?`${n}${e}${i}`:i;return typeof s=="object"&&s!==null?a(a({},o),x({prefix:p,data:s,delimiter:e})):f(a({},o),{[p]:s})},{})}x.prototype.defaultFlatJsonOptions=m;var S={delimiter:".",json:{}};function L(t){let{delimiter:r,json:e,prefix:n}=Object.assign({},S,t);return Object.keys(e).reduce((o,i)=>{let s=n?`${n}${r}${i}`:i;if(typeof e[i]=="object"&&e[i]!==null){let p=L(f(a({},t),{json:e[i],prefix:s}));if(p&&p.length)return o.concat(p)}else return o.concat({key:s,value:e[i]});return o},[])}var {set:P}=B__default.default,_={delimiter:".",list:[],isKeyInclude:()=>!0,keyItemTransformer:function(t){return t}};function nt(t){let{delimiter:r,keyItemTransformer:e,list:n,isKeyInclude:o}=Object.assign({},_,t),i={};return n.forEach(({key:s,value:p})=>{if(!o(s))return;let c=s.split(r).map(e);P(i,c.join("."),p);}),i}var {set:w}=B__default.default,E={delimiter:".",data:{}};function st(t={}){let{data:r,delimiter:e}=Object.assign({},E,t),n={};return Object.entries(r).forEach(([o,i])=>{w(n,o.split(e).join("."),i);}),n}var C={magicString:"tikkhun-json-bigint"},O=class{constructor(r){this.options=Object.assign({},C,r);}reviver(r,e){if(typeof e=="string"&&e.includes(this.options.magicString)){let n=e.replace(new RegExp(this.options.magicString,"g"),"");return BigInt(n)}return e}parse(r){return JSON.parse(r,this.reviver.bind(this))}replacer(r,e){return U(e)?`${this.options.magicString}${e}${this.options.magicString}`:e}stringify(r){return JSON.stringify(r,this.replacer.bind(this))}};function U(t){return typeof t=="bigint"}function mt(t){return Array.isArray(t)?t:[t]}var{get:F}=B__default.default;function yt(t,r=""){return r?F(t,r):t}function Tt(t){return JSON.parse(JSON.stringify(t))}function ht(t){for(let r in t)if(t.hasOwnProperty(r))return !1;return !0}function Jt(t){return t?t.constructor===Object:!1}function bt(t){return JSON.parse(JSON.stringify(t))}function jt(t){return Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{})}var D={limit:0,offset:0};function Nt(t){let{limit:r,offset:e}=Object.assign({},D,t),n=r>0?r:0,o=e>=0?Math.floor(e/n)+1:0;return {pageSize:n,pageNo:o}}function Lt(){return (Math.random()*16777216<<0).toString(16)}function Bt(t,r){return Math.round(Math.random()*r+t)}function _t(t,r){return r==="error"?A(t):M(t)}function A(t){return {status:"success",code:void 0,error:"",data:t}}function M(t){return {status:"error",code:void 0,error:t.message,data:null}}var y=["B","KB","MB","GB","TB","PB"];function wt(t){let r=0;for(;t>=1024&&r<y.length-1;)t/=1024,r++;return `${t.toFixed(2)} ${y[r]}`}function Ct(t=""){if(typeof t!="string")throw new Error("str is not string");let[r,...e]=t;return r?r.toUpperCase()+e.join(""):""}function Ut(t=""){return t.replace(/[-\s]/g,"_").replace(/[A-Z]/g,r=>`_${r}`).toUpperCase()}function $t(t){return t=t.replace(/[-_](\w)/g,(r,e)=>e.toUpperCase()),t.replace(/^\w/,r=>r.toUpperCase())}function Ft(t){return t=t.replace(/[-_](\w)/g,(r,e)=>e.toUpperCase()),t.charAt(0).toLowerCase()+t.slice(1)}function At(t){return g(this,null,function*(){return yield new Promise(r=>{setTimeout(r,t);})})}function kt(t){let r=[],e={};return t.forEach(n=>{e[n.id]=f(a({},n),{children:[]});}),t.forEach(n=>{if(!n.parentId)return;let o=e[n.parentId];o?(o.children||(o.children=[]),o.children.push(e[n.id])):r.push(e[n.id]);}),r}function K(t,r){if(t.id===r)return t;if(t.children)for(let e of t.children){let n=K(e,r);if(n)return n}return null}function vt(t,r){let e=[t];for(;e.length>0;){let n=e.shift();if(n.id===r)return n;n.children&&e.push(...n.children);}return null}function zt(t){return t.match(/^(\d)\./)} | ||
var T=Object.defineProperty,b=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var d=(t,r,e)=>r in t?T(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,a=(t,r)=>{for(var e in r||(r={}))J.call(r,e)&&d(t,e,r[e]);if(l)for(var e of l(r))I.call(r,e)&&d(t,e,r[e]);return t},u=(t,r)=>b(t,N(r));var g=(t,r,e)=>new Promise((n,o)=>{var i=c=>{try{p(e.next(c));}catch(f){o(f);}},s=c=>{try{p(e.throw(c));}catch(f){o(f);}},p=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,s);p((e=e.apply(t,r)).next());});var z="_",Z="__",G=".";var j="user",L="admin",V=[j,L];function W(t,r){return Object.values(r).includes(t)}var m={delimiter:".",data:{},prefix:""};function x(t){let{data:r,delimiter:e,prefix:n}=Object.assign({},m,t);return Object.entries(r).reduce((o={},[i,s])=>{let p=n?`${n}${e}${i}`:i;return typeof s=="object"&&s!==null?a(a({},o),x({prefix:p,data:s,delimiter:e})):u(a({},o),{[p]:s})},{})}x.prototype.defaultFlatJsonOptions=m;var S={delimiter:".",json:{}};function P(t){let{delimiter:r,json:e,prefix:n}=Object.assign({},S,t);return Object.keys(e).reduce((o,i)=>{let s=n?`${n}${r}${i}`:i;if(typeof e[i]=="object"&&e[i]!==null){let p=P(u(a({},t),{json:e[i],prefix:s}));if(p&&p.length)return o.concat(p)}else return o.concat({key:s,value:e[i]});return o},[])}var {set:_}=B__default.default,R={delimiter:".",list:[],isKeyInclude:()=>!0,keyItemTransformer:function(t){return t}};function ot(t){let{delimiter:r,keyItemTransformer:e,list:n,isKeyInclude:o}=Object.assign({},R,t),i={};return n.forEach(({key:s,value:p})=>{if(!o(s))return;let c=s.split(r).map(e);_(i,c.join("."),p);}),i}var {set:w}=B__default.default,E={delimiter:".",data:{}};function pt(t={}){let{data:r,delimiter:e}=Object.assign({},E,t),n={};return Object.entries(r).forEach(([o,i])=>{w(n,o.split(e).join("."),i);}),n}var C={magicString:"tikkhun-json-bigint"},O=class{constructor(r){this.options=Object.assign({},C,r);}reviver(r,e){if(typeof e=="string"&&e.includes(this.options.magicString)){let n=e.replace(new RegExp(this.options.magicString,"g"),"");return BigInt(n)}return e}parse(r){return JSON.parse(r,this.reviver.bind(this))}replacer(r,e){return U(e)?`${this.options.magicString}${e}${this.options.magicString}`:e}stringify(r){return JSON.stringify(r,this.replacer.bind(this))}};function U(t){return typeof t=="bigint"}function xt(t){return Array.isArray(t)?t:[t]}var{get:M}=B__default.default;function ht(t,r=""){return r?M(t,r):t}function Tt(t){return JSON.parse(JSON.stringify(t))}function bt(t){for(let r in t)if(t.hasOwnProperty(r))return !1;return !0}function Nt(t){return t?t.constructor===Object:!1}function Jt(t){return JSON.parse(JSON.stringify(t))}function It(t){return Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{})}var F={limit:0,offset:0};function Lt(t){let{limit:r,offset:e}=Object.assign({},F,t),n=r>0?r:0,o=e>=0?Math.floor(e/n)+1:0;return {pageSize:n,pageNo:o}}function Pt(){return (Math.random()*16777216<<0).toString(16)}function Bt(t,r){return Math.round(Math.random()*r+t)}function Rt(t,r){return r==="error"?D(t):K(t)}function D(t){return {status:"success",code:void 0,error:"",data:t}}function K(t){return {status:"error",code:void 0,error:t.message,data:null}}var y=["B","KB","MB","GB","TB","PB"];function wt(t){let r=0;for(;t>=1024&&r<y.length-1;)t/=1024,r++;return `${t.toFixed(2)} ${y[r]}`}function h(t){return typeof t=="undefined"||t===null}function Dt(t=""){if(typeof t!="string")throw new Error("str is not string");let[r,...e]=t;return r?r.toUpperCase()+e.join(""):""}function Kt(t=""){return t.replace(/[-\s]/g,"_").replace(/[A-Z]/g,r=>`_${r}`).toUpperCase()}function kt(t){return t=t.replace(/[-_](\w)/g,(r,e)=>e.toUpperCase()),t.replace(/^\w/,r=>r.toUpperCase())}function vt(t){return t=t.replace(/[-_](\w)/g,(r,e)=>e.toUpperCase()),t.charAt(0).toLowerCase()+t.slice(1)}function zt(t,r,e={keepMatch:!1}){return t.replace(/\{([^}]+)\}/g,(n,o)=>r.hasOwnProperty(o)&&!h(r[o])?r[o]:e.keepMatch?n:"")}function Gt(t){return g(this,null,function*(){return yield new Promise(r=>{setTimeout(r,t);})})}function Ht(t){let r=[],e={};return t.forEach(n=>{e[n.id]=u(a({},n),{children:[]});}),t.forEach(n=>{if(!n.parentId)return;let o=e[n.parentId];o?(o.children||(o.children=[]),o.children.push(e[n.id])):r.push(e[n.id]);}),r}function k(t,r){if(t.id===r)return t;if(t.children)for(let e of t.children){let n=k(e,r);if(n)return n}return null}function Qt(t,r){let e=[t];for(;e.length>0;){let n=e.shift();if(n.id===r)return n;n.children&&e.push(...n.children);}return null}function Yt(t){return t.match(/^(\d)\./)} | ||
exports.DEFAULT_JSON_BIGINT_OPTIONS = C; | ||
exports.DotDelimiter = q; | ||
exports.DoubleUnderlineDelimiter = G; | ||
exports.DotDelimiter = G; | ||
exports.DoubleUnderlineDelimiter = Z; | ||
exports.JsonBigInt = O; | ||
exports.ROLES = V; | ||
exports.UnderlineDelimiter = v; | ||
exports.buildTree = kt; | ||
exports.capitalize = Ct; | ||
exports.clone = bt; | ||
exports.color16 = Lt; | ||
exports.UnderlineDelimiter = z; | ||
exports.buildTree = Ht; | ||
exports.capitalize = Dt; | ||
exports.clone = Jt; | ||
exports.color16 = Pt; | ||
exports.defaultFlatJsonOptions = m; | ||
exports.defaultJsonToListOptions = S; | ||
exports.defaultListToJsonOptions = _; | ||
exports.defaultListToJsonOptions = R; | ||
exports.defaultunflatJsonOptions = E; | ||
exports.findNodeByIdBFS = vt; | ||
exports.findNodeByIdDFS = K; | ||
exports.findNodeByIdBFS = Qt; | ||
exports.findNodeByIdDFS = k; | ||
exports.flatJson = x; | ||
exports.formatSizeUnits = wt; | ||
exports.getByPath = yt; | ||
exports.getError = M; | ||
exports.getMajorVersion = zt; | ||
exports.getByPath = ht; | ||
exports.getError = K; | ||
exports.getMajorVersion = Yt; | ||
exports.getRandomNumber = Bt; | ||
exports.getResult = _t; | ||
exports.getSuccess = A; | ||
exports.getResult = Rt; | ||
exports.getSuccess = D; | ||
exports.isBigInt = U; | ||
exports.isEmptyObj = ht; | ||
exports.isPlainObject = Jt; | ||
exports.isStringInEnum = Q; | ||
exports.jsonToList = L; | ||
exports.isEmptyObj = bt; | ||
exports.isPlainObject = Nt; | ||
exports.isStringInEnum = W; | ||
exports.jsonToList = P; | ||
exports.killUndefined = Tt; | ||
exports.limitOffsetToPage = Nt; | ||
exports.listToJson = nt; | ||
exports.sleep = At; | ||
exports.sortKey = jt; | ||
exports.toBeList = mt; | ||
exports.toBigCamelCase = $t; | ||
exports.toCamelCase = Ft; | ||
exports.toConstCase = Ut; | ||
exports.unflatJson = st; | ||
exports.limitOffsetToPage = Lt; | ||
exports.listToJson = ot; | ||
exports.replaceParams = zt; | ||
exports.sleep = Gt; | ||
exports.sortKey = It; | ||
exports.toBeList = xt; | ||
exports.toBigCamelCase = kt; | ||
exports.toCamelCase = vt; | ||
exports.toConstCase = Kt; | ||
exports.unflatJson = pt; |
@@ -5,3 +5,4 @@ declare function isInt(n: any): boolean; | ||
declare function isNativeNumber(n: any): boolean; | ||
declare function isNil(v: any): boolean; | ||
export { isBiggerThanMinusOne, isInt, isNativeNumber, isPositiveInt }; | ||
export { isBiggerThanMinusOne, isInt, isNativeNumber, isNil, isPositiveInt }; |
@@ -5,9 +5,10 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
var n=/^[0-9]*$/;function e(t){return Number.isInteger(t)}function i(t){return e(t)&&t>0}function s(t){return t>-1}function u(t){return n.test(t)} | ||
var t=/^[0-9]*$/;function e(n){return Number.isInteger(n)}function i(n){return e(n)&&n>0}function u(n){return n>-1}function s(n){return t.test(n)}function a(n){return typeof n=="undefined"||n===null} | ||
exports.isBiggerThanMinusOne = s; | ||
exports.isBiggerThanMinusOne = u; | ||
exports.isInt = e; | ||
exports.isNativeNumber = u; | ||
exports.isNativeNumber = s; | ||
exports.isNil = a; | ||
exports.isPositiveInt = i; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var O=Object.defineProperty,J=Object.defineProperties;var g=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var u=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var f=(n,t,e)=>t in n?O(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,i=(n,t)=>{for(var e in t||(t={}))u.call(t,e)&&f(n,e,t[e]);if(d)for(var e of d(t))F.call(t,e)&&f(n,e,t[e]);return n},l=(n,t)=>J(n,g(t));var c={delimiter:".",data:{},prefix:""};function x(n){let{data:t,delimiter:e,prefix:o}=Object.assign({},c,n);return Object.entries(t).reduce((s={},[a,r])=>{let p=o?`${o}${e}${a}`:a;return typeof r=="object"&&r!==null?i(i({},s),x({prefix:p,data:r,delimiter:e})):l(i({},s),{[p]:r})},{})}x.prototype.defaultFlatJsonOptions=c; |
@@ -11,3 +11,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -14,0 +14,0 @@ var x=Object.defineProperty,O=Object.defineProperties;var g=Object.getOwnPropertyDescriptors;var l=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var c=(n,o,t)=>o in n?x(n,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[o]=t,p=(n,o)=>{for(var t in o||(o={}))J.call(o,t)&&c(n,t,o[t]);if(l)for(var t of l(o))j.call(o,t)&&c(n,t,o[t]);return n},f=(n,o)=>O(n,g(o));var m={delimiter:".",data:{},prefix:""};function d(n){let{data:o,delimiter:t,prefix:s}=Object.assign({},m,n);return Object.entries(o).reduce((r={},[e,i])=>{let a=s?`${s}${t}${e}`:e;return typeof i=="object"&&i!==null?p(p({},r),d({prefix:a,data:i,delimiter:t})):f(p({},r),{[a]:i})},{})}d.prototype.defaultFlatJsonOptions=m;var L={delimiter:".",json:{}};function T(n){let{delimiter:o,json:t,prefix:s}=Object.assign({},L,n);return Object.keys(t).reduce((r,e)=>{let i=s?`${s}${o}${e}`:e;if(typeof t[e]=="object"&&t[e]!==null){let a=T(f(p({},n),{json:t[e],prefix:i}));if(a&&a.length)return r.concat(a)}else return r.concat({key:i,value:t[e]});return r},[])}var {set:b}=y__default.default,I={delimiter:".",list:[],isKeyInclude:()=>!0,keyItemTransformer:function(n){return n}};function q(n){let{delimiter:o,keyItemTransformer:t,list:s,isKeyInclude:r}=Object.assign({},I,n),e={};return s.forEach(({key:i,value:a})=>{if(!r(i))return;let u=i.split(o).map(t);b(e,u.join("."),a);}),e}var {set:$}=y__default.default,F={delimiter:".",data:{}};function A(n={}){let{data:o,delimiter:t}=Object.assign({},F,n),s={};return Object.entries(o).forEach(([r,e])=>{$(s,r.split(t).join("."),e);}),s} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var L=Object.defineProperty,j=Object.defineProperties;var m=Object.getOwnPropertyDescriptors;var c=Object.getOwnPropertySymbols;var a=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var f=(n,s,t)=>s in n?L(n,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[s]=t,l=(n,s)=>{for(var t in s||(s={}))a.call(s,t)&&f(n,t,s[t]);if(c)for(var t of c(s))O.call(s,t)&&f(n,t,s[t]);return n},u=(n,s)=>j(n,m(s));var d={delimiter:".",json:{}};function g(n){let{delimiter:s,json:t,prefix:r}=Object.assign({},d,n);return Object.keys(t).reduce((i,o)=>{let p=r?`${r}${s}${o}`:o;if(typeof t[o]=="object"&&t[o]!==null){let e=g(u(l({},n),{json:t[o],prefix:p}));if(e&&e.length)return i.concat(e)}else return i.concat({key:p,value:t[o]});return i},[])} |
@@ -11,3 +11,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -14,0 +14,0 @@ var {set:a}=l__default.default,f={delimiter:".",list:[],isKeyInclude:()=>!0,keyItemTransformer:function(t){return t}};function u(t){let{delimiter:n,keyItemTransformer:e,list:o,isKeyInclude:r}=Object.assign({},f,t),s={};return o.forEach(({key:i,value:m})=>{if(!r(i))return;let c=i.split(n).map(e);a(s,c.join("."),m);}),s} |
@@ -11,3 +11,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -14,0 +14,0 @@ var {set:r}=e__default.default,l={delimiter:".",data:{}};function f(n={}){let{data:o,delimiter:s}=Object.assign({},l,n),t={};return Object.entries(o).forEach(([i,a])=>{r(t,i.split(s).join("."),a);}),t} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var e={magicString:"tikkhun-json-bigint"},r=class{constructor(t){this.options=Object.assign({},e,t);}reviver(t,i){if(typeof i=="string"&&i.includes(this.options.magicString)){let s=i.replace(new RegExp(this.options.magicString,"g"),"");return BigInt(s)}return i}parse(t){return JSON.parse(t,this.reviver.bind(this))}replacer(t,i){return o(i)?`${this.options.magicString}${i}${this.options.magicString}`:i}stringify(t){return JSON.stringify(t,this.replacer.bind(this))}};function o(n){return typeof n=="bigint"} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function n(r){return Array.isArray(r)?r:[r]} |
@@ -11,3 +11,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -14,0 +14,0 @@ var{get:o}=i__default.default;function u(r,t=""){return t?o(r,t):r}function c(r){return JSON.parse(JSON.stringify(r))}function f(r){for(let t in r)if(r.hasOwnProperty(t))return !1;return !0}function y(r){return r?r.constructor===Object:!1}function a(r){return JSON.parse(JSON.stringify(r))}function O(r){return Object.keys(r).sort().reduce((n,e)=>(n[e]=r[e],n),{})} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var s={limit:0,offset:0};function n(o){let{limit:t,offset:e}=Object.assign({},s,o),i=t>0?t:0,f=e>=0?Math.floor(e/i)+1:0;return {pageSize:i,pageNo:f}} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function r(){var n,o;return ((o=(n=window.navigator)==null?void 0:n.userAgentData)==null?void 0:o.platform)==="Windows"||(navigator==null?void 0:navigator.platform)==="Win32"}function t(){throw new Error("impl not ready")} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function t(){return (Math.random()*16777216<<0).toString(16)}function o(r,n){return Math.round(Math.random()*n+r)} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var o=/^(?:(?:\+|00)86)?1\d{10}$/,t=/^[0-9]*$/,e=/^[a-zA-Z0-9]*$/,n=/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function t(r,e){return e==="error"?n(r):s(r)}function n(r){return {status:"success",code:void 0,error:"",data:r}}function s(r){return {status:"error",code:void 0,error:r.message,data:null}} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var e=["B","KB","MB","GB","TB","PB"];function B(t){let n=0;for(;t>=1024&&n<e.length-1;)t/=1024,n++;return `${t.toFixed(2)} ${e[n]}`} |
@@ -56,3 +56,14 @@ /** | ||
declare function toCamelCase(str: string): string; | ||
/** | ||
* 替代params | ||
* @param str | ||
* @param variables | ||
* @returns | ||
* @example | ||
* replaceParams("{app}",{app: "hahah"}) => "hahah" | ||
*/ | ||
declare function replaceParams(str: string, variables: Record<string, any>, options?: { | ||
keepMatch: boolean; | ||
}): string; | ||
export { capitalize, toBigCamelCase, toCamelCase, toConstCase }; | ||
export { capitalize, replaceParams, toBigCamelCase, toCamelCase, toConstCase }; |
@@ -5,9 +5,10 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
function o(e=""){if(typeof e!="string")throw new Error("str is not string");let[r,...t]=e;return r?r.toUpperCase()+t.join(""):""}function n(e=""){return e.replace(/[-\s]/g,"_").replace(/[A-Z]/g,r=>`_${r}`).toUpperCase()}function p(e){return e=e.replace(/[-_](\w)/g,(r,t)=>t.toUpperCase()),e.replace(/^\w/,r=>r.toUpperCase())}function a(e){return e=e.replace(/[-_](\w)/g,(r,t)=>t.toUpperCase()),e.charAt(0).toLowerCase()+e.slice(1)} | ||
function o(e){return typeof e=="undefined"||e===null}function g(e=""){if(typeof e!="string")throw new Error("str is not string");let[t,...r]=e;return t?t.toUpperCase()+r.join(""):""}function f(e=""){return e.replace(/[-\s]/g,"_").replace(/[A-Z]/g,t=>`_${t}`).toUpperCase()}function l(e){return e=e.replace(/[-_](\w)/g,(t,r)=>r.toUpperCase()),e.replace(/^\w/,t=>t.toUpperCase())}function x(e){return e=e.replace(/[-_](\w)/g,(t,r)=>r.toUpperCase()),e.charAt(0).toLowerCase()+e.slice(1)}function m(e,t,r={keepMatch:!1}){return e.replace(/\{([^}]+)\}/g,(i,n)=>t.hasOwnProperty(n)&&!o(t[n])?t[n]:r.keepMatch?i:"")} | ||
exports.capitalize = o; | ||
exports.toBigCamelCase = p; | ||
exports.toCamelCase = a; | ||
exports.toConstCase = n; | ||
exports.capitalize = g; | ||
exports.replaceParams = m; | ||
exports.toBigCamelCase = l; | ||
exports.toCamelCase = x; | ||
exports.toConstCase = f; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var u=(t,r,n)=>new Promise((a,s)=>{var m=e=>{try{i(n.next(e));}catch(o){s(o);}},c=e=>{try{i(n.throw(e));}catch(o){s(o);}},i=e=>e.done?a(e.value):Promise.resolve(e.value).then(m,c);i((n=n.apply(t,r)).next());});function w(t){return u(this,null,function*(){return yield new Promise(r=>{setTimeout(r,t);})})} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ var u=Object.defineProperty,s=Object.defineProperties;var f=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;var o=(n,r,e)=>r in n?u(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,l=(n,r)=>{for(var e in r||(r={}))h.call(r,e)&&o(n,e,r[e]);if(d)for(var e of d(r))p.call(r,e)&&o(n,e,r[e]);return n},c=(n,r)=>s(n,f(r));function a(n){let r=[],e={};return n.forEach(i=>{e[i.id]=c(l({},i),{children:[]});}),n.forEach(i=>{if(!i.parentId)return;let t=e[i.parentId];t?(t.children||(t.children=[]),t.children.push(e[i.id])):r.push(e[i.id]);}),r}function N(n,r){if(n.id===r)return n;if(n.children)for(let e of n.children){let i=N(e,r);if(i)return i}return null}function g(n,r){let e=[n];for(;e.length>0;){let i=e.shift();if(i.id===r)return i;i.children&&e.push(...i.children);}return null} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function t(n){return typeof n=="number"}function e(n){return typeof n=="bigint"} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function t(r){return r.match(/^(\d)\./)} |
@@ -5,3 +5,3 @@ 'use strict'; | ||
@tikkhun/utils-core | ||
0.0.6 | ||
0.0.7 | ||
*/ | ||
@@ -8,0 +8,0 @@ function e(n,t=""){return a=>n(a)||t} |
{ | ||
"name": "@tikkhun/utils-core", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "", | ||
@@ -37,3 +37,3 @@ "main": "dist/index.js", | ||
"esbuild-plugin-lodash": "^1.2.0", | ||
"ts-node": "^10.9.1", | ||
"tsx": "^4.19.1", | ||
"tsup": "^8.3.0", | ||
@@ -44,5 +44,5 @@ "vitest": "^2.1.1" | ||
"build": "tsup", | ||
"dev": "ts-node ./src/index.ts", | ||
"dev": "tsx ./src/index.ts", | ||
"test": "vitest" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
53821
792