@kopexa/shared-utils 1.1.1 → 1.1.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,4 +1,11 @@
1
+ type Dict<T = unknown> = Record<string, T>;
2
+ declare function isArray<T>(value: unknown): value is Array<T>;
3
+ declare function isEmptyArray(value: unknown): boolean;
4
+ declare function isObject(value: unknown): value is Dict;
5
+ declare function isEmptyObject(value: unknown): boolean;
6
+ declare function isEmpty(value: unknown): boolean;
1
7
  type Booleanish = boolean | "true" | "false";
2
8
  declare const dataAttr: (condition: boolean | undefined) => Booleanish;
9
+ declare const ariaAttr: (condition: boolean | undefined) => Booleanish;
3
10
 
4
- export { dataAttr };
11
+ export { type Dict, ariaAttr, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isObject };
@@ -1,4 +1,11 @@
1
+ type Dict<T = unknown> = Record<string, T>;
2
+ declare function isArray<T>(value: unknown): value is Array<T>;
3
+ declare function isEmptyArray(value: unknown): boolean;
4
+ declare function isObject(value: unknown): value is Dict;
5
+ declare function isEmptyObject(value: unknown): boolean;
6
+ declare function isEmpty(value: unknown): boolean;
1
7
  type Booleanish = boolean | "true" | "false";
2
8
  declare const dataAttr: (condition: boolean | undefined) => Booleanish;
9
+ declare const ariaAttr: (condition: boolean | undefined) => Booleanish;
3
10
 
4
- export { dataAttr };
11
+ export { type Dict, ariaAttr, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isObject };
package/dist/assertion.js CHANGED
@@ -20,11 +20,43 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/assertion.ts
21
21
  var assertion_exports = {};
22
22
  __export(assertion_exports, {
23
- dataAttr: () => dataAttr
23
+ ariaAttr: () => ariaAttr,
24
+ dataAttr: () => dataAttr,
25
+ isArray: () => isArray,
26
+ isEmpty: () => isEmpty,
27
+ isEmptyArray: () => isEmptyArray,
28
+ isEmptyObject: () => isEmptyObject,
29
+ isObject: () => isObject
24
30
  });
25
31
  module.exports = __toCommonJS(assertion_exports);
32
+ function isArray(value) {
33
+ return Array.isArray(value);
34
+ }
35
+ function isEmptyArray(value) {
36
+ return isArray(value) && value.length === 0;
37
+ }
38
+ function isObject(value) {
39
+ const type = typeof value;
40
+ return value != null && (type === "object" || type === "function") && !isArray(value);
41
+ }
42
+ function isEmptyObject(value) {
43
+ return isObject(value) && Object.keys(value).length === 0;
44
+ }
45
+ function isEmpty(value) {
46
+ if (isArray(value)) return isEmptyArray(value);
47
+ if (isObject(value)) return isEmptyObject(value);
48
+ if (value == null || value === "") return true;
49
+ return false;
50
+ }
26
51
  var dataAttr = (condition) => condition ? "true" : void 0;
52
+ var ariaAttr = (condition) => condition ? "true" : void 0;
27
53
  // Annotate the CommonJS export names for ESM import in node:
28
54
  0 && (module.exports = {
29
- dataAttr
55
+ ariaAttr,
56
+ dataAttr,
57
+ isArray,
58
+ isEmpty,
59
+ isEmptyArray,
60
+ isEmptyObject,
61
+ isObject
30
62
  });
@@ -1,5 +1,31 @@
1
1
  // src/assertion.ts
