@wopjs/cast 0.1.11 → 0.1.13

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/dist/index.d.mts CHANGED
@@ -1,11 +1,11 @@
1
- type _ = undefined;
2
1
  /** Returns `U` if `T` is `never` or `any`, otherwise returns `T`. */
3
2
  type SetDefaultType<T, U> = [T, U][T extends any ? (0 extends 1 & T ? 1 : 0) : 1];
3
+ type Defined<T> = Exclude<T, undefined>;
4
4
  /** Returns `true` if `x` is not `undefined`. */
5
- declare const isDefined: <T>(x: T | _) => x is Exclude<T, _>;
5
+ declare const isDefined: <T>(x: T | undefined) => x is Defined<T>;
6
6
  declare const isTrue: (x: unknown) => x is true;
7
7
  /** Returns `true` if `x` is `true`, otherwise returns `undefined`. */
8
- declare const toTrue: (x: unknown) => true | _;
8
+ declare const toTrue: (x: unknown) => true | undefined;
9
9
  /** Returns `true` if `x` is `true`, otherwise returns `false`. */
10
10
  declare const asTrue: (x: unknown) => boolean;
11
11
  type Falsy = false | null | undefined | 0 | "";
@@ -13,46 +13,47 @@ type ExtractFalsy<T> = SetDefaultType<Extract<T, Falsy>, Falsy>;
13
13
  /** Returns `true` if `Boolean(x)` is `false`. */
14
14
  declare const isFalsy: <T>(x: T) => x is ExtractFalsy<T>;
15
15
  /** Returns `x` if `Boolean(x)` is `false`, otherwise returns `undefined`. */
16
- declare const toFalsy: <T>(x: T) => ExtractFalsy<T> | _;
16
+ declare const toFalsy: <T>(x: T) => ExtractFalsy<T> | undefined;
17
+ type Truthy<T> = Exclude<T, Falsy>;
17
18
  /** Returns `true` if `Boolean(x)` is `true`. */
18
- declare const isTruthy: <T>(x: T) => x is Exclude<T, Falsy>;
19
+ declare const isTruthy: <T>(x: T) => x is Truthy<T>;
19
20
  /** Returns `x` if `Boolean(x)` is `true`, otherwise returns `undefined`. */
20
- declare const toTruthy: <T>(x: T) => Exclude<T, Falsy> | _;
21
+ declare const toTruthy: <T>(x: T) => Truthy<T> | undefined;
21
22
  declare const isBoolean: (x: unknown) => x is boolean;
22
23
  /** Returns `x` if `x` is `true` or `false`, otherwise returns `undefined`. */
23
- declare const toBoolean: (x: unknown) => boolean | _;
24
+ declare const toBoolean: (x: unknown) => boolean | undefined;
24
25
  /** Returns `true` if `x` is a number, returns `false` if `x` is `NaN` or other value. */
25
26
  declare const isNumber: (x: unknown) => x is number;
26
27
  /** Returns `x` if `x` is a number, `NaN` and other value will be coerced to `undefined`. */
27
- declare const toNumber: (x: unknown) => number | _;
28
+ declare const toNumber: (x: unknown) => number | undefined;
28
29
  /** Returns `x` if `x` is a number, `NaN` and other value will be coerced to `0`. */
29
30
  declare const asNumber: (x: unknown) => number;
30
31
  /** Returns `true` if `x` is a string. */
31
32
  declare const isString: (x: unknown) => x is string;
32
33
  /** Returns `x` if `x` is a string, otherwise returns `undefined`. */
33
- declare const toString: (x: unknown) => string | _;
34
+ declare const toString: (x: unknown) => string | undefined;
34
35
  /** Returns `x` if `x` is a string, otherwise returns `''` (empty string). */
35
36
  declare const asString: (x: unknown) => string;
36
37
  /** Returns `true` if `x` is a string and not `''`. */
37
38
  declare const isNonEmptyString: (x: unknown) => x is string;
38
39
  /** Returns `x` if `x` is a string and not empty, otherwise returns `undefined`. */
39
- declare const toNonEmptyString: (x: unknown) => string | _;
40
+ declare const toNonEmptyString: (x: unknown) => string | undefined;
40
41
  /** Extracts array type from `T`, or `unknown[]` if no array type found. */
41
42
  type ExtractArray<T> = SetDefaultType<Extract<T, readonly unknown[]>, unknown[]>;
42
43
  declare const isArray: <T>(x: T) => x is ExtractArray<T>;
43
44
  /** Returns `x` if `x` is an array. */
44
- declare const toArray: <T>(x: T) => ExtractArray<T> | _;
45
+ declare const toArray: <T>(x: T) => ExtractArray<T> | undefined;
45
46
  /** Returns `x` if `x` is an array, otherwise returns `[]` (empty array). */
46
47
  declare const asArray: <T>(x: T) => ExtractArray<T>;
47
48
  /** Returns `true` if `x` is an array and has at least one element. */
48
49
  declare const isNonEmptyArray: <T>(x: T) => x is ExtractArray<T>;
49
50
  /** Returns `x` if `x` is an array and has at least one element, otherwise returns `undefined`. */
50
- declare const toNonEmptyArray: <T>(x: T) => ExtractArray<T> | _;
51
+ declare const toNonEmptyArray: <T>(x: T) => ExtractArray<T> | undefined;
51
52
  type ExtractObject<T> = SetDefaultType<Extract<T, object>, object>;
52
53
  /** Returns `true` if `x` is an object (including array) and not null. */
53
54
  declare const isObject: <T>(x: T) => x is ExtractObject<T>;
54
55
  /** Returns `x` if `x` is an object (including array). */
55
- declare const toObject: <T>(x: T) => ExtractObject<T> | _;
56
+ declare const toObject: <T>(x: T) => ExtractObject<T> | undefined;
56
57
  /** Returns `x` if `x` is an object (including array), otherwise returns `{}` (empty object). */
