@ls-stack/utils 3.12.3 → 3.14.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.
Files changed (50) hide show
  1. package/lib/arrayUtils.cjs +5 -2
  2. package/lib/arrayUtils.js +3 -2
  3. package/lib/assertions.cjs +42 -34
  4. package/lib/assertions.d.cts +175 -11
  5. package/lib/assertions.d.ts +175 -11
  6. package/lib/assertions.js +2 -1
  7. package/lib/cache.cjs +7 -4
  8. package/lib/cache.js +2 -1
  9. package/lib/{chunk-UTFE4P3P.js → chunk-DMW5Q4T2.js} +1 -1
  10. package/lib/{chunk-OHHF4CJZ.js → chunk-GKOTKAIV.js} +1 -1
  11. package/lib/chunk-NH2LCAQS.js +56 -0
  12. package/lib/chunk-SSKW673U.js +36 -0
  13. package/lib/chunk-WS4WEVHU.js +57 -0
  14. package/lib/concurrentCalls.cjs +20 -14
  15. package/lib/concurrentCalls.d.cts +2 -0
  16. package/lib/concurrentCalls.d.ts +2 -0
  17. package/lib/concurrentCalls.js +5 -2
  18. package/lib/createThrottleController.cjs +5 -2
  19. package/lib/createThrottleController.js +3 -2
  20. package/lib/enhancedMap.cjs +5 -2
  21. package/lib/enhancedMap.js +3 -2
  22. package/lib/getCompositeKey.cjs +86 -0
  23. package/lib/getCompositeKey.d.cts +10 -0
  24. package/lib/getCompositeKey.d.ts +10 -0
  25. package/lib/getCompositeKey.js +8 -0
  26. package/lib/getValueStableKey.cjs +10 -4
  27. package/lib/getValueStableKey.d.cts +5 -1
  28. package/lib/getValueStableKey.d.ts +5 -1
  29. package/lib/getValueStableKey.js +5 -49
  30. package/lib/interpolate.cjs +2 -2
  31. package/lib/interpolate.js +2 -1
  32. package/lib/objUtils.d.cts +1 -0
  33. package/lib/objUtils.d.ts +1 -0
  34. package/lib/parallelAsyncCalls.cjs +10 -7
  35. package/lib/parallelAsyncCalls.js +2 -1
  36. package/lib/saferTyping.d.cts +11 -1
  37. package/lib/saferTyping.d.ts +11 -1
  38. package/lib/serializeXML.js +3 -2
  39. package/lib/testUtils.cjs +5 -2
  40. package/lib/testUtils.js +3 -2
  41. package/lib/tsResult.cjs +9 -4
  42. package/lib/tsResult.js +2 -1
  43. package/lib/typeGuards.cjs +65 -0
  44. package/lib/typeGuards.d.cts +109 -0
  45. package/lib/typeGuards.d.ts +109 -0
  46. package/lib/typeGuards.js +16 -0
  47. package/lib/yamlStringify.cjs +17 -9
  48. package/lib/yamlStringify.js +7 -2
  49. package/package.json +9 -1
  50. package/lib/chunk-3XCS7FVO.js +0 -66
@@ -1,66 +0,0 @@
1
- // src/assertions.ts
2
- var undefErrMsg = "not undefined assertion failed";
3
- var nullishErrMsg = "not nullish assertion failed";
4
- function notUndefined(value, errorMsg = undefErrMsg) {
5
- if (value === void 0) {
6
- throw new Error(errorMsg);
7
- }
8
- return value;
9
- }
10
- function notNullish(value, errorMsg = nullishErrMsg) {
11
- if (value === void 0 || value === null) {
12
- throw new Error(errorMsg);
13
- }
14
- return value;
15
- }
16
- function assertIsNotNullish(value, errorMsg = nullishErrMsg) {
17
- if (value === void 0 || value === null) {
18
- throw new Error(errorMsg);
19
- }
20
- }
21
- function assertIsNotUndefined(value, errorMsg = undefErrMsg) {
22
- if (value === void 0) {
23
- throw new Error(errorMsg);
24
- }
25
- }
26
- function invariant(condition, errorMsg = "Invariant violation") {
27
- if (!condition) {
28
- throw new Error(`Invariant violation: ${errorMsg}`);
29
- }
30
- }
31
- function exhaustiveCheck(narrowedType) {
32
- return new Error("This should never happen");
33
- }
34
- function isObject(value) {
35
- return typeof value === "object" && value !== null && !Array.isArray(value);
36
- }
37
- function isFunction(value) {
38
- return typeof value === "function";
39
- }
40
- function isPromise(value) {
41
- return isObject(value) && "then" in value && isFunction(value.then);
42
- }
43
- function isPlainObject(value) {
44
- if (!value || typeof value !== "object") return false;
45
- const proto = Object.getPrototypeOf(value);
46
- if (proto === null) {
47
- return true;
48
- }
49
- const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
50
- if (Ctor === Object) return true;
51
- const objectCtorString = Object.prototype.constructor.toString();
52
- return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
53
- }
54
-
55
- export {
56
- notUndefined,
57
- notNullish,
58
- assertIsNotNullish,
59
- assertIsNotUndefined,
60
- invariant,
61
- exhaustiveCheck,
62
- isObject,
63
- isFunction,
64
- isPromise,
65
- isPlainObject
66
- };