@okam/core-lib 2.0.0 → 2.2.0
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/CHANGELOG.md +4 -0
- package/index.js +1 -1
- package/index.mjs +27 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(t,e){if([t,e].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new TypeError(`${n===0?"min":"max"} is not a valid integer`)}),e<t)throw new Error("Min cannot be greater than max");return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}class p{static getRandom(e){return e[l(0,e.length-1)]}static removeItem(e,r){const n=e.indexOf(r);return n>-1&&e.splice(n,1),e}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(t,e){if([t,e].forEach((r,n)=>{if(!Number.isSafeInteger(r))throw new TypeError(`${n===0?"min":"max"} is not a valid integer`)}),e<t)throw new Error("Min cannot be greater than max");return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}class p{static getRandom(e){return e[l(0,e.length-1)]}static removeItem(e,r){const n=e.indexOf(r);return n>-1&&e.splice(n,1),e}}const b=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/;function d(t){if(typeof t!="string"||!b.test(t))return!1;try{return new Date(t).toISOString()===t}catch{return!1}}function s(t,e=!0){return typeof t=="string"&&(e?t.trim():t).length>0}function g(t){return typeof t=="object"&&t!==null&&t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function a(t){return typeof t=="number"&&Number.isSafeInteger(t)}function y(t){return typeof t=="number"&&!Number.isNaN(t)?!0:s(t)?!Number.isNaN(Number.parseInt(t,10)||Number.isNaN(Number.parseFloat(t))):!1}const h=/^-?\d+$/;function m(t){const e=typeof t=="string"&&h.test(t)?Number.parseInt(t,10):t;return a(e)}function N(t){return a(t)&&t<600&&t>=100}class o{static isPresent(e,r){if(e==null)throw o.createException(r,"Value is null or undefined.")}static safeInteger(e,r){if(typeof e!="number"||!Number.isSafeInteger(e))throw o.createException(r,"Value is not a safe integer")}static nonEmptyString(e,r,n){if(!s(e,n??!0))throw o.createException(r)}static never(e,r){throw new Error(r??"Unexpected value")}static createException(e,r){throw typeof e=="function"?e():new Error(e??r??"Assertion did not pass.")}}function O(t){return t.split("/").reduceRight((n,i)=>n.length===0&&i===""?n:[i,...n],[]).join("/")}function I(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function f(t,e,r){const n=Object.keys(t);let i;i??=r;for(const c of n){const u=t[c];if(I(u)&&(i??=f(u,e,i)),c===e)return t[e]}return i}function S(t,e){const r=t[e];return r!=null&&typeof r=="object"&&Object.hasOwn(t,e)?r:null}function j(t){return t.charAt(0).toUpperCase()+t.slice(1)}exports.ArrayUtils=p;exports.Asserts=o;exports.capitalizeFirstLetter=j;exports.checkObjectProperty=S;exports.getNestedObjectValueOfKey=f;exports.isHttpStatusCode=N;exports.isIsoDateString=d;exports.isNonEmptyString=s;exports.isParsableNumeric=y;exports.isParsableSafeInteger=m;exports.isPlainObject=g;exports.isSafeInteger=a;exports.normalizePath=O;
|
package/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ function f(t, e) {
|
|
|
6
6
|
throw new Error("Min cannot be greater than max");
|
|
7
7
|
return t = Math.ceil(t), e = Math.floor(e), Math.floor(Math.random() * (e - t + 1)) + t;
|
|
8
8
|
}
|
|
9
|
-
class
|
|
9
|
+
class h {
|
|
10
10
|
static getRandom(e) {
|
|
11
11
|
return e[f(0, e.length - 1)];
|
|
12
12
|
}
|
|
@@ -15,8 +15,9 @@ class b {
|
|
|
15
15
|
return n > -1 && e.splice(n, 1), e;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const l = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/;
|
|
19
|
+
function g(t) {
|
|
20
|
+
if (typeof t != "string" || !l.test(t))
|
|
20
21
|
return !1;
|
|
21
22
|
try {
|
|
22
23
|
return new Date(t).toISOString() === t;
|
|
@@ -27,20 +28,21 @@ function d(t) {
|
|
|
27
28
|
function c(t, e = !0) {
|
|
28
29
|
return typeof t == "string" && (e ? t.trim() : t).length > 0;
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
+
function y(t) {
|
|
31
32
|
return typeof t == "object" && t !== null && t.constructor === Object && Object.getPrototypeOf(t) === Object.prototype;
|
|
32
33
|
}
|
|
33
34
|
function a(t) {
|
|
34
35
|
return typeof t == "number" && Number.isSafeInteger(t);
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function N(t) {
|
|
37
38
|
return typeof t == "number" && !Number.isNaN(t) ? !0 : c(t) ? !Number.isNaN(Number.parseInt(t, 10) || Number.isNaN(Number.parseFloat(t))) : !1;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
const p = /^-?\d+$/;
|
|
41
|
+
function m(t) {
|
|
42
|
+
const e = typeof t == "string" && p.test(t) ? Number.parseInt(t, 10) : t;
|
|
41
43
|
return a(e);
|
|
42
44
|
}
|
|
43
|
-
function
|
|
45
|
+
function w(t) {
|
|
44
46
|
return a(t) && t < 600 && t >= 100;
|
|
45
47
|
}
|
|
46
48
|
class o {
|
|
@@ -63,42 +65,42 @@ class o {
|
|
|
63
65
|
throw typeof e == "function" ? e() : new Error(e ?? r ?? "Assertion did not pass.");
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
function
|
|
68
|
+
function E(t) {
|
|
67
69
|
return t.split("/").reduceRight((n, i) => n.length === 0 && i === "" ? n : [i, ...n], []).join("/");
|
|
68
70
|
}
|
|
69
|
-
function
|
|
71
|
+
function b(t) {
|
|
70
72
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
71
73
|
}
|
|
72
|
-
function
|
|
74
|
+
function d(t, e, r) {
|
|
73
75
|
const n = Object.keys(t);
|
|
74
76
|
let i;
|
|
75
77
|
i ??= r;
|
|
76
|
-
for (const
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
78
|
+
for (const s of n) {
|
|
79
|
+
const u = t[s];
|
|
80
|
+
if (b(u) && (i ??= d(u, e, i)), s === e)
|
|
79
81
|
return t[e];
|
|
80
82
|
}
|
|
81
83
|
return i;
|
|
82
84
|
}
|
|
83
|
-
function
|
|
85
|
+
function I(t, e) {
|
|
84
86
|
const r = t[e];
|
|
85
|
-
return r != null && typeof r == "object" && Object.
|
|
87
|
+
return r != null && typeof r == "object" && Object.hasOwn(t, e) ? r : null;
|
|
86
88
|
}
|
|
87
89
|
function O(t) {
|
|
88
90
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
89
91
|
}
|
|
90
92
|
export {
|
|
91
|
-
|
|
93
|
+
h as ArrayUtils,
|
|
92
94
|
o as Asserts,
|
|
93
95
|
O as capitalizeFirstLetter,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
I as checkObjectProperty,
|
|
97
|
+
d as getNestedObjectValueOfKey,
|
|
98
|
+
w as isHttpStatusCode,
|
|
99
|
+
g as isIsoDateString,
|
|
98
100
|
c as isNonEmptyString,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
N as isParsableNumeric,
|
|
102
|
+
m as isParsableSafeInteger,
|
|
103
|
+
y as isPlainObject,
|
|
102
104
|
a as isSafeInteger,
|
|
103
|
-
|
|
105
|
+
E as normalizePath
|
|
104
106
|
};
|