@tolki/utils 1.6.0 → 1.6.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../src/equality.ts"],"names":[],"mappings":"AAmIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5D;AAuID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgH1D;AA8FD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAqE3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACf,OAAO,CA2DT"}
1
+ {"version":3,"file":"equality.d.ts","sourceRoot":"","sources":["../src/equality.ts"],"names":[],"mappings":"AAmIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAE5D;AAgJD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAgH1D;AA8FD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAqE3D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CACzB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACf,OAAO,CA2DT"}
package/dist/equality.js CHANGED
@@ -1,8 +1,8 @@
1
- import { isNumber as T, isString as u, isPhpNumeric as y, isBoolean as h, isObject as m, isPlainObject as V, isArray as B, isPhpFalsy as H, isNull as R, isUndefined as U } from "./guards.js";
1
+ import { isNumber as T, isString as u, isPhpNumeric as y, isBoolean as N, isObject as m, isPlainObject as V, isArray as B, isPhpFalsy as H, isNull as R, isUndefined as U } from "./guards.js";
2
2
  function g(t) {
3
3
  return R(t) || U(t);
4
4
  }
5
- function N(t, r) {
5
+ function h(t, r) {
6
6
  return t < r ? -1 : t > r ? 1 : 0;
7
7
  }
8
8
  const j = /^[ \t\n\r\v\f]*[+-]?\d+[ \t\n\r\v\f]*$/, A = 2 ** 63, k = 2n ** 63n;
@@ -11,11 +11,11 @@ function S(t) {
11
11
  }
12
12
  function D(t, r) {
13
13
  if (j.test(t) && j.test(r)) {
14
- const i = BigInt(t), c = BigInt(r), s = S(i);
15
- return s !== 0 && s === S(c) && Number(t) === Number(r) ? N(t, r) : i < c ? -1 : i > c ? 1 : 0;
14
+ const e = BigInt(t), i = BigInt(r), s = S(e);
15
+ return s !== 0 && s === S(i) && Number(t) === Number(r) ? h(t, r) : e < i ? -1 : e > i ? 1 : 0;
16
16
  }
17
- const n = Number(t), e = Number(r);
18
- return n === e && !Number.isFinite(n) ? N(t, r) : n < e ? -1 : n > e ? 1 : 0;
17
+ const n = Number(t), o = Number(r);
18
+ return n === o && !Number.isFinite(n) ? h(t, r) : n < o ? -1 : n > o ? 1 : 0;
19
19
  }
20
20
  function p(t) {
21
21
  return !H(t);
@@ -25,10 +25,10 @@ function _(t, r) {
25
25
  }
26
26
  function G(t, r, n) {
27
27
  if (g(t) && u(r))
28
- return N("", r);
28
+ return h("", r);
29
29
  if (u(t) && g(r))
30
- return N(t, "");
31
- if (g(t) || g(r) || h(t) || h(r)) {
30
+ return h(t, "");
31
+ if (g(t) || g(r) || N(t) || N(r)) {
32
32
  const e = p(t), i = p(r);
33
33
  return e === i ? 0 : e ? 1 : -1;
34
34
  }
@@ -38,32 +38,34 @@ function G(t, r, n) {
38
38
  }
39
39
  if (typeof t == "object" && typeof r == "object")
40
40
  return q(t, r, n ?? /* @__PURE__ */ new Map());
41
+ if ((typeof t == "number" || u(t)) && (typeof r == "number" || u(r)) && (Number.isNaN(t) || Number.isNaN(r)))
42
+ return 1;
41
43
  if (y(t) && y(r)) {
42
44
  if (u(t) && u(r))
43
45
  return D(t, r);
44
46
  const e = Number(t), i = Number(r);
45
47
  return e < i ? -1 : e > i ? 1 : 0;
46
48
  }
47
- return u(t) || u(r) ? N(String(t), String(r)) : t < r ? -1 : t > r ? 1 : 0;
49
+ return u(t) || u(r) ? h(String(t), String(r)) : t < r ? -1 : t > r ? 1 : 0;
48
50
  }
49
51
  function q(t, r, n) {
50
- const e = n.get(t);
51
- if (e?.has(r))
52
+ const o = n.get(t);
53
+ if (o?.has(r))
52
54
  return 0;
53
- const i = e ?? /* @__PURE__ */ new Set();
54
- e || n.set(t, i), i.add(r);
55
- const c = C(t, r, n);
56
- return i.delete(r), c;
55
+ const e = o ?? /* @__PURE__ */ new Set();
56
+ o || n.set(t, e), e.add(r);
57
+ const i = C(t, r, n);
58
+ return e.delete(r), i;
57
59
  }
58
60
  function C(t, r, n) {
59
- const e = Object.keys(t), i = Object.keys(r).length;
60
- if (e.length !== i)
61
- return e.length < i ? -1 : 1;
62
- const c = t, s = r;
63
- for (const f of e) {
61
+ const o = Object.keys(t), e = Object.keys(r).length;
62
+ if (o.length !== e)
63
+ return o.length < e ? -1 : 1;
64
+ const i = t, s = r;
65
+ for (const f of o) {
64
66
  if (!Object.hasOwn(r, f))
65
67
  return 1;
66
- const l = G(c[f], s[f], n);
68
+ const l = G(i[f], s[f], n);
67
69
  if (l !== 0)
68
70
  return l;
69
71
  }
@@ -76,14 +78,14 @@ function I(t, r) {
76
78
  return !1;
77
79
  if (u(t) && u(r))
78
80
  return y(t) && y(r) && D(t, r) === 0;
79
- const n = g(t), e = g(r);
80
- if (n && e)
81
+ const n = g(t), o = g(r);
82
+ if (n && o)
81
83
  return !0;
82
- if (n || e) {
84
+ if (n || o) {
83
85
  const s = n ? r : t;
84
86
  return u(s) ? s === "" : !p(s);
85
87
  }
86
- if (h(t) || h(r))
88
+ if (N(t) || N(r))
87
89
  return p(t) === p(r);
88
90
  if (P(t) || P(r))
89
91
  return !1;
@@ -92,8 +94,8 @@ function I(t, r) {
92
94
  if (m(s) && !V(s) && x(s))
93
95
  return String(s) === (u(t) ? t : r);
94
96
  }
95
- const i = E(t) || u(t), c = E(r) || u(r);
96
- if (i && c)
97
+ const e = E(t) || u(t), i = E(r) || u(r);
98
+ if (e && i)
97
99
  return d(t) && d(r) ? w(t) && w(r) ? BigInt(t) === BigInt(r) : Number(t) === Number(r) : F(t) === F(r);
98
100
  if (B(t) && B(r)) {
99
101
  if (t.length !== r.length)
@@ -151,14 +153,14 @@ function O(t, r) {
151
153
  return !0;
152
154
  }
153
155
  if (t !== null && r !== null && typeof t == "object" && typeof r == "object" && !Array.isArray(t) && !Array.isArray(r)) {
154
- const n = t.constructor === Object || t.constructor === void 0, e = r.constructor === Object || r.constructor === void 0;
155
- if (!n || !e)
156
+ const n = t.constructor === Object || t.constructor === void 0, o = r.constructor === Object || r.constructor === void 0;
157
+ if (!n || !o)
156
158
  return !1;
157
- const i = Object.keys(t), c = Object.keys(r);
158
- if (i.length !== c.length)
159
+ const e = Object.keys(t), i = Object.keys(r);
160
+ if (e.length !== i.length)
159
161
  return !1;
160
- for (const [s, f] of i.entries())
161
- if (f !== c[s] || !O(
162
+ for (const [s, f] of e.entries())
163
+ if (f !== i[s] || !O(
162
164
  t[f],
163
165
  r[f]
164
166
  ))
@@ -168,24 +170,24 @@ function O(t, r) {
168
170
  return !1;
169
171
  }
170
172
  function Y(t, r, n) {
171
- const e = [t, n], i = (o) => m(o) && !V(o);
172
- if (e.filter(
173
- (o) => u(o) || i(o) && x(o)
174
- ).length < 2 && e.filter(i).length === 1)
173
+ const o = [t, n], e = (c) => m(c) && !V(c);
174
+ if (o.filter(
175
+ (c) => u(c) || e(c) && x(c)
176
+ ).length < 2 && o.filter(e).length === 1)
175
177
  return ["!=", "<>", "!=="].includes(r);
176
- const f = !(h(t) || h(n) || g(t) || g(n)) && (P(t) || P(n)), l = (o) => !f && o(_(t, n));
178
+ const f = !(N(t) || N(n) || g(t) || g(n)) && (P(t) || P(n)), l = (c) => !f && c(_(t, n));
177
179
  switch (r) {
178
180
  case "!=":
179
181
  case "<>":
180
182
  return !I(t, n);
181
183
  case "<":
182
- return l((o) => o < 0);
184
+ return l((c) => c < 0);
183
185
  case ">":
184
- return l((o) => o > 0);
186
+ return l((c) => c > 0);
185
187
  case "<=":
186
- return l((o) => o <= 0);
188
+ return l((c) => c <= 0);
187
189
  case ">=":
188
- return l((o) => o >= 0);
190
+ return l((c) => c >= 0);
189
191
  // PHP's `===` compares an array by value — same keys, same order, same types — and only a real object by
190
192
  // identity. strictEqual is that rule; JS's own `===` would call every pair of equal arrays unequal
191
193
  // (docs/php-parity/Collection/contains.json, "r4-strict-operators").
package/dist/index.js CHANGED
@@ -1,30 +1,32 @@
1
- import { arrayableItems as t, arrayableValues as i, castableToArray as s, cssListItemToString as a, getAccessibleValues as o, normalizeToArray as p, phpIntArgument as n, phpIntCast as l, phpStringCast as y, toArrayable as m, toJsonSerializable as u, toJsonable as c, toPhpKeyString as b } from "./cast.js";
2
- import { compareValues as g, looseEqual as x, operatorMatch as S, strictEqual as f } from "./equality.js";
3
- import { InvalidArgumentException as K, ItemNotFoundException as d, MultipleItemsFoundException as P, UnexpectedValueException as A } from "./exceptions.js";
4
- import { isAccessibleData as E, isArray as M, isBoolean as N, isEnumCase as T, isFalsy as F, isFiniteNumber as O, isFloat as V, isFunction as C, isInteger as j, isIterable as k, isMap as w, isNegativeNumber as L, isNonPrimitive as U, isNull as z, isNumber as D, isObject as R, isObjectAny as q, isPhpAccessible as J, isPhpFalsy as W, isPhpInt as B, isPhpNumeric as G, isPlainObject as H, isPositiveNumber as Q, isPrimitive as X, isPrototypeObject as Y, isSet as Z, isString as _, isStringable as $, isSymbol as ee, isTruthy as re, isTruthyObject as te, isUndefined as ie, isWeakMap as se, isWeakSet as ae, objectToString as oe, phpValueMatch as pe, phpValueMatcher as ne } from "./guards.js";
5
- import { arrayKeyExistsError as ye, defineKey as me, deleteMapKey as ue, entriesKeyValue as ce, hasOwnToString as be, isIllegalOffset as he, isIntegerLikeKey as ge, isPhpArrayKey as xe, isUnsafeKey as Se, keyedEntries as fe, nextIntegerKey as Ie, phpArrayKey as Ke, phpComputedKey as de, readMapKey as Pe, reindexIntegerKeys as Ae, renumberPhpIntegerKeys as ve, writeMapKey as Ee } from "./keys.js";
1
+ import { arrayableItems as t, arrayableValues as i, castableToArray as s, cssListItemToString as a, getAccessibleValues as o, normalizeToArray as p, phpIntArgument as l, phpIntCast as n, phpStringCast as y, toArrayable as c, toJsonSerializable as m, toJsonable as u, toPhpKeyString as h } from "./cast.js";
2
+ import { compareValues as b, looseEqual as S, operatorMatch as x, strictEqual as f } from "./equality.js";
3
+ import { InvalidArgumentException as K, ItemNotFoundException as d, MultipleItemsFoundException as A, UnexpectedValueException as P } from "./exceptions.js";
4
+ import { isAccessibleData as E, isArray as M, isBoolean as N, isEnumCase as T, isFalsy as F, isFiniteNumber as O, isFloat as V, isFunction as C, isInteger as j, isIterable as k, isMap as w, isNegativeNumber as L, isNonPrimitive as U, isNull as z, isNumber as D, isObject as R, isObjectAny as W, isPhpAccessible as q, isPhpFalsy as J, isPhpInt as B, isPhpNumeric as G, isPlainObject as H, isPositiveNumber as Q, isPrimitive as X, isPrototypeObject as Y, isSet as Z, isString as _, isStringable as $, isSymbol as ee, isTruthy as re, isTruthyObject as te, isUndefined as ie, isWeakMap as se, isWeakSet as ae, objectToString as oe, phpValueMatch as pe, phpValueMatcher as le } from "./guards.js";
5
+ import { arrayKeyExistsError as ye, defineKey as ce, deleteMapKey as me, entriesKeyValue as ue, hasOwnToString as he, isIllegalOffset as ge, isIntegerLikeKey as be, isPhpArrayKey as Se, isUnsafeKey as xe, keyedEntries as fe, nextIntegerKey as Ie, phpArrayKey as Ke, phpComputedKey as de, readMapKey as Ae, reindexIntegerKeys as Pe, renumberPhpIntegerKeys as ve, writeMapKey as Ee } from "./keys.js";
6
6
  import { resolvePadLength as Ne, resolveRangeSize as Te, resolveSliceRange as Fe, resolveSpliceRange as Oe, resolveTakeCount as Ve } from "./range.js";
7
7
  import { phpDebugType as je, phpTypeName as ke, resolveDefault as we, typeOf as Le } from "./reflect.js";
8
8
  import { createSortSpecComparator as ze, phpSortComparator as De } from "./sorting.js";
9
- import { arrayValueMessage as qe, lowerFirst as Je, toLower as We, toUpper as Be, upperFirst as Ge } from "./string.js";
9
+ import { arrayValueMessage as We, escapeShellArg as qe, escapeWindowsShellArg as Je, lowerFirst as Be, toLower as Ge, toUpper as He, upperFirst as Qe } from "./string.js";
10
10
  export {
11
11
  K as InvalidArgumentException,
12
12
  d as ItemNotFoundException,
13
- P as MultipleItemsFoundException,
14
- A as UnexpectedValueException,
13
+ A as MultipleItemsFoundException,
14
+ P as UnexpectedValueException,
15
15
  ye as arrayKeyExistsError,
16
- qe as arrayValueMessage,
16
+ We as arrayValueMessage,
17
17
  t as arrayableItems,
18
18
  i as arrayableValues,
19
19
  s as castableToArray,
20
- g as compareValues,
20
+ b as compareValues,
21
21
  ze as createSortSpecComparator,
22
22
  a as cssListItemToString,
23
- me as defineKey,
24
- ue as deleteMapKey,
25
- ce as entriesKeyValue,
23
+ ce as defineKey,
24
+ me as deleteMapKey,
25
+ ue as entriesKeyValue,
26
+ qe as escapeShellArg,
27
+ Je as escapeWindowsShellArg,
26
28
  o as getAccessibleValues,
27
- be as hasOwnToString,
29
+ he as hasOwnToString,
28
30
  E as isAccessibleData,
29
31
  M as isArray,
30
32
  N as isBoolean,
@@ -33,9 +35,9 @@ export {
33
35
  O as isFiniteNumber,
34
36
  V as isFloat,
35
37
  C as isFunction,
36
- he as isIllegalOffset,
38
+ ge as isIllegalOffset,
37
39
  j as isInteger,
38
- ge as isIntegerLikeKey,
40
+ be as isIntegerLikeKey,
39
41
  k as isIterable,
40
42
  w as isMap,
41
43
  L as isNegativeNumber,
@@ -43,10 +45,10 @@ export {
43
45
  z as isNull,
44
46
  D as isNumber,
45
47
  R as isObject,
46
- q as isObjectAny,
47
- J as isPhpAccessible,
48
- xe as isPhpArrayKey,
49
- W as isPhpFalsy,
48
+ W as isObjectAny,
49
+ q as isPhpAccessible,
50
+ Se as isPhpArrayKey,
51
+ J as isPhpFalsy,
50
52
  B as isPhpInt,
51
53
  G as isPhpNumeric,
52
54
  H as isPlainObject,
@@ -60,28 +62,28 @@ export {
60
62
  re as isTruthy,
61
63
  te as isTruthyObject,
62
64
  ie as isUndefined,
63
- Se as isUnsafeKey,
65
+ xe as isUnsafeKey,
64
66
  se as isWeakMap,
65
67
  ae as isWeakSet,
66
68
  fe as keyedEntries,
67
- x as looseEqual,
68
- Je as lowerFirst,
69
+ S as looseEqual,
70
+ Be as lowerFirst,
69
71
  Ie as nextIntegerKey,
70
72
  p as normalizeToArray,
71
73
  oe as objectToString,
72
- S as operatorMatch,
74
+ x as operatorMatch,
73
75
  Ke as phpArrayKey,
74
76
  de as phpComputedKey,
75
77
  je as phpDebugType,
76
- n as phpIntArgument,
77
- l as phpIntCast,
78
+ l as phpIntArgument,
79
+ n as phpIntCast,
78
80
  De as phpSortComparator,
79
81
  y as phpStringCast,
80
82
  ke as phpTypeName,
81
83
  pe as phpValueMatch,
82
- ne as phpValueMatcher,
83
- Pe as readMapKey,
84
- Ae as reindexIntegerKeys,
84
+ le as phpValueMatcher,
85
+ Ae as readMapKey,
86
+ Pe as reindexIntegerKeys,
85
87
  ve as renumberPhpIntegerKeys,
86
88
  we as resolveDefault,
87
89
  Ne as resolvePadLength,
@@ -90,13 +92,13 @@ export {
90
92
  Oe as resolveSpliceRange,
91
93
  Ve as resolveTakeCount,
92
94
  f as strictEqual,
93
- m as toArrayable,
94
- u as toJsonSerializable,
95
- c as toJsonable,
96
- We as toLower,
97
- b as toPhpKeyString,
98
- Be as toUpper,
95
+ c as toArrayable,
96
+ m as toJsonSerializable,
97
+ u as toJsonable,
98
+ Ge as toLower,
99
+ h as toPhpKeyString,
100
+ He as toUpper,
99
101
  Le as typeOf,
100
- Ge as upperFirst,
102
+ Qe as upperFirst,
101
103
  Ee as writeMapKey
102
104
  };
package/dist/string.d.ts CHANGED
@@ -24,4 +24,23 @@ export declare function upperFirst(value: string): string;
24
24
  * @returns The formatted error message.
25
25
  */
26
26
  export declare function arrayValueMessage(value: unknown, key: PathKey): string;
27
+ /**
28
+ * Escape a value for safe interpolation into a shell command string.
29
+ *
30
+ * Uses POSIX single-quote wrapping: the only character that requires
31
+ * escaping inside single quotes is the single quote itself.
32
+ *
33
+ * @param value - The raw string to escape.
34
+ * @returns A shell-safe string.
35
+ */
36
+ export declare function escapeShellArg(value: string): string;
37
+ /**
38
+ * Escape a value for safe interpolation into a cmd.exe command string, the shell Node's `exec` runs on Windows.
39
+ *
40
+ * `%` cannot be escaped on a cmd.exe command line, so a `%NAME%` in the value still expands.
41
+ *
42
+ * @param value - The raw string to escape.
43
+ * @returns The value bare when every character is safe, else double-quoted by the MSVCRT argv rules.
44
+ */
45
+ export declare function escapeWindowsShellArg(value: string): string;
27
46
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAEtE"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUhD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAEtE;AAID;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA2B3D"}
package/dist/string.js CHANGED
@@ -1,25 +1,46 @@
1
- import { phpTypeName as t } from "./reflect.js";
2
- function o(r) {
1
+ import { phpTypeName as s } from "./reflect.js";
2
+ function c(r) {
3
3
  return r.toLowerCase();
4
4
  }
5
- function u(r) {
5
+ function p(r) {
6
6
  return r.toUpperCase();
7
7
  }
8
- function a(r) {
8
+ function f(r) {
9
9
  const e = [...r];
10
10
  return e.length === 0 ? r : (e[0] = e[0].toLowerCase(), e.join(""));
11
11
  }
12
- function i(r) {
12
+ function a(r) {
13
13
  const e = [...r];
14
14
  return e.length === 0 ? r : (e[0] = e[0].toUpperCase(), e.join(""));
15
15
  }
16
- function p(r, e) {
17
- return `Array value for key [${String(e)}] must be an array, ${t(r)} found.`;
16
+ function u(r, e) {
17
+ return `Array value for key [${String(e)}] must be an array, ${s(r)} found.`;
18
+ }
19
+ const o = /^[\w@%+=:,./-]+$/;
20
+ function h(r) {
21
+ return r === "" ? "''" : o.test(r) ? r : "'" + r.replace(/'/g, "'\\''") + "'";
22
+ }
23
+ function $(r) {
24
+ if (r === "")
25
+ return '""';
26
+ if (o.test(r))
27
+ return r;
28
+ let e = "", t = 0;
29
+ for (const n of r) {
30
+ if (n === "\\") {
31
+ t++;
32
+ continue;
33
+ }
34
+ e += n === '"' ? `${"\\".repeat(t * 2 + 1)}"` : `${"\\".repeat(t)}${n}`, t = 0;
35
+ }
36
+ return `"${e}${"\\".repeat(t * 2)}"`;
18
37
  }
19
38
  export {
20
- p as arrayValueMessage,
21
- a as lowerFirst,
22
- o as toLower,
23
- u as toUpper,
24
- i as upperFirst
39
+ u as arrayValueMessage,
40
+ h as escapeShellArg,
41
+ $ as escapeWindowsShellArg,
42
+ f as lowerFirst,
43
+ c as toLower,
44
+ p as toUpper,
45
+ a as upperFirst
25
46
  };
package/dist/utils.js CHANGED
@@ -1,30 +1,32 @@
1
- import { arrayableItems as t, arrayableValues as i, castableToArray as s, cssListItemToString as a, getAccessibleValues as o, normalizeToArray as p, phpIntArgument as n, phpIntCast as l, phpStringCast as y, toArrayable as m, toJsonSerializable as u, toJsonable as c, toPhpKeyString as b } from "./cast.js";
2
- import { compareValues as g, looseEqual as x, operatorMatch as S, strictEqual as f } from "./equality.js";
3
- import { InvalidArgumentException as K, ItemNotFoundException as d, MultipleItemsFoundException as P, UnexpectedValueException as A } from "./exceptions.js";
4
- import { isAccessibleData as E, isArray as M, isBoolean as N, isEnumCase as T, isFalsy as F, isFiniteNumber as O, isFloat as V, isFunction as C, isInteger as j, isIterable as k, isMap as w, isNegativeNumber as L, isNonPrimitive as U, isNull as z, isNumber as D, isObject as R, isObjectAny as q, isPhpAccessible as J, isPhpFalsy as W, isPhpInt as B, isPhpNumeric as G, isPlainObject as H, isPositiveNumber as Q, isPrimitive as X, isPrototypeObject as Y, isSet as Z, isString as _, isStringable as $, isSymbol as ee, isTruthy as re, isTruthyObject as te, isUndefined as ie, isWeakMap as se, isWeakSet as ae, objectToString as oe, phpValueMatch as pe, phpValueMatcher as ne } from "./guards.js";
5
- import { arrayKeyExistsError as ye, defineKey as me, deleteMapKey as ue, entriesKeyValue as ce, hasOwnToString as be, isIllegalOffset as he, isIntegerLikeKey as ge, isPhpArrayKey as xe, isUnsafeKey as Se, keyedEntries as fe, nextIntegerKey as Ie, phpArrayKey as Ke, phpComputedKey as de, readMapKey as Pe, reindexIntegerKeys as Ae, renumberPhpIntegerKeys as ve, writeMapKey as Ee } from "./keys.js";
1
+ import { arrayableItems as t, arrayableValues as i, castableToArray as s, cssListItemToString as a, getAccessibleValues as o, normalizeToArray as p, phpIntArgument as l, phpIntCast as n, phpStringCast as y, toArrayable as c, toJsonSerializable as m, toJsonable as u, toPhpKeyString as h } from "./cast.js";
2
+ import { compareValues as b, looseEqual as S, operatorMatch as x, strictEqual as f } from "./equality.js";
3
+ import { InvalidArgumentException as K, ItemNotFoundException as d, MultipleItemsFoundException as A, UnexpectedValueException as P } from "./exceptions.js";
4
+ import { isAccessibleData as E, isArray as M, isBoolean as N, isEnumCase as T, isFalsy as F, isFiniteNumber as O, isFloat as V, isFunction as C, isInteger as j, isIterable as k, isMap as w, isNegativeNumber as L, isNonPrimitive as U, isNull as z, isNumber as D, isObject as R, isObjectAny as W, isPhpAccessible as q, isPhpFalsy as J, isPhpInt as B, isPhpNumeric as G, isPlainObject as H, isPositiveNumber as Q, isPrimitive as X, isPrototypeObject as Y, isSet as Z, isString as _, isStringable as $, isSymbol as ee, isTruthy as re, isTruthyObject as te, isUndefined as ie, isWeakMap as se, isWeakSet as ae, objectToString as oe, phpValueMatch as pe, phpValueMatcher as le } from "./guards.js";
5
+ import { arrayKeyExistsError as ye, defineKey as ce, deleteMapKey as me, entriesKeyValue as ue, hasOwnToString as he, isIllegalOffset as ge, isIntegerLikeKey as be, isPhpArrayKey as Se, isUnsafeKey as xe, keyedEntries as fe, nextIntegerKey as Ie, phpArrayKey as Ke, phpComputedKey as de, readMapKey as Ae, reindexIntegerKeys as Pe, renumberPhpIntegerKeys as ve, writeMapKey as Ee } from "./keys.js";
6
6
  import { resolvePadLength as Ne, resolveRangeSize as Te, resolveSliceRange as Fe, resolveSpliceRange as Oe, resolveTakeCount as Ve } from "./range.js";
7
7
  import { phpDebugType as je, phpTypeName as ke, resolveDefault as we, typeOf as Le } from "./reflect.js";
8
8
  import { createSortSpecComparator as ze, phpSortComparator as De } from "./sorting.js";
9
- import { arrayValueMessage as qe, lowerFirst as Je, toLower as We, toUpper as Be, upperFirst as Ge } from "./string.js";
9
+ import { arrayValueMessage as We, escapeShellArg as qe, escapeWindowsShellArg as Je, lowerFirst as Be, toLower as Ge, toUpper as He, upperFirst as Qe } from "./string.js";
10
10
  export {
11
11
  K as InvalidArgumentException,
12
12
  d as ItemNotFoundException,
13
- P as MultipleItemsFoundException,
14
- A as UnexpectedValueException,
13
+ A as MultipleItemsFoundException,
14
+ P as UnexpectedValueException,
15
15
  ye as arrayKeyExistsError,
16
- qe as arrayValueMessage,
16
+ We as arrayValueMessage,
17
17
  t as arrayableItems,
18
18
  i as arrayableValues,
19
19
  s as castableToArray,
20
- g as compareValues,
20
+ b as compareValues,
21
21
  ze as createSortSpecComparator,
22
22
  a as cssListItemToString,
23
- me as defineKey,
24
- ue as deleteMapKey,
25
- ce as entriesKeyValue,
23
+ ce as defineKey,
24
+ me as deleteMapKey,
25
+ ue as entriesKeyValue,
26
+ qe as escapeShellArg,
27
+ Je as escapeWindowsShellArg,
26
28
  o as getAccessibleValues,
27
- be as hasOwnToString,
29
+ he as hasOwnToString,
28
30
  E as isAccessibleData,
29
31
  M as isArray,
30
32
  N as isBoolean,
@@ -33,9 +35,9 @@ export {
33
35
  O as isFiniteNumber,
34
36
  V as isFloat,
35
37
  C as isFunction,
36
- he as isIllegalOffset,
38
+ ge as isIllegalOffset,
37
39
  j as isInteger,
38
- ge as isIntegerLikeKey,
40
+ be as isIntegerLikeKey,
39
41
  k as isIterable,
40
42
  w as isMap,
41
43
  L as isNegativeNumber,
@@ -43,10 +45,10 @@ export {
43
45
  z as isNull,
44
46
  D as isNumber,
45
47
  R as isObject,
46
- q as isObjectAny,
47
- J as isPhpAccessible,
48
- xe as isPhpArrayKey,
49
- W as isPhpFalsy,
48
+ W as isObjectAny,
49
+ q as isPhpAccessible,
50
+ Se as isPhpArrayKey,
51
+ J as isPhpFalsy,
50
52
  B as isPhpInt,
51
53
  G as isPhpNumeric,
52
54
  H as isPlainObject,
@@ -60,28 +62,28 @@ export {
60
62
  re as isTruthy,
61
63
  te as isTruthyObject,
62
64
  ie as isUndefined,
63
- Se as isUnsafeKey,
65
+ xe as isUnsafeKey,
64
66
  se as isWeakMap,
65
67
  ae as isWeakSet,
66
68
  fe as keyedEntries,
67
- x as looseEqual,
68
- Je as lowerFirst,
69
+ S as looseEqual,
70
+ Be as lowerFirst,
69
71
  Ie as nextIntegerKey,
70
72
  p as normalizeToArray,
71
73
  oe as objectToString,
72
- S as operatorMatch,
74
+ x as operatorMatch,
73
75
  Ke as phpArrayKey,
74
76
  de as phpComputedKey,
75
77
  je as phpDebugType,
76
- n as phpIntArgument,
77
- l as phpIntCast,
78
+ l as phpIntArgument,
79
+ n as phpIntCast,
78
80
  De as phpSortComparator,
79
81
  y as phpStringCast,
80
82
  ke as phpTypeName,
81
83
  pe as phpValueMatch,
82
- ne as phpValueMatcher,
83
- Pe as readMapKey,
84
- Ae as reindexIntegerKeys,
84
+ le as phpValueMatcher,
85
+ Ae as readMapKey,
86
+ Pe as reindexIntegerKeys,
85
87
  ve as renumberPhpIntegerKeys,
86
88
  we as resolveDefault,
87
89
  Ne as resolvePadLength,
@@ -90,13 +92,13 @@ export {
90
92
  Oe as resolveSpliceRange,
91
93
  Ve as resolveTakeCount,
92
94
  f as strictEqual,
93
- m as toArrayable,
94
- u as toJsonSerializable,
95
- c as toJsonable,
96
- We as toLower,
97
- b as toPhpKeyString,
98
- Be as toUpper,
95
+ c as toArrayable,
96
+ m as toJsonSerializable,
97
+ u as toJsonable,
98
+ Ge as toLower,
99
+ h as toPhpKeyString,
100
+ He as toUpper,
99
101
  Le as typeOf,
100
- Ge as upperFirst,
102
+ Qe as upperFirst,
101
103
  Ee as writeMapKey
102
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/utils",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "A set of utility functions for the @tolki packages.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",
@@ -15,7 +15,7 @@
15
15
  "type": "module",
16
16
  "main": "dist/index.js",
17
17
  "dependencies": {
18
- "@tolki/types": "^1.9.0"
18
+ "@tolki/types": "^1.11.0"
19
19
  },
20
20
  "sideEffects": false,
21
21
  "files": [