2
+ function isArray(value) {
3
+ return Array.isArray(value);
4
+ }
5
+ function isEmptyArray(value) {
6
+ return isArray(value) && value.length === 0;
7
+ }
8
+ function isObject(value) {
9
+ const type = typeof value;
10
+ return value != null && (type === "object" || type === "function") && !isArray(value);
11
+ }
12
+ function isEmptyObject(value) {
13
+ return isObject(value) && Object.keys(value).length === 0;
14
+ }
15
+ function isEmpty(value) {
16
+ if (isArray(value)) return isEmptyArray(value);
17
+ if (isObject(value)) return isEmptyObject(value);
18
+ if (value == null || value === "") return true;
19
+ return false;
20
+ }
2
21
  var dataAttr = (condition) => condition ? "true" : void 0;
22
+ var ariaAttr = (condition) => condition ? "true" : void 0;
3
23
  export {
4
- dataAttr
24
+ ariaAttr,
25
+ dataAttr,
26
+ isArray,
27
+ isEmpty,
28
+ isEmptyArray,
29
+ isEmptyObject,
30
+ isObject
5
31
  };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- export { dataAttr } from './assertion.mjs';
1
+ export { ariaAttr, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isObject } from './assertion.mjs';
2
2
  export { cn } from './clsx.mjs';
3
3
  export { getUniqueID } from './functions.mjs';
4
4
  export { clamp } from './numbers.mjs';
5
+ export { chain } from './ra.mjs';
5
6
  import 'clsx';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export { dataAttr } from './assertion.js';
1
+ export { ariaAttr, dataAttr, isArray, isEmpty, isEmptyArray, isEmptyObject, isObject } from './assertion.js';
2
2
  export { cn } from './clsx.js';
3
3
  export { getUniqueID } from './functions.js';
4
4
  export { clamp } from './numbers.js';
5
+ export { chain } from './ra.js';
5
6
  import 'clsx';
package/dist/index.js CHANGED
@@ -20,15 +20,42 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ ariaAttr: () => ariaAttr,
24
+ chain: () => chain,
23
25
  clamp: () => clamp,
24
26
  cn: () => cn,
25
27
  dataAttr: () => dataAttr,
26
- getUniqueID: () => getUniqueID
28
+ getUniqueID: () => getUniqueID,
29
+ isArray: () => isArray,
30
+ isEmpty: () => isEmpty,
31
+ isEmptyArray: () => isEmptyArray,
32
+ isEmptyObject: () => isEmptyObject,
33
+ isObject: () => isObject
27
34
  });
28
35
  module.exports = __toCommonJS(index_exports);
29
36
 
30
37
  // src/assertion.ts
38
+ function isArray(value) {
39
+ return Array.isArray(value);
40
+ }
41
+ function isEmptyArray(value) {
42
+ return isArray(value) && value.length === 0;
43
+ }
44
+ function isObject(value) {
45
+ const type = typeof value;
46
+ return value != null && (type === "object" || type === "function") && !isArray(value);
47
+ }
48
+ function isEmptyObject(value) {
49
+ return isObject(value) && Object.keys(value).length === 0;
50
+ }
51
+ function isEmpty(value) {
52
+ if (isArray(value)) return isEmptyArray(value);
53
+ if (isObject(value)) return isEmptyObject(value);
54
+ if (value == null || value === "") return true;
55
+ return false;
56
+ }
31
57
  var dataAttr = (condition) => condition ? "true" : void 0;
58
+ var ariaAttr = (condition) => condition ? "true" : void 0;
32
59
 
33
60
  // src/clsx.ts
34
61
  var import_clsx = require("clsx");