57
58
  declare const asObject: <T>(x: T) => ExtractObject<T>;
58
59
  interface PlainObject {
@@ -62,25 +63,25 @@ type ExtractPlainObject<T> = SetDefaultType<Exclude<Extract<T, object>, readonly
62
63
  /** Returns `true` if `x` is a plain object (shallow test), not `null` or array. */
63
64
  declare const isPlainObject: <T>(x: T) => x is ExtractPlainObject<T>;
64
65
  /** Returns `x` if `x` is a plain object. */
65
- declare const toPlainObject: <T>(x: T) => ExtractPlainObject<T> | _;
66
+ declare const toPlainObject: <T>(x: T) => ExtractPlainObject<T> | undefined;
66
67
  /** Returns `x` if `x` is a plain object, otherwise returns `{}` (empty object). */
67
68
  declare const asPlainObject: <T>(x: T) => ExtractPlainObject<T>;
68
69
  /** Returns `true` if `x` is a plain object and has at least one key. */
69
70
  declare const isNonEmptyPlainObject: <T>(x: T) => x is ExtractPlainObject<T>;
70
71
  /** Returns `x` if `x` is a plain object and has at least one key. */
71
- declare const toNonEmptyPlainObject: <T>(x: T) => ExtractPlainObject<T> | _;
72
+ declare const toNonEmptyPlainObject: <T>(x: T) => ExtractPlainObject<T> | undefined;
72
73
  /** Returns `true` if `x` is a plain object and has at least one key with non-undefined value. */
73
74
  declare const isNonEmptyJSONObject: <T>(x: T) => x is ExtractPlainObject<T>;
74
75
  /** Returns `x` if `x` is a plain object and has at least one key with non-undefined value, otherwise returns `undefined`. */
75
- declare const toNonEmptyJSONObject: <T>(x: T) => ExtractPlainObject<T> | _;
76
+ declare const toNonEmptyJSONObject: <T>(x: T) => ExtractPlainObject<T> | undefined;
76
77
  type ExtractPlainObjectValue<T> = ExtractPlainObject<T>[keyof ExtractPlainObject<T>];
77
78
  /**
78
79
  * Creates an object from `x` with keys `k` if `f(x[k])` returns `true`.
79
80
  * If `x` is not a plain object, or there's no passed props, returns `undefined`.
80
81
  */
81
- declare const toPlainObjectOf: <T, U extends ExtractPlainObjectValue<T>>(x: T, f: (v: ExtractPlainObjectValue<T>) => v is U) => Record<PropertyKey, U> | _;
82
+ declare const toPlainObjectOf: <T, U extends ExtractPlainObjectValue<T>>(x: T, f: (v: ExtractPlainObjectValue<T>) => v is U) => Record<PropertyKey, U> | undefined;
82
83
  /** Filter props from object `x` whose values are `true`. */
83
- declare const toPlainObjectOfTrue: (x: unknown) => Record<PropertyKey, true> | _;
84
+ declare const toPlainObjectOfTrue: (x: unknown) => Record<PropertyKey, true> | undefined;
84
85
  /**
85
86
  * Returns `x` if `x` is string, otherwise returns `''` (empty string) if
86
87
  * `x` is `null` or `undefined`, otherwise returns `JSON.stringify(x)`.
@@ -95,4 +96,43 @@ declare const returnsFalse: () => false;
95
96
  declare const returnsTrue: () => true;
96
97
  declare const returnsEmptyString: () => string;
97
98
 
98
- export { type ExtractArray, type ExtractFalsy, type ExtractObject, type ExtractPlainObject, type Falsy, type PlainObject, type SetDefaultType, type _, asArray, asNumber, asObject, asPlainObject, asString, asTrue, isArray, isBoolean, isDefined, isFalsy, isNonEmptyArray, isNonEmptyJSONObject, isNonEmptyPlainObject, isNonEmptyString, isNumber, isObject, isPlainObject, isString, isTrue, isTruthy, noop, print, returnsEmptyString, returnsFalse, returnsNull, returnsTrue, returnsUndefined, toArray, toBoolean, toFalsy, toNonEmptyArray, toNonEmptyJSONObject, toNonEmptyPlainObject, toNonEmptyString, toNumber, toObject, toPlainObject, toPlainObjectOf, toPlainObjectOfTrue, toString, toTrue, toTruthy };
99
+ /**
100
+ * Lazy filterMap that avoids creating a new array when possible.
101
+ *
102
+ * @returns the original array if `callbackfn` returns the same value for all items, otherwise a new array with the mapped items.
103
+ *
104
+ * @param arr
105
+ * @param callbackfn Return `undefined` to filter out the item, or return a value to map the item.
106
+ * @param thisArg
107
+ */
108
+ declare function inertFilterMap<T, U = T>(arr: T[], callbackfn: (value: T, index: number, arr: T[]) => U | undefined, thisArg?: any): Defined<U>[];
109
+ declare function inertFilterMap<T, U = T>(arr: T[] | undefined, callbackfn: (value: T, index: number, arr: T[]) => U | undefined, thisArg?: any): Defined<U>[] | undefined;
110
+ declare function inertFilterMap<T, U = T>(arr: readonly T[], callbackfn: (value: T, index: number, arr: readonly T[]) => U | undefined, thisArg?: any): readonly Defined<U>[];
111
+ declare function inertFilterMap<T, U = T>(arr: readonly T[] | undefined, callbackfn: (value: T, index: number, arr: readonly T[]) => U | undefined, thisArg?: any): readonly Defined<U>[] | undefined;
112
+ /**
113
+ * Lazy filter that avoids creating a new array when possible.
114
+ *
115
+ * @returns the original array if `predicate` returns `true` for all items, otherwise a new array with the filtered items.
116
+ *
117
+ * @param arr
118
+ * @param predicate Return `false` to filter out the item, or `true` to keep it.
119
+ * @param thisArg
120
+ */
121
+ declare function inertFilter<T, U extends T>(arr: T[], predicate: (value: T, index: number, arr: T[]) => value is U, thisArg?: any): U[];
122
+ declare function inertFilter<T, U extends T>(arr: T[] | undefined, predicate: (value: T, index: number, arr: T[]) => value is U, thisArg?: any): U[] | undefined;
123
+ declare function inertFilter<T, U extends T>(arr: readonly T[], predicate: (value: T, index: number, arr: readonly T[]) => value is U, thisArg?: any): readonly U[];
124
+ declare function inertFilter<T, U extends T>(arr: readonly T[] | undefined, predicate: (value: T, index: number, arr: readonly T[]) => value is U, thisArg?: any): readonly U[] | undefined;
125
+ declare function inertFilter<T>(arr: T[], predicate: (value: T, index: number, arr: T[]) => boolean, thisArg?: any): T[];
126
+ declare function inertFilter<T>(arr: T[] | undefined, predicate: (value: T, index: number, arr: T[]) => boolean, thisArg?: any): T[] | undefined;
127
+ declare function inertFilter<T>(arr: readonly T[], predicate: (value: T, index: number, arr: readonly T[]) => boolean, thisArg?: any): readonly T[];
128
+ declare function inertFilter<T>(arr: readonly T[] | undefined, predicate: (value: T, index: number, arr: readonly T[]) => boolean, thisArg?: any): readonly T[] | undefined;
129
+ interface Coalesce {
130
+ <T>(arr: T[]): Truthy<T>[];
131
+ <T>(arr: readonly T[]): readonly Truthy<T>[];
132
+ }
133
+ /**
134
+ * @returns the same array if all its items are truthy, otherwise a new array with all falsy items removed.
135
+ */
136
+ declare const coalesce: Coalesce;
137
+
138
+ export { type Coalesce, type Defined, type ExtractArray, type ExtractFalsy, type ExtractObject, type ExtractPlainObject, type Falsy, type PlainObject, type SetDefaultType, type Truthy, asArray, asNumber, asObject, asPlainObject, asString, asTrue, coalesce, inertFilter, inertFilterMap, isArray, isBoolean, isDefined, isFalsy, isNonEmptyArray, isNonEmptyJSONObject, isNonEmptyPlainObject, isNonEmptyString, isNumber, isObject, isPlainObject, isString, isTrue, isTruthy, noop, print, returnsEmptyString, returnsFalse, returnsNull, returnsTrue, returnsUndefined, toArray, toBoolean, toFalsy, toNonEmptyArray, toNonEmptyJSONObject, toNonEmptyPlainObject, toNonEmptyString, toNumber, toObject, toPlainObject, toPlainObjectOf, toPlainObjectOfTrue, toString, toTrue, toTruthy };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- type _ = undefined;
2
1
  /** Returns `U` if `T` is `never` or `any`, otherwise returns `T`. */
3
2
  type SetDefaultType<T, U> = [T, U][T extends any ? (0 extends 1 & T ? 1 : 0) : 1];
3
+ type Defined<T> = Exclude<T, undefined>;
4
4
  /** Returns `true` if `x` is not `undefined`. */
5
- declare const isDefined: <T>(x: T | _) => x is Exclude<T, _>;
5
+ declare const isDefined: <T>(x: T | undefined) => x is Defined<T>;
6
6
  declare const isTrue: (x: unknown) => x is true;
7
7
  /** Returns `true` if `x` is `true`, otherwise returns `undefined`. */
8
- declare const toTrue: (x: unknown) => true | _;
8
+ declare const toTrue: (x: unknown) => true | undefined;
9
9
  /** Returns `true` if `x` is `true`, otherwise returns `false`. */
10
10
  declare const asTrue: (x: unknown) => boolean;
11
11
  type Falsy = false | null | undefined | 0 | "";
@@ -13,46 +13,47 @@ type ExtractFalsy<T> = SetDefaultType<Extract<T, Falsy>, Falsy>;
13
13
  /** Returns `true` if `Boolean(x)` is `false`. */
14
14
  declare const isFalsy: <T>(x: T) => x is ExtractFalsy<T>;
15
15
  /** Returns `x` if `Boolean(x)` is `false`, otherwise returns `undefined`. */
16
- declare const toFalsy: <T>(x: T) => ExtractFalsy<T> | _;
16
+ declare const toFalsy: <T>(x: T) => ExtractFalsy<T> | undefined;
17
+ type Truthy<T> = Exclude<T, Falsy>;
17
18
  /** Returns `true` if `Boolean(x)` is `true`. */
18
- declare const isTruthy: <T>(x: T) => x is Exclude<T, Falsy>;
19
+ declare const isTruthy: <T>(x: T) => x is Truthy<T>;
19
20
  /** Returns `x` if `Boolean(x)` is `true`, otherwise returns `undefined`. */
20
- declare const toTruthy: <T>(x: T) => Exclude<T, Falsy> | _;
21
+ declare const toTruthy: <T>(x: T) => Truthy<T> | undefined;
21
22
  declare const isBoolean: (x: unknown) => x is boolean;
22
23
  /** Returns `x` if `x` is `true` or `false`, otherwise returns `undefined`. */
23
- declare const toBoolean: (x: unknown) => boolean | _;
24
+ declare const toBoolean: (x: unknown) => boolean | undefined;
24
25
  /** Returns `true` if `x` is a number, returns `false` if `x` is `NaN` or other value. */
25
26
  declare const isNumber: (x: unknown) => x is number;
26
27
  /** Returns `x` if `x` is a number, `NaN` and other value will be coerced to `undefined`. */
27
- declare const toNumber: (x: unknown) => number | _;
28
+ declare const toNumber: (x: unknown) => number | undefined;
28
29
  /** Returns `x` if `x` is a number, `NaN` and other value will be coerced to `0`. */
29
30
  declare const asNumber: (x: unknown) => number;
30
31
  /** Returns `true` if `x` is a string. */
31
32
  declare const isString: (x: unknown) => x is string;
32
33
  /** Returns `x` if `x` is a string, otherwise returns `undefined`. */
33
- declare const toString: (x: unknown) => string | _;
34
+ declare const toString: (x: unknown) => string | undefined;
34
35
  /** Returns `x` if `x` is a string, otherwise returns `''` (empty string). */
35
36
  declare const asString: (x: unknown) => string;
36
37
  /** Returns `true` if `x` is a string and not `''`. */
37
38
  declare const isNonEmptyString: (x: unknown) => x is string;
38
39
  /** Returns `x` if `x` is a string and not empty, otherwise returns `undefined`. */
39
- declare const toNonEmptyString: (x: unknown) => string | _;
40
+ declare const toNonEmptyString: (x: unknown) => string | undefined;
40
41
  /** Extracts array type from `T`, or `unknown[]` if no array type found. */
41
42
  type ExtractArray<T> = SetDefaultType<Extract<T, readonly unknown[]>, unknown[]>;
42
43
  declare const isArray: <T>(x: T) => x is ExtractArray<T>;
43
44
  /** Returns `x` if `x` is an array. */
44
- declare const toArray: <T>(x: T) => ExtractArray<T> | _;
45
+ declare const toArray: <T>(x: T) => ExtractArray<T> | undefined;
45
46
  /** Returns `x` if `x` is an array, otherwise returns `[]` (empty array). */
46
47
  declare const asArray: <T>(x: T) => ExtractArray<T>;
47
48
  /** Returns `true` if `x` is an array and has at least one element. */
48
49
  declare const isNonEmptyArray: <T>(x: T) => x is ExtractArray<T>;
49
50
  /** Returns `x` if `x` is an array and has at least one element, otherwise returns `undefined`. */
50
- declare const toNonEmptyArray: <T>(x: T) => ExtractArray<T> | _;
51
+ declare const toNonEmptyArray: <T>(x: T) => ExtractArray<T> | undefined;
51
52
  type ExtractObject<T> = SetDefaultType<Extract<T, object>, object>;
52
53
  /** Returns `true` if `x` is an object (including array) and not null. */
53
54
  declare const isObject: <T>(x: T) => x is ExtractObject<T>;
54
55
  /** Returns `x` if `x` is an object (including array). */
55
- declare const toObject: <T>(x: T) => ExtractObject<T> | _;
56
+ declare const toObject: <T>(x: T) => ExtractObject<T> | undefined;
56
57
  /** Returns `x` if `x` is an object (including array), otherwise returns `{}` (empty object). */
57
58
  declare const asObject: <T>(x: T) => ExtractObject<T>;
58
59
  interface PlainObject {
@@ -62,25 +63,25 @@ type ExtractPlainObject<T> = SetDefaultType<Exclude<Extract<T, object>, readonly
62
63
  /** Returns `true` if `x` is a plain object (shallow test), not `null` or array. */
63
64
  declare const isPlainObject: <T>(x: T) => x is ExtractPlainObject<T>;
64
65
  /** Returns `x` if `x` is a plain object. */
65
- declare const toPlainObject: <T>(x: T) => ExtractPlainObject<T> | _;
66
+ declare const toPlainObject: <T>(x: T) => ExtractPlainObject<T> | undefined;
66
67
  /** Returns `x` if `x` is a plain object, otherwise returns `{}` (empty object). */
67
68
  declare const asPlainObject: <T>(x: T) => ExtractPlainObject<T>;
68
69
  /** Returns `true` if `x` is a plain object and has at least one key. */
69
70
  declare const isNonEmptyPlainObject: <T>(x: T) => x is ExtractPlainObject<T>;
70
71
  /** Returns `x` if `x` is a plain object and has at least one key. */
71
- declare const toNonEmptyPlainObject: <T>(x: T) => ExtractPlainObject<T> | _;
72
+ declare const toNonEmptyPlainObject: <T>(x: T) => ExtractPlainObject<T> | undefined;
72
73
  /** Returns `true` if `x` is a plain object and has at least one key with non-undefined value. */
73
74
  declare const isNonEmptyJSONObject: <T>(x: T) => x is ExtractPlainObject<T>;
74
75
  /** Returns `x` if `x` is a plain object and has at least one key with non-undefined value, otherwise returns `undefined`. */
75
- declare const toNonEmptyJSONObject: <T>(x: T) => ExtractPlainObject<T> | _;
76
+ declare const toNonEmptyJSONObject: <T>(x: T) => ExtractPlainObject<T> | undefined;
76
77
  type ExtractPlainObjectValue<T> = ExtractPlainObject<T>[keyof ExtractPlainObject<T>];
77
78
  /**
78
79
  * Creates an object from `x` with keys `k` if `f(x[k])` returns `true`.
79
80
  * If `x` is not a plain object, or there's no passed props, returns `undefined`.
80
81
  */
81
- declare const toPlainObjectOf: <T, U extends ExtractPlainObjectValue<T>>(x: T, f: (v: ExtractPlainObjectValue<T>) => v is U) => Record<PropertyKey, U> | _;
82
+ declare const toPlainObjectOf: <T, U extends ExtractPlainObjectValue<T>>(x: T, f: (v: ExtractPlainObjectValue<T>) => v is U) => Record<PropertyKey, U> | undefined;
82
83
  /** Filter props from object `x` whose values are `true`. */
83
- declare const toPlainObjectOfTrue: (x: unknown) => Record<PropertyKey, true> | _;
84
+ declare const toPlainObjectOfTrue: (x: unknown) => Record<PropertyKey, true> | undefined;
84
85
  /**
85
86
  * Returns `x` if `x` is string, otherwise returns `''` (empty string) if
86
87
  * `x` is `null` or `undefined`, otherwise returns `JSON.stringify(x)`.
@@ -95,4 +96,43 @@ declare const returnsFalse: () => false;
95
96
  declare const returnsTrue: () => true;
96
97
  declare const returnsEmptyString: () => string;
97
98
 
98
- export { type ExtractArray, type ExtractFalsy, type ExtractObject, type ExtractPlainObject, type Falsy, type PlainObject, type SetDefaultType, type _, asArray, asNumber, asObject, asPlainObject, asString, asTrue, isArray, isBoolean, isDefined, isFalsy, isNonEmptyArray, isNonEmptyJSONObject, isNonEmptyPlainObject, isNonEmptyString, isNumber, isObject, isPlainObject, isString, isTrue, isTruthy, noop, print, returnsEmptyString, returnsFalse, returnsNull, returnsTrue, returnsUndefined, toArray, toBoolean, toFalsy, toNonEmptyArray, toNonEmptyJSONObject, toNonEmptyPlainObject, toNonEmptyString, toNumber, toObject, toPlainObject, toPlainObjectOf, toPlainObjectOfTrue, toString, toTrue, toTruthy };
99
+ /**
100
+ * Lazy filterMap that avoids creating a new array when possible.
101
+ *
102
+ * @returns the original array if `callbackfn` returns the same value for all items, otherwise a new array with the mapped items.
103
+ *
104
+ * @param arr
105
+ * @param callbackfn Return `undefined` to filter out the item, or return a value to map the item.
106
+ * @param thisArg
107
+ */
108
+ declare function inertFilterMap<T, U = T>(arr: T[], callbackfn: (value: T, index: number, arr: T[]) => U | undefined, thisArg?: any): Defined<U>[];
109
+ declare function inertFilterMap<T, U = T>(arr: T[] | undefined, callbackfn: (value: T, index: number, arr: T[]) => U | undefined, thisArg?: any): Defined<U>[] | undefined;
110
+ declare function inertFilterMap<T, U = T>(arr: readonly T[], callbackfn: (value: T, index: number, arr: readonly T[]) => U | undefined, thisArg?: any): readonly Defined<U>[];
111
+ declare function inertFilterMap<T, U = T>(arr: readonly T[] | undefined, callbackfn: (value: T, index: number, arr: readonly T[]) => U | undefined, thisArg?: any): readonly Defined<U>[] | undefined;
112
+ /**
113
+ * Lazy filter that avoids creating a new array when possible.
114
+ *
115
+ * @returns the original array if `predicate` returns `true` for all items, otherwise a new array with the filtered items.
116
+ *
117
+ * @param arr
118
+ * @param predicate Return `false` to filter out the item, or `true` to keep it.
119
+ * @param thisArg
120
+ */
121
+ declare function inertFilter<T, U extends T>(arr: T[], predicate: (value: T, index: number, arr: T[]) => value is U, thisArg?: any): U[];
122
+ declare function inertFilter<T, U extends T>(arr: T[] | undefined, predicate: (value: T, index: number, arr: T[]) => value is U, thisArg?: any): U[] | undefined;
123
+ declare function inertFilter<T, U extends T>(arr: readonly T[], predicate: (value: T, index: number, arr: readonly T[]) => value is U, thisArg?: any): readonly U[];
124
+ declare function inertFilter<T, U extends T>(arr: readonly T[] | undefined, predicate: (value: T, index: number, arr: readonly T[]) => value is U, thisArg?: any): readonly U[] | undefined;
125
+ declare function inertFilter<T>(arr: T[], predicate: (value: T, index: number, arr: T[]) => boolean, thisArg?: any): T[];
126
+ declare function inertFilter<T>(arr: T[] | undefined, predicate: (value: T, index: number, arr: T[]) => boolean, thisArg?: any): T[] | undefined;
127
+ declare function inertFilter<T>(arr: readonly T[], predicate: (value: T, index: number, arr: readonly T[]) => boolean, thisArg?: any): readonly T[];
128
+ declare function inertFilter<T>(arr: readonly T[] | undefined, predicate: (value: T, index: number, arr: readonly T[]) => boolean, thisArg?: any): readonly T[] | undefined;
129
+ interface Coalesce {
130
+ <T>(arr: T[]): Truthy<T>[];
131
+ <T>(arr: readonly T[]): readonly Truthy<T>[];
132
+ }
133
+ /**
134
+ * @returns the same array if all its items are truthy, otherwise a new array with all falsy items removed.
135
+ */
136
+ declare const coalesce: Coalesce;
137
+
138
+ export { type Coalesce, type Defined, type ExtractArray, type ExtractFalsy, type ExtractObject, type ExtractPlainObject, type Falsy, type PlainObject, type SetDefaultType, type Truthy, asArray, asNumber, asObject, asPlainObject, asString, asTrue, coalesce, inertFilter, inertFilterMap, isArray, isBoolean, isDefined, isFalsy, isNonEmptyArray, isNonEmptyJSONObject, isNonEmptyPlainObject, isNonEmptyString, isNumber, isObject, isPlainObject, isString, isTrue, isTruthy, noop, print, returnsEmptyString, returnsFalse, returnsNull, returnsTrue, returnsUndefined, toArray, toBoolean, toFalsy, toNonEmptyArray, toNonEmptyJSONObject, toNonEmptyPlainObject, toNonEmptyString, toNumber, toObject, toPlainObject, toPlainObjectOf, toPlainObjectOfTrue, toString, toTrue, toTruthy };
package/dist/index.js CHANGED
@@ -1,35 +1,34 @@
1
1
  'use strict';
2
2
 
3
3
  // src/is-to-as.ts
4
- var _ = void 0;
5
- var isDefined = (x) => x !== _;
4
+ var isDefined = (x) => x !== void 0;
6
5
  var isTrue = (x) => x === true;
7
- var toTrue = (x) => x === true ? true : _;
6
+ var toTrue = (x) => x === true ? true : void 0;
8
7
  var asTrue = (x) => x === true ? x : false;
9
8
  var isFalsy = (x) => !x;
10
- var toFalsy = (x) => isFalsy(x) ? x : _;
9
+ var toFalsy = (x) => isFalsy(x) ? x : void 0;
11
10
  var isTruthy = (x) => !!x;
12
- var toTruthy = (x) => isTruthy(x) ? x : _;
11
+ var toTruthy = (x) => isTruthy(x) ? x : void 0;
13
12
  var isBoolean = (x) => x === true || x === false;
14
- var toBoolean = (x) => isBoolean(x) ? x : _;
13
+ var toBoolean = (x) => isBoolean(x) ? x : void 0;
15
14
  var isNumber = (x) => typeof x === "number" && x === x;
16
- var toNumber = (x) => isNumber(x) ? x : _;
15
+ var toNumber = (x) => isNumber(x) ? x : void 0;
17
16
  var asNumber = (x) => isNumber(x) ? x : 0;
18
17
  var isString = (x) => typeof x === "string";
19
- var toString = (x) => isString(x) ? x : _;
18
+ var toString = (x) => isString(x) ? x : void 0;
20
19
  var asString = (x) => isString(x) ? x : "";
21
20
  var isNonEmptyString = (x) => isString(x) && x !== "";
22
- var toNonEmptyString = (x) => isNonEmptyString(x) ? x : _;
21
+ var toNonEmptyString = (x) => isNonEmptyString(x) ? x : void 0;
23
22
  var isArray = Array.isArray;
24
- var toArray = (x) => isArray(x) ? x : _;
23
+ var toArray = (x) => isArray(x) ? x : void 0;
25
24
  var asArray = (x) => isArray(x) ? x : [];
26
25
  var isNonEmptyArray = (x) => isArray(x) && x.length > 0;
27
- var toNonEmptyArray = (x) => isNonEmptyArray(x) ? x : _;
26
+ var toNonEmptyArray = (x) => isNonEmptyArray(x) ? x : void 0;
28
27
  var isObject = (x) => x !== null && typeof x === "object";
29
- var toObject = (x) => isObject(x) ? x : _;
28
+ var toObject = (x) => isObject(x) ? x : void 0;
30
29
  var asObject = (x) => isObject(x) ? x : {};
31
30
  var isPlainObject = (x) => isObject(x) && !isArray(x);
32
- var toPlainObject = (x) => isPlainObject(x) ? x : _;
31
+ var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
33
32
  var asPlainObject = (x) => isPlainObject(x) ? x : {};
34
33
  var walkPlainObjectValues = (x, predicate) => {
35
34
  if (isPlainObject(x)) {
@@ -42,9 +41,9 @@ var walkPlainObjectValues = (x, predicate) => {
42
41
  return false;
43
42
  };
44
43
  var isNonEmptyPlainObject = (x) => walkPlainObjectValues(x);
45
- var toNonEmptyPlainObject = (x) => isNonEmptyPlainObject(x) ? x : _;
44
+ var toNonEmptyPlainObject = (x) => isNonEmptyPlainObject(x) ? x : void 0;
46
45
  var isNonEmptyJSONObject = (x) => walkPlainObjectValues(x, isDefined);
47
- var toNonEmptyJSONObject = (x) => isNonEmptyJSONObject(x) ? x : _;
46
+ var toNonEmptyJSONObject = (x) => isNonEmptyJSONObject(x) ? x : void 0;
48
47
  var toPlainObjectOf = (x, f) => {
49
48
  if (isPlainObject(x)) {
50
49
  let index = -1;
@@ -81,12 +80,50 @@ var returnsFalse = () => false;
81
80
  var returnsTrue = () => true;
82
81
  var returnsEmptyString = () => "";
83
82
 
83
+ // src/array.ts
84
+ function inertFilterMap(arr, callbackfn, thisArg) {
85
+ if (arr) {
86
+ let result;
87
+ let index = -1;
88
+ let length = arr.length;
89
+ while (++index < length) {
90
+ const newItem = callbackfn.call(thisArg, arr[index], index, arr);
91
+ if (newItem === void 0 || !Object.is(newItem, arr[index])) {
92
+ result ??= arr.slice(0, index);
93
+ }
94
+ if (newItem !== void 0) {
95
+ result?.push(newItem);
96
+ }
97
+ }
98
+ return result || arr;
99
+ }
100
+ }
101
+ function inertFilter(arr, predicate, thisArg) {
102
+ if (arr) {
103
+ let result;
104
+ let index = -1;
105
+ let length = arr.length;
106
+ while (++index < length) {
107
+ if (predicate.call(thisArg, arr[index], index, arr)) {
108
+ result?.push(arr[index]);
109
+ } else {
110
+ result ??= arr.slice(0, index);
111
+ }
112
+ }
113
+ return result || arr;
114
+ }
115
+ }
116
+ var coalesce = (arr) => inertFilter(arr, isTruthy);
117
+
84
118
  exports.asArray = asArray;
85
119
  exports.asNumber = asNumber;
86
120
  exports.asObject = asObject;
87
121
  exports.asPlainObject = asPlainObject;
88
122
  exports.asString = asString;
89
123
  exports.asTrue = asTrue;
124
+ exports.coalesce = coalesce;
125
+ exports.inertFilter = inertFilter;
126
+ exports.inertFilterMap = inertFilterMap;
90
127
  exports.isArray = isArray;
91
128
  exports.isBoolean = isBoolean;
92
129
  exports.isDefined = isDefined;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/is-to-as.ts","../src/returns.ts"],"names":[],"mappings":";;;AAAA,IAAM,CAAA,GAAI,MAAA;AAOH,IAAM,SAAA,GAAY,CAAI,CAAA,KAAiC,CAAA,KAAM;AAE7D,IAAM,MAAA,GAAS,CAAC,CAAA,KAA0B,CAAA,KAAM;AAGhD,IAAM,MAAA,GAAS,CAAC,CAAA,KAA0B,CAAA,KAAM,OAAO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OAAO,EAAE,QAAQ,MAAA,EAAQ;AACvB,MAAA,IAAI,SAAA,CAAU,KAAK,OAAA,EAAS,GAAA,CAAI,KAAK,CAAA,EAAG,KAAA,EAAO,GAAU,CAAA,EAAG;AAC1D,QAAA,MAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,MACzB,CAAA,MAAO;AACL,QAAA,MAAA,KAAW,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA;AAAA,MAC/B;AAAA,IACF;AACA,IAAA,OAAO,MAAA,IAAU,GAAA;AAAA,EACnB;AACF;AAUO,IAAM,QAAA,GAAqB,CAAA,GAAA,KAAO,WAAA,CAAY,GAAA,EAAK,QAAQ","file":"index.js"}
package/dist/index.mjs CHANGED
@@ -1,33 +1,32 @@
1
1
  // src/is-to-as.ts
2
- var _ = void 0;
3
- var isDefined = (x) => x !== _;
2
+ var isDefined = (x) => x !== void 0;
4
3
  var isTrue = (x) => x === true;
5
- var toTrue = (x) => x === true ? true : _;
4
+ var toTrue = (x) => x === true ? true : void 0;
6
5
  var asTrue = (x) => x === true ? x : false;
7
6
  var isFalsy = (x) => !x;
8
- var toFalsy = (x) => isFalsy(x) ? x : _;
7
+ var toFalsy = (x) => isFalsy(x) ? x : void 0;
9
8
  var isTruthy = (x) => !!x;
10
- var toTruthy = (x) => isTruthy(x) ? x : _;
9
+ var toTruthy = (x) => isTruthy(x) ? x : void 0;
11
10
  var isBoolean = (x) => x === true || x === false;
12
- var toBoolean = (x) => isBoolean(x) ? x : _;
11
+ var toBoolean = (x) => isBoolean(x) ? x : void 0;
13
12
  var isNumber = (x) => typeof x === "number" && x === x;
14
- var toNumber = (x) => isNumber(x) ? x : _;
13
+ var toNumber = (x) => isNumber(x) ? x : void 0;
15
14
  var asNumber = (x) => isNumber(x) ? x : 0;
16
15
  var isString = (x) => typeof x === "string";
17
- var toString = (x) => isString(x) ? x : _;
16
+ var toString = (x) => isString(x) ? x : void 0;
18
17
  var asString = (x) => isString(x) ? x : "";
19
18
  var isNonEmptyString = (x) => isString(x) && x !== "";
20
- var toNonEmptyString = (x) => isNonEmptyString(x) ? x : _;
19
+ var toNonEmptyString = (x) => isNonEmptyString(x) ? x : void 0;
21
20
  var isArray = Array.isArray;
22
- var toArray = (x) => isArray(x) ? x : _;
21
+ var toArray = (x) => isArray(x) ? x : void 0;
23
22
  var asArray = (x) => isArray(x) ? x : [];
24
23
  var isNonEmptyArray = (x) => isArray(x) && x.length > 0;
25
- var toNonEmptyArray = (x) => isNonEmptyArray(x) ? x : _;
24
+ var toNonEmptyArray = (x) => isNonEmptyArray(x) ? x : void 0;
26
25
  var isObject = (x) => x !== null && typeof x === "object";
27
- var toObject = (x) => isObject(x) ? x : _;
26
+ var toObject = (x) => isObject(x) ? x : void 0;
28
27
  var asObject = (x) => isObject(x) ? x : {};
29
28
  var isPlainObject = (x) => isObject(x) && !isArray(x);
30
- var toPlainObject = (x) => isPlainObject(x) ? x : _;
29
+ var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
31
30
  var asPlainObject = (x) => isPlainObject(x) ? x : {};
32
31
  var walkPlainObjectValues = (x, predicate) => {
33
32
  if (isPlainObject(x)) {
@@ -40,9 +39,9 @@ var walkPlainObjectValues = (x, predicate) => {
40
39
  return false;
41
40
  };
42
41
  var isNonEmptyPlainObject = (x) => walkPlainObjectValues(x);
43
- var toNonEmptyPlainObject = (x) => isNonEmptyPlainObject(x) ? x : _;
42
+ var toNonEmptyPlainObject = (x) => isNonEmptyPlainObject(x) ? x : void 0;
44
43
  var isNonEmptyJSONObject = (x) => walkPlainObjectValues(x, isDefined);
45
- var toNonEmptyJSONObject = (x) => isNonEmptyJSONObject(x) ? x : _;
44
+ var toNonEmptyJSONObject = (x) => isNonEmptyJSONObject(x) ? x : void 0;
46
45
  var toPlainObjectOf = (x, f) => {
47
46
  if (isPlainObject(x)) {
48
47
  let index = -1;
@@ -79,6 +78,41 @@ var returnsFalse = () => false;
79
78
  var returnsTrue = () => true;
80
79
  var returnsEmptyString = () => "";
81
80
 
82
- export { asArray, asNumber, asObject, asPlainObject, asString, asTrue, isArray, isBoolean, isDefined, isFalsy, isNonEmptyArray, isNonEmptyJSONObject, isNonEmptyPlainObject, isNonEmptyString, isNumber, isObject, isPlainObject, isString, isTrue, isTruthy, noop, print, returnsEmptyString, returnsFalse, returnsNull, returnsTrue, returnsUndefined, toArray, toBoolean, toFalsy, toNonEmptyArray, toNonEmptyJSONObject, toNonEmptyPlainObject, toNonEmptyString, toNumber, toObject, toPlainObject, toPlainObjectOf, toPlainObjectOfTrue, toString, toTrue, toTruthy };
81
+ // src/array.ts
82
+ function inertFilterMap(arr, callbackfn, thisArg) {
83
+ if (arr) {
84
+ let result;
85
+ let index = -1;
86
+ let length = arr.length;
87
+ while (++index < length) {
88
+ const newItem = callbackfn.call(thisArg, arr[index], index, arr);
89
+ if (newItem === void 0 || !Object.is(newItem, arr[index])) {
90
+ result ??= arr.slice(0, index);
91
+ }
92
+ if (newItem !== void 0) {
93
+ result?.push(newItem);
94
+ }
95
+ }
96
+ return result || arr;
97
+ }
98
+ }
99
+ function inertFilter(arr, predicate, thisArg) {
100
+ if (arr) {
101
+ let result;
102
+ let index = -1;
103
+ let length = arr.length;
104
+ while (++index < length) {
105
+ if (predicate.call(thisArg, arr[index], index, arr)) {
106
+ result?.push(arr[index]);
107
+ } else {
108
+ result ??= arr.slice(0, index);
109
+ }
110
+ }
111
+ return result || arr;
112
+ }
113
+ }
114
+ var coalesce = (arr) => inertFilter(arr, isTruthy);
115
+
116
+ export { asArray, asNumber, asObject, asPlainObject, asString, asTrue, coalesce, inertFilter, inertFilterMap, isArray, isBoolean, isDefined, isFalsy, isNonEmptyArray, isNonEmptyJSONObject, isNonEmptyPlainObject, isNonEmptyString, isNumber, isObject, isPlainObject, isString, isTrue, isTruthy, noop, print, returnsEmptyString, returnsFalse, returnsNull, returnsTrue, returnsUndefined, toArray, toBoolean, toFalsy, toNonEmptyArray, toNonEmptyJSONObject, toNonEmptyPlainObject, toNonEmptyString, toNumber, toObject, toPlainObject, toPlainObjectOf, toPlainObjectOfTrue, toString, toTrue, toTruthy };
83
117
  //# sourceMappingURL=index.mjs.map
84
118
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/is-to-as.ts","../src/returns.ts"],"names":[],"mappings":";AAAA,IAAM,CAAA,GAAI,MAAA;AAOH,IAAM,SAAA,GAAY,CAAI,CAAA,KAAiC,CAAA,KAAM;AAE7D,IAAM,MAAA,GAAS,CAAC,CAAA,KAA0B,CAAA,KAAM;AAGhD,IAAM,MAAA,GAAS,CAAC,CAAA,KAA0B,CAAA,KAAM,OAAO,IAAA,GAAO;AAG9D,IAAM,MAAA,GAAS,CAAC,CAAA,KAAyB,CAAA,KAAM,OAAO,CAAA,GAAI;AAO1D,IAAM,OAAA,GAAU,CAAI,CAAA,KAA+B,CAAC;AAGpD,IAAM,UAAU,CAAI,CAAA,KAA+B,OAAA,CAAQ,CAAC,IAAI,CAAA,GAAI;AAGpE,IAAM,QAAA,GAAW,CAAI,CAAA,KAAiC,CAAC,CAAC;AAGxD,IAAM,WAAW,CAAI,CAAA,KAAiC,QAAA,CAAS,CAAC,IAAI,CAAA,GAAI;AAExE,IAAM,SAAA,GAAY,CAAC,CAAA,KAA6B,CAAA,KAAM,QAAQ,CAAA,KAAM;AAGpE,IAAM,YAAY,CAAC,CAAA,KAA6B,SAAA,CAAU,CAAC,IAAI,CAAA,GAAI;AAGnE,IAAM,WAAW,CAAC,CAAA,KAA4B,OAAO,CAAA,KAAM,YAAY,CAAA,KAAM;AAG7E,IAAM,WAAW,CAAC,CAAA,KAA4B,QAAA,CAAS,CAAC,IAAI,CAAA,GAAI;AAGhE,IAAM,WAAW,CAAC,CAAA,KAAwB,QAAA,CAAS,CAAC,IAAI,CAAA,GAAI;AAG5D,IAAM,QAAA,GAAW,CAAC,CAAA,KAA4B,OAAO,CAAA,KAAM;AAG3D,IAAM,WAAW,CAAC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,KAAW,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA;AAAA,MAC/B;AACA,MAAA,IAAI,YAAY,MAAA,EAAW;AACzB,QAAA,MAAA,EAAQ,KAAK,OAAqB,CAAA;AAAA,MACpC;AAAA,IACF;AACA,IAAA,OAAO,MAAA,IAAW,GAAA;AAAA,EACpB;AACF;AA+CO,SAAS,WAAA,CACd,GAAA,EACA,SAAA,EACA,OAAA,EAC0B;AAC1B,EAAA,IAAI,GAAA,EAAK;AACP,IAAA,IAAI,MAAA;AACJ,IAAA,IAAI,KAAA,GAAQ,EAAA;AACZ,IAAA,IAAI,SAAS,GAAA,CAAI,MAAA;AACjB,IAAA,OAAO,EAAE,QAAQ,MAAA,EAAQ;AACvB,MAAA,IAAI,SAAA,CAAU,KAAK,OAAA,EAAS,GAAA,CAAI,KAAK,CAAA,EAAG,KAAA,EAAO,GAAU,CAAA,EAAG;AAC1D,QAAA,MAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,KAAK,CAAC,CAAA;AAAA,MACzB,CAAA,MAAO;AACL,QAAA,MAAA,KAAW,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA;AAAA,MAC/B;AAAA,IACF;AACA,IAAA,OAAO,MAAA,IAAU,GAAA;AAAA,EACnB;AACF;AAUO,IAAM,QAAA,GAAqB,CAAA,GAAA,KAAO,WAAA,CAAY,GAAA,EAAK,QAAQ","file":"index.mjs"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopjs/cast",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Type-safe utilities for filtering and coercing unknown values in TypeScript.",
5
5
  "repository": "wopjs/cast",
6
6
  "main": "./dist/index.js",