@budsbox/lib-es 1.0.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/README.md +1 -0
- package/dist/array.d.ts +43 -0
- package/dist/array.js +54 -0
- package/dist/guards.d.ts +145 -0
- package/dist/guards.js +135 -0
- package/dist/logical.d.ts +51 -0
- package/dist/logical.js +64 -0
- package/dist/object.d.ts +21 -0
- package/dist/object.js +47 -0
- package/dist/string.d.ts +88 -0
- package/dist/string.js +82 -0
- package/dist/types.d.ts +19 -0
- package/dist/types.js +2 -0
- package/package.json +113 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @budsbox/lib-es
|
package/dist/array.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures that the provided value is returned as an array. If the value is already an array,
|
|
3
|
+
* it is returned as-is. If the value is not an array, it is wrapped in a new array.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The value to be checked and converted into an array if necessary.
|
|
6
|
+
* @return An array containing the original value or the original array if it was already an array.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ensureArray<T>(value: T | readonly T[]): readonly T[];
|
|
9
|
+
export declare function ensureArray<T>(value: T | T[]): T[];
|
|
10
|
+
/**
|
|
11
|
+
* Removes duplicate elements from the provided array while preserving the order of the first occurrence of each element.
|
|
12
|
+
*
|
|
13
|
+
* @param items - The array of items from which duplicates should be removed.
|
|
14
|
+
* The array is expected to be read-only and can contain elements of any type.
|
|
15
|
+
* @returns A new array containing only the unique elements from the input array, in the order of their first occurrence.
|
|
16
|
+
*/
|
|
17
|
+
export declare const dedupe: <T>(items: readonly T[]) => T[];
|
|
18
|
+
/**
|
|
19
|
+
* Creates an array of unique values from the combined elements of the input arrays.
|
|
20
|
+
*
|
|
21
|
+
* @param arrays - The arrays to be merged and deduplicated.
|
|
22
|
+
* @return An array containing unique elements from all input arrays.
|
|
23
|
+
*/
|
|
24
|
+
export declare function union<T>(...arrays: ReadonlyArray<T | readonly T[]>): T[];
|
|
25
|
+
/**
|
|
26
|
+
* Computes the intersection of multiple arrays, returning an array that contains
|
|
27
|
+
* all elements that are present in every input array.
|
|
28
|
+
*
|
|
29
|
+
* @param arrays - A variadic parameter allowing multiple arrays or single elements.
|
|
30
|
+
* Each array or element will be checked for intersection.
|
|
31
|
+
* @returns An array containing elements that are present in all input arrays.
|
|
32
|
+
*/
|
|
33
|
+
export declare function intersection<T>(...arrays: ReadonlyArray<T | readonly T[]>): T[];
|
|
34
|
+
/**
|
|
35
|
+
* Computes the difference between a source array and one or more arrays of exclusions.
|
|
36
|
+
* Returns a new array containing elements from the source array that are not present in any of the exclusion arrays.
|
|
37
|
+
*
|
|
38
|
+
* @param source The source array to compare against.
|
|
39
|
+
* @param excludes Arrays containing elements to be excluded from the source array.
|
|
40
|
+
* @return A new array containing elements from the source array that are not in the exclusion arrays.
|
|
41
|
+
*/
|
|
42
|
+
export declare function diff<T>(source: readonly T[], ...excludes: ReadonlyArray<readonly T[]>): T[];
|
|
43
|
+
//# sourceMappingURL=array.d.ts.map
|
package/dist/array.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function ensureArray(value) {
|
|
2
|
+
return Array.isArray(value) ? value : [value];
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Removes duplicate elements from the provided array while preserving the order of the first occurrence of each element.
|
|
6
|
+
*
|
|
7
|
+
* @param items - The array of items from which duplicates should be removed.
|
|
8
|
+
* The array is expected to be read-only and can contain elements of any type.
|
|
9
|
+
* @returns A new array containing only the unique elements from the input array, in the order of their first occurrence.
|
|
10
|
+
*/
|
|
11
|
+
export const dedupe = (items) => Array.from(new Set(items));
|
|
12
|
+
/**
|
|
13
|
+
* Creates an array of unique values from the combined elements of the input arrays.
|
|
14
|
+
*
|
|
15
|
+
* @param arrays - The arrays to be merged and deduplicated.
|
|
16
|
+
* @return An array containing unique elements from all input arrays.
|
|
17
|
+
*/
|
|
18
|
+
export function union(...arrays) {
|
|
19
|
+
return dedupe(arrays.flatMap((v) => v));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Computes the intersection of multiple arrays, returning an array that contains
|
|
23
|
+
* all elements that are present in every input array.
|
|
24
|
+
*
|
|
25
|
+
* @param arrays - A variadic parameter allowing multiple arrays or single elements.
|
|
26
|
+
* Each array or element will be checked for intersection.
|
|
27
|
+
* @returns An array containing elements that are present in all input arrays.
|
|
28
|
+
*/
|
|
29
|
+
export function intersection(...arrays) {
|
|
30
|
+
const { length } = arrays;
|
|
31
|
+
const counters = new Map();
|
|
32
|
+
for (const array of arrays) {
|
|
33
|
+
for (const item of ensureArray(array)) {
|
|
34
|
+
const count = counters.get(item) ?? 0;
|
|
35
|
+
counters.set(item, count + 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return [...counters]
|
|
39
|
+
.filter(([, count]) => count === length)
|
|
40
|
+
.map(([item]) => item);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Computes the difference between a source array and one or more arrays of exclusions.
|
|
44
|
+
* Returns a new array containing elements from the source array that are not present in any of the exclusion arrays.
|
|
45
|
+
*
|
|
46
|
+
* @param source The source array to compare against.
|
|
47
|
+
* @param excludes Arrays containing elements to be excluded from the source array.
|
|
48
|
+
* @return A new array containing elements from the source array that are not in the exclusion arrays.
|
|
49
|
+
*/
|
|
50
|
+
export function diff(source, ...excludes) {
|
|
51
|
+
const set = new Set(excludes.flatMap((v) => v));
|
|
52
|
+
return source.filter((v) => !set.has(v));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=array.js.map
|
package/dist/guards.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Def, Nil, NonNil, Undef } from '@budsbox/lib-types';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the provided value is `undefined`.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The value to check for `undefined`.
|
|
6
|
+
* @return `true` if the value is `undefined`, otherwise `false`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isUndef(value: unknown): value is Undef;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a given value is defined (not `undefined`).
|
|
11
|
+
*
|
|
12
|
+
* @param value - The value to check.
|
|
13
|
+
* @return Whether the value is defined.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDef<U>(value: U): value is Def<U>;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the provided value is `null` or `undefined`.
|
|
18
|
+
*
|
|
19
|
+
* @param value - The value to be checked.
|
|
20
|
+
* @return Returns `true` if the value is `null` or `undefined`, otherwise `false`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isNil(value: unknown): value is Nil;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the provided value is not null or undefined.
|
|
25
|
+
*
|
|
26
|
+
* @param value - The value to be checked.
|
|
27
|
+
* @return Returns true if the value is not null or undefined; otherwise, false.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isNotNil<T>(value: T): value is NonNil<T>;
|
|
30
|
+
export declare function isNotNil(value: unknown): value is NonNil;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the provided value is strictly equal to true.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @return Returns true if the value is strictly true, otherwise false.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isTrue(value: unknown): value is true;
|
|
38
|
+
/**
|
|
39
|
+
* Determines if the provided value is strictly `false`.
|
|
40
|
+
*
|
|
41
|
+
* @param value - The value to be checked.
|
|
42
|
+
* @return Returns `true` if the value is `false`, otherwise returns `false`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isFalse(value: unknown): value is false;
|
|
45
|
+
/**
|
|
46
|
+
* Determines if the given value is truly, i.e., converts to true when used in a boolean context.
|
|
47
|
+
*
|
|
48
|
+
* @param value - The value to be tested for truthiness.
|
|
49
|
+
* @return Returns true if the value is truthy, false otherwise.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isTruly(value: unknown): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Determines if a given value is falsy.
|
|
54
|
+
* A value is considered falsy if it evaluates to false when coerced to a boolean.
|
|
55
|
+
*
|
|
56
|
+
* @param value The value to be tested.
|
|
57
|
+
* @return True if the value is falsy, otherwise false.
|
|
58
|
+
*/
|
|
59
|
+
export declare function isFalsy(value: unknown): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if the given value is an object.
|
|
62
|
+
*
|
|
63
|
+
* @param value - The value to check.
|
|
64
|
+
* @return True if the value is an object, false otherwise.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isObject(value: unknown): value is object;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if the provided value is a record.
|
|
69
|
+
*
|
|
70
|
+
* A record is considered an object where the keys are property keys,
|
|
71
|
+
* and the values can be any type. The function also checks whether
|
|
72
|
+
* empty records are allowed based on the specified flag.
|
|
73
|
+
*
|
|
74
|
+
* @param value - The value to check.
|
|
75
|
+
* @param allowEmpty - Determines whether empty records are allowed.
|
|
76
|
+
* @return A boolean indicating whether the value is a record.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isRecord(value: unknown, allowEmpty?: boolean): value is Record<PropertyKey, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Checks if the given value is an array.
|
|
81
|
+
*
|
|
82
|
+
* @template T - Type of the value to be checked.
|
|
83
|
+
* @param value - The value to check.
|
|
84
|
+
* @return True if the value is an array, otherwise false.
|
|
85
|
+
*/
|
|
86
|
+
export declare function isArray<T>(value: T | readonly T[]): value is readonly T[];
|
|
87
|
+
/**
|
|
88
|
+
* Checks if the provided value is an array.
|
|
89
|
+
*
|
|
90
|
+
* @template T - type of the value to be checked.
|
|
91
|
+
* @param value - The value to be checked.
|
|
92
|
+
* @return True if the value is an array, otherwise false.
|
|
93
|
+
*/
|
|
94
|
+
export declare function isArray<T>(value: T | T[]): value is T[];
|
|
95
|
+
/**
|
|
96
|
+
* Checks if the given value is an array.
|
|
97
|
+
*
|
|
98
|
+
* @param value - The value to be checked.
|
|
99
|
+
* @return Returns true if the value is an array, otherwise false.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isArray(value: unknown): value is unknown[];
|
|
102
|
+
/**
|
|
103
|
+
* Determines if the provided value is of type Function.
|
|
104
|
+
*
|
|
105
|
+
* @param value - The value to be checked.
|
|
106
|
+
* @return True if the value is a function; otherwise, false.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isFunction(value: unknown): value is CallableFunction;
|
|
109
|
+
/**
|
|
110
|
+
* Determines if the provided value is a string.
|
|
111
|
+
*
|
|
112
|
+
* @param value - The value to check.
|
|
113
|
+
* @return True if the value is a string, otherwise false.
|
|
114
|
+
*/
|
|
115
|
+
export declare function isString(value: unknown): value is string;
|
|
116
|
+
/**
|
|
117
|
+
* Checks if the provided value is a number and not NaN.
|
|
118
|
+
*
|
|
119
|
+
* @param value - The value to be checked.
|
|
120
|
+
* @return Returns true if the value is a number and not NaN, otherwise false.
|
|
121
|
+
*/
|
|
122
|
+
export declare function isNumber(value: unknown): value is number;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if the given value is of type boolean.
|
|
125
|
+
*
|
|
126
|
+
* @param value - The value to check.
|
|
127
|
+
* @return A boolean indicating whether the value is a boolean or not.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isBoolean(value: unknown): value is boolean;
|
|
130
|
+
export declare function hasProp(source: Nil, prop: PropertyKey, test?: (propValue: unknown) => boolean): false;
|
|
131
|
+
/**
|
|
132
|
+
* Checks if the given source has the specified property.
|
|
133
|
+
*
|
|
134
|
+
* @param source - The source to check for the property.
|
|
135
|
+
* @param prop - The property to check for existence.
|
|
136
|
+
* @return True if the source is an object and contains the property.
|
|
137
|
+
*/
|
|
138
|
+
export declare function hasProp<T, Key extends PropertyKey>(source: Record<PropertyKey, T>, prop: Key): source is Record<Key, T>;
|
|
139
|
+
export declare function hasProp<Key extends PropertyKey>(source: unknown, prop: Key): source is Record<Key, unknown>;
|
|
140
|
+
export declare function hasProp<T, Narrowed extends T, Key extends PropertyKey>(source: Record<PropertyKey, T>, prop: Key, test: (propValue: T) => propValue is Narrowed): source is Record<Key, Narrowed>;
|
|
141
|
+
export declare function hasProp<T, Narrowed, Key extends PropertyKey>(source: Record<PropertyKey, T>, prop: Key, test: (propValue: unknown) => propValue is Narrowed): source is Record<Key, T & Narrowed>;
|
|
142
|
+
export declare function hasProp<Key extends PropertyKey, T>(source: unknown, prop: Key, test: (propValue: unknown) => propValue is T): source is {
|
|
143
|
+
[K in Key]: T;
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=guards.d.ts.map
|
package/dist/guards.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the provided value is `undefined`.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The value to check for `undefined`.
|
|
5
|
+
* @return `true` if the value is `undefined`, otherwise `false`.
|
|
6
|
+
*/
|
|
7
|
+
export function isUndef(value) {
|
|
8
|
+
return value === undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a given value is defined (not `undefined`).
|
|
12
|
+
*
|
|
13
|
+
* @param value - The value to be checked.
|
|
14
|
+
* @return Returns true if the value is defined, otherwise false.
|
|
15
|
+
*/
|
|
16
|
+
export function isDef(value) {
|
|
17
|
+
return value !== undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks if the provided value is `null` or `undefined`.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The value to be checked.
|
|
23
|
+
* @return Returns `true` if the value is `null` or `undefined`, otherwise `false`.
|
|
24
|
+
*/
|
|
25
|
+
export function isNil(value) {
|
|
26
|
+
return value == null;
|
|
27
|
+
}
|
|
28
|
+
export function isNotNil(value) {
|
|
29
|
+
return !isNil(value);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Checks if the provided value is strictly equal to true.
|
|
33
|
+
*
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @return Returns true if the value is strictly true, otherwise false.
|
|
36
|
+
*/
|
|
37
|
+
export function isTrue(value) {
|
|
38
|
+
return value === true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Determines if the provided value is strictly `false`.
|
|
42
|
+
*
|
|
43
|
+
* @param value - The value to be checked.
|
|
44
|
+
* @return Returns `true` if the value is `false`, otherwise returns `false`.
|
|
45
|
+
*/
|
|
46
|
+
export function isFalse(value) {
|
|
47
|
+
return value === false;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Determines if the given value is truly, i.e., converts to true when used in a boolean context.
|
|
51
|
+
*
|
|
52
|
+
* @param value - The value to be tested for truthiness.
|
|
53
|
+
* @return Returns true if the value is truthy, false otherwise.
|
|
54
|
+
*/
|
|
55
|
+
export function isTruly(value) {
|
|
56
|
+
return Boolean(value);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Determines if a given value is falsy.
|
|
60
|
+
* A value is considered falsy if it evaluates to false when coerced to a boolean.
|
|
61
|
+
*
|
|
62
|
+
* @param value The value to be tested.
|
|
63
|
+
* @return True if the value is falsy, otherwise false.
|
|
64
|
+
*/
|
|
65
|
+
export function isFalsy(value) {
|
|
66
|
+
return !isTruly(value);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks if the given value is an object.
|
|
70
|
+
*
|
|
71
|
+
* @param value - The value to check.
|
|
72
|
+
* @return True if the value is an object, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
export function isObject(value) {
|
|
75
|
+
return value != null && typeof value === 'object';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Checks if the provided value is a record.
|
|
79
|
+
*
|
|
80
|
+
* A record is considered an object where the keys are property keys,
|
|
81
|
+
* and the values can be any type. The function also checks whether
|
|
82
|
+
* empty records are allowed based on the specified flag.
|
|
83
|
+
*
|
|
84
|
+
* @param value - The value to check.
|
|
85
|
+
* @param allowEmpty - Determines whether empty records are allowed.
|
|
86
|
+
* @return A boolean indicating whether the value is a record.
|
|
87
|
+
*/
|
|
88
|
+
export function isRecord(value, allowEmpty = false) {
|
|
89
|
+
return isObject(value) && (allowEmpty || Object.keys(value).length > 0);
|
|
90
|
+
}
|
|
91
|
+
export function isArray(value) {
|
|
92
|
+
return Array.isArray(value);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Determines if the provided value is of type Function.
|
|
96
|
+
*
|
|
97
|
+
* @param value - The value to be checked.
|
|
98
|
+
* @return True if the value is a function; otherwise, false.
|
|
99
|
+
*/
|
|
100
|
+
export function isFunction(value) {
|
|
101
|
+
return typeof value === 'function';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Determines if the provided value is a string.
|
|
105
|
+
*
|
|
106
|
+
* @param value - The value to check.
|
|
107
|
+
* @return True if the value is a string, otherwise false.
|
|
108
|
+
*/
|
|
109
|
+
export function isString(value) {
|
|
110
|
+
return typeof value === 'string';
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Checks if the provided value is a number and not NaN.
|
|
114
|
+
*
|
|
115
|
+
* @param value - The value to be checked.
|
|
116
|
+
* @return Returns true if the value is a number and not NaN, otherwise false.
|
|
117
|
+
*/
|
|
118
|
+
export function isNumber(value) {
|
|
119
|
+
return typeof value === 'number' && !Number.isNaN(value);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Checks if the given value is of type boolean.
|
|
123
|
+
*
|
|
124
|
+
* @param value - The value to check.
|
|
125
|
+
* @return A boolean indicating whether the value is a boolean or not.
|
|
126
|
+
*/
|
|
127
|
+
export function isBoolean(value) {
|
|
128
|
+
return typeof value === 'boolean';
|
|
129
|
+
}
|
|
130
|
+
export function hasProp(source, prop, test) {
|
|
131
|
+
return (isNotNil(source) &&
|
|
132
|
+
Object.hasOwn(source, prop) &&
|
|
133
|
+
(!isFunction(test) || test(source[prop])));
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { OnFalseParam, OnTrueParam, TestParam } from './types.js';
|
|
2
|
+
import { isNotNil, isTrue } from '#guards';
|
|
3
|
+
/**
|
|
4
|
+
* Functional If
|
|
5
|
+
*
|
|
6
|
+
* Evaluates a value with a given test and returns a value (or executes a function and returns it's result) based on the result.
|
|
7
|
+
*
|
|
8
|
+
* @typeParam TrueType - The type of the value or the return type of the function if the test's result is true.
|
|
9
|
+
* @typeParam FalseType - The type of the value or the return type of the function if the test's result is true, defaults to undefined.
|
|
10
|
+
*
|
|
11
|
+
* @param value - The value to test against the provided test function.
|
|
12
|
+
* @param test - A function to evaluate the provided value.
|
|
13
|
+
* @param onTrue - A function or value to execute or return if the test evaluates to true.
|
|
14
|
+
* @param onFalse - A function or value to execute or return if the test evaluates to false.
|
|
15
|
+
* @return The value or the result of the function based on the test result
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const result1 = fif(10, (n) => n > 5, 'Greater', 'Smaller');
|
|
20
|
+
* // result1 is 'Greater'
|
|
21
|
+
*
|
|
22
|
+
* const result2 = fif(3, (n) => n > 5, (n) => `Above ${n}`, (n) => `Below ${n}`);
|
|
23
|
+
* // result2 is 'Below 3'
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function fif<ValueType, TestParamType extends TestParam<ValueType>, TrueType, FalseType = undefined>(value: ValueType, test: TestParamType, onTrue: OnTrueParam<ValueType, TestParamType, TrueType>, onFalse?: OnFalseParam<ValueType, TestParamType, FalseType>): TrueType | FalseType;
|
|
27
|
+
/**
|
|
28
|
+
* Functional If (Static)
|
|
29
|
+
*
|
|
30
|
+
* Evaluates a condition and returns a value or executes a function based on the result.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam TrueType - The type of the value or the return type of the function if the condition is true.
|
|
33
|
+
* @typeParam FalseType - The type of the value or the return type of the function if the condition is false, defaults to null.
|
|
34
|
+
*
|
|
35
|
+
* @param condition - The condition to evaluate.
|
|
36
|
+
* @param onTrue - The value or function to return/execute if the condition is true. If it's a function, it receives `true` as an argument.
|
|
37
|
+
* @param onFalse - The value or function to return/execute if the condition is false. If it's a function, it receives `false` as an argument.
|
|
38
|
+
* @return The value or the result of the function based on the evaluated condition.
|
|
39
|
+
*/
|
|
40
|
+
export declare function fifs<TrueType, FalseType = undefined>(condition: boolean, onTrue: OnTrueParam<boolean, typeof isTrue, TrueType>, onFalse?: OnFalseParam<boolean, typeof isTrue, FalseType>): TrueType | FalseType;
|
|
41
|
+
/**
|
|
42
|
+
* Ensures that the provided value is not null or undefined,
|
|
43
|
+
* and returns a value (or executes a function and returns it's result) based on the result.
|
|
44
|
+
*
|
|
45
|
+
* @param value - The value to be checked.
|
|
46
|
+
* @param onTrue - Callback function to be executed if the value is not null or undefined.
|
|
47
|
+
* @param onFalse - (Optional) Callback function to be executed if the value is null or undefined.
|
|
48
|
+
* @return The result of the appropriate callback function based on the evaluation of the value.
|
|
49
|
+
*/
|
|
50
|
+
export declare function sure<ValueType, TrueType, FalseType = undefined>(value: ValueType, onTrue: OnTrueParam<ValueType, typeof isNotNil, TrueType>, onFalse?: OnFalseParam<ValueType, typeof isNotNil, FalseType>): TrueType | FalseType;
|
|
51
|
+
//# sourceMappingURL=logical.d.ts.map
|
package/dist/logical.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isFunction, isNotNil, isTrue } from '#guards';
|
|
2
|
+
/**
|
|
3
|
+
* Functional If
|
|
4
|
+
*
|
|
5
|
+
* Evaluates a value with a given test and returns a value (or executes a function and returns it's result) based on the result.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam TrueType - The type of the value or the return type of the function if the test's result is true.
|
|
8
|
+
* @typeParam FalseType - The type of the value or the return type of the function if the test's result is true, defaults to undefined.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The value to test against the provided test function.
|
|
11
|
+
* @param test - A function to evaluate the provided value.
|
|
12
|
+
* @param onTrue - A function or value to execute or return if the test evaluates to true.
|
|
13
|
+
* @param onFalse - A function or value to execute or return if the test evaluates to false.
|
|
14
|
+
* @return The value or the result of the function based on the test result
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const result1 = fif(10, (n) => n > 5, 'Greater', 'Smaller');
|
|
19
|
+
* // result1 is 'Greater'
|
|
20
|
+
*
|
|
21
|
+
* const result2 = fif(3, (n) => n > 5, (n) => `Above ${n}`, (n) => `Below ${n}`);
|
|
22
|
+
* // result2 is 'Below 3'
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function fif(value, test, onTrue, onFalse) {
|
|
26
|
+
if (test(value)) {
|
|
27
|
+
return isFunction(onTrue) ?
|
|
28
|
+
onTrue(value)
|
|
29
|
+
: onTrue;
|
|
30
|
+
}
|
|
31
|
+
if (isFunction(onFalse)) {
|
|
32
|
+
return onFalse(value);
|
|
33
|
+
}
|
|
34
|
+
return onFalse;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Functional If (Static)
|
|
38
|
+
*
|
|
39
|
+
* Evaluates a condition and returns a value or executes a function based on the result.
|
|
40
|
+
*
|
|
41
|
+
* @typeParam TrueType - The type of the value or the return type of the function if the condition is true.
|
|
42
|
+
* @typeParam FalseType - The type of the value or the return type of the function if the condition is false, defaults to null.
|
|
43
|
+
*
|
|
44
|
+
* @param condition - The condition to evaluate.
|
|
45
|
+
* @param onTrue - The value or function to return/execute if the condition is true. If it's a function, it receives `true` as an argument.
|
|
46
|
+
* @param onFalse - The value or function to return/execute if the condition is false. If it's a function, it receives `false` as an argument.
|
|
47
|
+
* @return The value or the result of the function based on the evaluated condition.
|
|
48
|
+
*/
|
|
49
|
+
export function fifs(condition, onTrue, onFalse) {
|
|
50
|
+
return fif(condition, isTrue, onTrue, onFalse);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Ensures that the provided value is not null or undefined,
|
|
54
|
+
* and returns a value (or executes a function and returns it's result) based on the result.
|
|
55
|
+
*
|
|
56
|
+
* @param value - The value to be checked.
|
|
57
|
+
* @param onTrue - Callback function to be executed if the value is not null or undefined.
|
|
58
|
+
* @param onFalse - (Optional) Callback function to be executed if the value is null or undefined.
|
|
59
|
+
* @return The result of the appropriate callback function based on the evaluation of the value.
|
|
60
|
+
*/
|
|
61
|
+
export function sure(value, onTrue, onFalse) {
|
|
62
|
+
return fif(value, isNotNil, onTrue, onFalse);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=logical.js.map
|
package/dist/object.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ConditionalExcept } from 'type-fest';
|
|
2
|
+
import type { OmitNilProps, Value } from '@budsbox/lib-types/object';
|
|
3
|
+
export declare function pick<T extends object, Keys extends PropertyKey = keyof T>(source: T, ...keys: readonly Keys[]): Pick<T, Keys & keyof T>;
|
|
4
|
+
export declare const pickStrict: <T extends object, Keys extends keyof T = keyof T>(source: T, ...keys: readonly Keys[]) => Pick<T, Keys>;
|
|
5
|
+
export declare function omit<T extends object, K extends PropertyKey>(source: T, ...keys: readonly K[]): Omit<T, K>;
|
|
6
|
+
export declare const omitStrict: <TSource extends object, TKey extends keyof TSource>(source: TSource, ...keys: readonly TKey[]) => Omit<TSource, TKey>;
|
|
7
|
+
export declare function filterBy<T, K extends string, R extends T>(value: Partial<Record<K, T>>, test: (value: T) => value is R): ConditionalExcept<Record<K, T>, R>;
|
|
8
|
+
export declare function filterBy<T, K extends string, R extends T>(value: Partial<Record<K, T>> | Record<K, T>, test: (value: T) => value is R): ConditionalExcept<Record<K, T>, R>;
|
|
9
|
+
export declare function filterBy<V extends object>(obj: V, filter: (value: V[keyof V], key: keyof V, obj: V) => boolean): Partial<V>;
|
|
10
|
+
export declare function omitNils<T extends object>(object: T): OmitNilProps<T>;
|
|
11
|
+
export declare function reduce<U>(obj: Readonly<Record<string, unknown>>, callback: (previousValue: U, currentValue: Value<typeof obj>, currentKey: keyof typeof obj, object: typeof obj) => U, initialValue: Partial<U>): U;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the first key of the given object.
|
|
14
|
+
* Useful when working with objects that have only one key.
|
|
15
|
+
*
|
|
16
|
+
* @param value
|
|
17
|
+
*/
|
|
18
|
+
export declare function getKey<T extends string>(value: Record<T, unknown>): T;
|
|
19
|
+
export declare function getKey<T extends string>(value: Partial<Record<T, unknown>>): T | undefined;
|
|
20
|
+
export declare function getKey<T extends object>(value: T): keyof T;
|
|
21
|
+
//# sourceMappingURL=object.d.ts.map
|
package/dist/object.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { isNotNil } from '#guards';
|
|
2
|
+
export function pick(source, ...keys) {
|
|
3
|
+
return keys.reduce((acc, key) => Object.hasOwn(source, key) ? { ...acc, [key]: source[key] } : acc, {});
|
|
4
|
+
}
|
|
5
|
+
export const pickStrict = pick;
|
|
6
|
+
export function omit(source, ...keys) {
|
|
7
|
+
const keySet = new Set(keys);
|
|
8
|
+
return Object.fromEntries(Object.entries(source).filter(([key]) => !keySet.has(key)));
|
|
9
|
+
}
|
|
10
|
+
export const omitStrict = omit;
|
|
11
|
+
export function filterBy(obj, filter) {
|
|
12
|
+
const newObj = {};
|
|
13
|
+
for (const key in obj) {
|
|
14
|
+
if (!Object.hasOwn(obj, key)) {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
const value = obj[key];
|
|
18
|
+
if (filter(value, key, obj)) {
|
|
19
|
+
newObj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return newObj;
|
|
23
|
+
}
|
|
24
|
+
export function omitNils(object) {
|
|
25
|
+
return filterBy(object, isNotNil);
|
|
26
|
+
}
|
|
27
|
+
export function reduce(obj, callback, initialValue) {
|
|
28
|
+
return Object.entries(obj).reduce((acc, [key, value]) => callback(acc, value, key, obj), initialValue);
|
|
29
|
+
}
|
|
30
|
+
export function getKey(value) {
|
|
31
|
+
for (const key in value) {
|
|
32
|
+
if (Object.hasOwn(value, key)) {
|
|
33
|
+
return key;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
/*
|
|
37
|
+
Modern JS interpreters in the for..in loop
|
|
38
|
+
first traverse the object's own properties,
|
|
39
|
+
and then the inherited ones. Therefore, you can end the loop
|
|
40
|
+
if the own property has never been encountered
|
|
41
|
+
*/
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=object.js.map
|
package/dist/string.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { CamelCase, DelimiterCase, KebabCase, PascalCase, SnakeCase } from 'type-fest';
|
|
2
|
+
import type { Nil } from '@budsbox/lib-types';
|
|
3
|
+
import type { ParsedPackageName } from './types.js';
|
|
4
|
+
export type { ParsedPackageName };
|
|
5
|
+
/**
|
|
6
|
+
* Parses a package name string to extract its scope and name.
|
|
7
|
+
*
|
|
8
|
+
* @param packageName - The full name of the package, potentially including a scope.
|
|
9
|
+
* @param clean - A flag indicating whether to return a cleaned version (i.e., without a leading `@` and trailing `/`) of the scope. Defaults to false.
|
|
10
|
+
* @return An object containing the parsed scope and name of the package. The scope will be `null` if no scope is present.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parsePackageName(packageName: string, clean?: boolean): Required<ParsedPackageName>;
|
|
13
|
+
/**
|
|
14
|
+
* Converts a ParsedPackageName object into its string representation.
|
|
15
|
+
*
|
|
16
|
+
* @param parsedPackageName - An object representing the parsed package name with fields such as `scope` and `name`.
|
|
17
|
+
* @returns The string representation of the package name, including the scope if it exists.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stringifyPackageName(parsedPackageName: Readonly<ParsedPackageName>): string;
|
|
20
|
+
/**
|
|
21
|
+
* Converts a parsed package name object or a Nil value into a string representation.
|
|
22
|
+
*
|
|
23
|
+
* @param parsedPackageName - A parsed package name object of type `ParsedPackageName` or a Nil value.
|
|
24
|
+
* @param allowNil - A boolean flag specifying whether Nil values are allowed for conversion.
|
|
25
|
+
* @return The string representation of the package name if valid, or an empty string if `allowNil` is true and the input is Nil.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stringifyPackageName(parsedPackageName: Readonly<ParsedPackageName> | Nil, allowNil: true): string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the string representation of the given value.
|
|
30
|
+
* Useful for debugging purposes.
|
|
31
|
+
*
|
|
32
|
+
* @param value
|
|
33
|
+
*/
|
|
34
|
+
export declare function debugString(value: unknown): string;
|
|
35
|
+
/**
|
|
36
|
+
* Trims leading and trailing whitespace from the input string and collapses
|
|
37
|
+
* multiple consecutive whitespace characters into a single space.
|
|
38
|
+
*
|
|
39
|
+
* @param str - The input string to be processed.
|
|
40
|
+
* @returns The processed string with trimmed and normalized whitespace.
|
|
41
|
+
*/
|
|
42
|
+
export declare function clampWS(str: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Joins multiple parts of a path into a single string.
|
|
45
|
+
* It ensures that there are no duplicate slashes between the parts
|
|
46
|
+
* and trims leading/trailing slashes where necessary.
|
|
47
|
+
*
|
|
48
|
+
* @param parts - An array of path parts to join. Each part can be a string, number, boolean, null, or undefined. Non-string values will be stringified, and null/undefined values are ignored.
|
|
49
|
+
* @returns The combined path as a single string, with proper slash formatting.
|
|
50
|
+
*/
|
|
51
|
+
export declare function joinPath(...parts: ReadonlyArray<string | number | boolean | null | undefined>): string;
|
|
52
|
+
/**
|
|
53
|
+
* Transforms a given string into camelCase format.
|
|
54
|
+
*
|
|
55
|
+
* @param str - The string to be converted to camelCase.
|
|
56
|
+
* @returns The input string transformed into camelCase.
|
|
57
|
+
*/
|
|
58
|
+
export declare function camelCase<T extends string>(str: T): CamelCase<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Converts a given string to PascalCase format.
|
|
61
|
+
*
|
|
62
|
+
* @param str - The string to be transformed into PascalCase.
|
|
63
|
+
* @returns The transformed string in PascalCase format.
|
|
64
|
+
*/
|
|
65
|
+
export declare function pascalCase<T extends string>(str: T): PascalCase<T>;
|
|
66
|
+
/**
|
|
67
|
+
* Converts a given string to a delimited case using the specified delimiter.
|
|
68
|
+
*
|
|
69
|
+
* @param name - The input string that will be converted to the delimited case.
|
|
70
|
+
* @param delimiter - The character or string to use as a delimiter in the transformed output.
|
|
71
|
+
* @returns The input string transformed into the delimited case format using the given delimiter.
|
|
72
|
+
*/
|
|
73
|
+
export declare function delimCase<T extends string, D extends string>(name: T, delimiter: D): DelimiterCase<T, D>;
|
|
74
|
+
/**
|
|
75
|
+
* Converts a given string to kebab-case format.
|
|
76
|
+
*
|
|
77
|
+
* @param name - The string input to be converted to kebab-case. The input should be a string type.
|
|
78
|
+
* @returns The transformed string in kebab-case format.
|
|
79
|
+
*/
|
|
80
|
+
export declare function kebabCase<T extends string>(name: T): KebabCase<T>;
|
|
81
|
+
/**
|
|
82
|
+
* Converts a given string to snake_case format.
|
|
83
|
+
*
|
|
84
|
+
* @param name - The string to be converted to snake_case.
|
|
85
|
+
* @returns The converted string in snake_case format.
|
|
86
|
+
*/
|
|
87
|
+
export declare function snakeCase<T extends string>(name: T): SnakeCase<T>;
|
|
88
|
+
//# sourceMappingURL=string.d.ts.map
|
package/dist/string.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { isNil, isNotNil, isString } from '#guards';
|
|
2
|
+
/**
|
|
3
|
+
* Parses a package name string to extract its scope and name.
|
|
4
|
+
*
|
|
5
|
+
* @param packageName - The full name of the package, potentially including a scope.
|
|
6
|
+
* @param clean - A flag indicating whether to return a cleaned version (i.e., without a leading `@` and trailing `/`) of the scope. Defaults to false.
|
|
7
|
+
* @return An object containing the parsed scope and name of the package. The scope will be `null` if no scope is present.
|
|
8
|
+
*/
|
|
9
|
+
export function parsePackageName(packageName, clean = false) {
|
|
10
|
+
const [scope, cleanScope] = /^@([^/]+)\//.exec(packageName) ?? [null, null];
|
|
11
|
+
return {
|
|
12
|
+
scope: clean ? cleanScope : scope,
|
|
13
|
+
name: packageName.replace(scope ?? '', ''),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function stringifyPackageName(parsedPackageName, allowNil = false) {
|
|
17
|
+
if (!allowNil && isNil(parsedPackageName)) {
|
|
18
|
+
throw new TypeError('Expected a non-nil value');
|
|
19
|
+
}
|
|
20
|
+
const { scope, name } = parsedPackageName ?? { scope: null, name: '' };
|
|
21
|
+
return isString(scope) ?
|
|
22
|
+
[scope.replace(/^@?([^]+)\/?$/, '@$1'), name].join('/')
|
|
23
|
+
: name;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the string representation of the given value.
|
|
27
|
+
* Useful for debugging purposes.
|
|
28
|
+
*
|
|
29
|
+
* @param value
|
|
30
|
+
*/
|
|
31
|
+
export function debugString(value) {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.stringify(value);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return String(value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Trims leading and trailing whitespace from the input string and collapses
|
|
41
|
+
* multiple consecutive whitespace characters into a single space.
|
|
42
|
+
*
|
|
43
|
+
* @param str - The input string to be processed.
|
|
44
|
+
* @returns The processed string with trimmed and normalized whitespace.
|
|
45
|
+
*/
|
|
46
|
+
export function clampWS(str) {
|
|
47
|
+
return str.trim().replace(/\s+/g, ' ');
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Joins multiple parts of a path into a single string.
|
|
51
|
+
* It ensures that there are no duplicate slashes between the parts
|
|
52
|
+
* and trims leading/trailing slashes where necessary.
|
|
53
|
+
*
|
|
54
|
+
* @param parts - An array of path parts to join. Each part can be a string, number, boolean, null, or undefined. Non-string values will be stringified, and null/undefined values are ignored.
|
|
55
|
+
* @returns The combined path as a single string, with proper slash formatting.
|
|
56
|
+
*/
|
|
57
|
+
export function joinPath(...parts) {
|
|
58
|
+
return parts
|
|
59
|
+
.filter(isNotNil)
|
|
60
|
+
.reduce((acc, part) => acc.length === 0 ?
|
|
61
|
+
String(part)
|
|
62
|
+
: `${acc.replace(/\/+$/, '')}/${String(part).replace(/^\/+/, '')}`, '');
|
|
63
|
+
}
|
|
64
|
+
export function camelCase(name) {
|
|
65
|
+
return clampWS(name).replace(/[-_\s]+([^-_\s])/g, (_, suffix) => suffix.toUpperCase());
|
|
66
|
+
}
|
|
67
|
+
export function pascalCase(name) {
|
|
68
|
+
return camelCase(name).replace(/^./, (c) => c.toUpperCase());
|
|
69
|
+
}
|
|
70
|
+
export function delimCase(name, delimiter = '-') {
|
|
71
|
+
return clampWS(name)
|
|
72
|
+
.replace(/(.)([A-Z])/g, `$1${delimiter}$2`)
|
|
73
|
+
.replace(/[-_\s]+/g, delimiter)
|
|
74
|
+
.toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
export function kebabCase(name) {
|
|
77
|
+
return delimCase(name, '-');
|
|
78
|
+
}
|
|
79
|
+
export function snakeCase(name) {
|
|
80
|
+
return delimCase(name, '_');
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=string.js.map
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `FValue` type represents a union type that can be either a value of type `T` or a function
|
|
3
|
+
* that takes a parameter of type `A` and returns a value of type `T`.
|
|
4
|
+
*
|
|
5
|
+
* @template A - The type of the parameter for the function.
|
|
6
|
+
* @template T - The type of the value or the return type of the function.
|
|
7
|
+
*/
|
|
8
|
+
export type FValue<A, T> = T | ((value: A) => T);
|
|
9
|
+
export type TypeGuard<T, V extends T> = (value: T) => value is V;
|
|
10
|
+
export type TestFn<T> = (value: T) => boolean;
|
|
11
|
+
export type TestParam<ValueType = any, NarrowedType extends ValueType = ValueType> = TypeGuard<ValueType, NarrowedType> | TestFn<ValueType>;
|
|
12
|
+
export type TestResultType<ValueType, TestType extends TestParam, BranchType extends boolean> = TestType extends TypeGuard<unknown, infer NarrowedType> ? BranchType extends true ? Extract<ValueType, NarrowedType> : Exclude<ValueType, NarrowedType> : TestType extends TestFn<infer OriginalType> ? OriginalType : never;
|
|
13
|
+
export type OnTrueParam<ValueType, TestType extends TestParam, ReturnType> = FValue<TestResultType<ValueType, TestType, true>, ReturnType>;
|
|
14
|
+
export type OnFalseParam<ValueType, TestType extends TestParam, ReturnType> = FValue<TestResultType<ValueType, TestType, false>, ReturnType>;
|
|
15
|
+
export interface ParsedPackageName {
|
|
16
|
+
scope?: string | null;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@budsbox/lib-es",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"homepage": "https://gitlab.com/budsbox/fe/seed",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://gitlab.com/budsbox/fe/seed/-/issues"
|
|
7
|
+
},
|
|
8
|
+
"repository": "gitlab:budsbox/fe/seed",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Konstantin Kutsyllo <trikadin@pm.me>",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"imports": {
|
|
13
|
+
"#package.json": "./package.json",
|
|
14
|
+
"#array": {
|
|
15
|
+
"import": {
|
|
16
|
+
"default": "./dist/array.js",
|
|
17
|
+
"types": "./dist/array.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"#object": {
|
|
21
|
+
"import": {
|
|
22
|
+
"default": "./dist/object.js",
|
|
23
|
+
"types": "./dist/object.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"#string": {
|
|
27
|
+
"import": {
|
|
28
|
+
"default": "./dist/string.js",
|
|
29
|
+
"types": "./dist/string.d.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"#guards": {
|
|
33
|
+
"import": {
|
|
34
|
+
"default": "./dist/guards.js",
|
|
35
|
+
"types": "./dist/guards.d.ts"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"#logical": {
|
|
39
|
+
"import": {
|
|
40
|
+
"default": "./dist/logical.js",
|
|
41
|
+
"types": "./dist/logical.d.ts"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
"./array": {
|
|
47
|
+
"import": {
|
|
48
|
+
"default": "./dist/array.js",
|
|
49
|
+
"types": "./dist/array.d.ts"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"./object": {
|
|
53
|
+
"import": {
|
|
54
|
+
"default": "./dist/object.js",
|
|
55
|
+
"types": "./dist/object.d.ts"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"./string": {
|
|
59
|
+
"import": {
|
|
60
|
+
"default": "./dist/string.js",
|
|
61
|
+
"types": "./dist/string.d.ts"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"./guards": {
|
|
65
|
+
"import": {
|
|
66
|
+
"default": "./dist/guards.js",
|
|
67
|
+
"types": "./dist/guards.d.ts"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./logical": {
|
|
71
|
+
"import": {
|
|
72
|
+
"default": "./dist/logical.js",
|
|
73
|
+
"types": "./dist/logical.d.ts"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"./package.json": "./package.json"
|
|
77
|
+
},
|
|
78
|
+
"files": [
|
|
79
|
+
"dist/**/*.d.ts",
|
|
80
|
+
"dist/**/*.js"
|
|
81
|
+
],
|
|
82
|
+
"scripts": {
|
|
83
|
+
"name": "echo $npm_package_name",
|
|
84
|
+
"prepack": "yarn p:ts:prepack"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@budsbox/lib-types": "^1.0.0",
|
|
88
|
+
"tslib": "^2.8.1",
|
|
89
|
+
"type-fest": "^4.32.0"
|
|
90
|
+
},
|
|
91
|
+
"devDependencies": {
|
|
92
|
+
"@budsbox/eslint": "^1.0.0",
|
|
93
|
+
"@budsbox/eslint_presets-lib": "^1.0.0",
|
|
94
|
+
"@budsbox/eslint_presets-tools": "^1.0.0",
|
|
95
|
+
"@budsbox/tsconfigs": "^4.0.0",
|
|
96
|
+
"@eslint/js": "^9.26.0",
|
|
97
|
+
"@types/eslint": "^9.6.1",
|
|
98
|
+
"@types/node": "^22.15.2",
|
|
99
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
100
|
+
"eslint": "^9.26.0",
|
|
101
|
+
"eslint-config-prettier": "^10.1.5",
|
|
102
|
+
"eslint-import-resolver-typescript": "^4.3.4",
|
|
103
|
+
"eslint-plugin-import-x": "^4.11.1",
|
|
104
|
+
"eslint-plugin-jsdoc": "^50.6.17",
|
|
105
|
+
"eslint-plugin-react": "^7.37.5",
|
|
106
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
107
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
108
|
+
"globals": "^16.1.0",
|
|
109
|
+
"typescript": "^5.8.3",
|
|
110
|
+
"typescript-eslint": "^8.32.1"
|
|
111
|
+
},
|
|
112
|
+
"packageManager": "yarn@4.9.2"
|
|
113
|
+
}
|