@@ -46,10 +73,28 @@ function getUniqueID(prefix) {
46
73
  function clamp(value, min, max) {
47
74
  return Math.min(Math.max(value, min), max);
48
75
  }
76
+
77
+ // src/ra.ts
78
+ function chain(...callbacks) {
79
+ return (...args) => {
80
+ for (const callback of callbacks) {
81
+ if (typeof callback === "function") {
82
+ callback(...args);
83
+ }
84
+ }
85
+ };
86
+ }
49
87
  // Annotate the CommonJS export names for ESM import in node:
50
88
  0 && (module.exports = {
89
+ ariaAttr,
90
+ chain,
51
91
  clamp,
52
92
  cn,
53
93
  dataAttr,
54
- getUniqueID
94
+ getUniqueID,
95
+ isArray,
96
+ isEmpty,
97
+ isEmptyArray,
98
+ isEmptyObject,
99
+ isObject
55
100
  });
package/dist/index.mjs CHANGED
@@ -1,5 +1,25 @@
1
1
  // src/assertion.ts
2
+ function isArray(value) {
3
+ return Array.isArray(value);
4
+ }
5
+ function isEmptyArray(value) {
6
+ return isArray(value) && value.length === 0;
7
+ }
8
+ function isObject(value) {
9
+ const type = typeof value;
10
+ return value != null && (type === "object" || type === "function") && !isArray(value);
11
+ }
12
+ function isEmptyObject(value) {
13
+ return isObject(value) && Object.keys(value).length === 0;
14
+ }
15
+ function isEmpty(value) {
16
+ if (isArray(value)) return isEmptyArray(value);
17
+ if (isObject(value)) return isEmptyObject(value);
18
+ if (value == null || value === "") return true;
19
+ return false;
20
+ }
2
21
  var dataAttr = (condition) => condition ? "true" : void 0;
22
+ var ariaAttr = (condition) => condition ? "true" : void 0;
3
23
 
4
24
  // src/clsx.ts
5
25
  import { clsx } from "clsx";
@@ -17,9 +37,27 @@ function getUniqueID(prefix) {
17
37
  function clamp(value, min, max) {
18
38
  return Math.min(Math.max(value, min), max);
19
39
  }
40
+
41
+ // src/ra.ts
42
+ function chain(...callbacks) {
43
+ return (...args) => {
44
+ for (const callback of callbacks) {
45
+ if (typeof callback === "function") {
46
+ callback(...args);
47
+ }
48
+ }
49
+ };
50
+ }
20
51
  export {
52
+ ariaAttr,
53
+ chain,
21
54
  clamp,
22
55
  cn,
23
56
  dataAttr,
24
- getUniqueID
57
+ getUniqueID,
58
+ isArray,
59
+ isEmpty,
60
+ isEmptyArray,
61
+ isEmptyObject,
62
+ isObject
25
63
  };
package/dist/ra.d.mts ADDED
@@ -0,0 +1,7 @@
1
+ /** biome-ignore-all lint/suspicious/noExplicitAny: ulitities are allowed */
2
+ /**
3
+ * Calls all functions in the order they were chained with the same arguments.
4
+ */
5
+ declare function chain(...callbacks: any[]): (...args: any[]) => void;
6
+
7
+ export { chain };
package/dist/ra.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /** biome-ignore-all lint/suspicious/noExplicitAny: ulitities are allowed */
2
+ /**
3
+ * Calls all functions in the order they were chained with the same arguments.
4
+ */
5
+ declare function chain(...callbacks: any[]): (...args: any[]) => void;
6
+
7
+ export { chain };
package/dist/ra.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/ra.ts
21
+ var ra_exports = {};
22
+ __export(ra_exports, {
23
+ chain: () => chain
24
+ });
25
+ module.exports = __toCommonJS(ra_exports);
26
+ function chain(...callbacks) {
27
+ return (...args) => {
28
+ for (const callback of callbacks) {
29
+ if (typeof callback === "function") {
30
+ callback(...args);
31
+ }
32
+ }
33
+ };
34
+ }
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ chain
38
+ });
package/dist/ra.mjs ADDED
@@ -0,0 +1,13 @@
1
+ // src/ra.ts
2
+ function chain(...callbacks) {
3
+ return (...args) => {
4
+ for (const callback of callbacks) {
5
+ if (typeof callback === "function") {
6
+ callback(...args);
7
+ }
8
+ }
9
+ };
10
+ }
11
+ export {
12
+ chain
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kopexa/shared-utils",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A set of kopexa shared utilities",
5
5
  "keywords": [
6
6
  "system"