@oscarpalmer/atoms 0.201.0 → 0.202.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/dist/array/group-by.d.mts +13 -181
- package/dist/array/to-map.d.mts +15 -171
- package/dist/array/to-record.d.mts +15 -171
- package/dist/index.d.mts +62 -526
- package/dist/internal/subscription.d.mts +6 -6
- package/dist/models.d.mts +17 -1
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ type SubscriptionProperty = {
|
|
|
44
44
|
*/
|
|
45
45
|
value: unknown;
|
|
46
46
|
};
|
|
47
|
-
type Subscriptions = {
|
|
47
|
+
type Subscriptions<Value = unknown> = {
|
|
48
48
|
/**
|
|
49
49
|
* Items of the subscriptions store
|
|
50
50
|
*
|
|
@@ -60,7 +60,7 @@ type Subscriptions = {
|
|
|
60
60
|
* - `to.any` - Map of subscriptions to values _(for unkeyed subscriptions)_
|
|
61
61
|
* - `to.keyed` - Map of keys to maps of subscriptions to values _(for keyed subscriptions)_
|
|
62
62
|
*/
|
|
63
|
-
readonly values: Readonly<SubscriptionsValues
|
|
63
|
+
readonly values: Readonly<SubscriptionsValues<Value>>;
|
|
64
64
|
/**
|
|
65
65
|
* Clear all subscriptions
|
|
66
66
|
*/
|
|
@@ -90,9 +90,9 @@ type SubscriptionsItems = {
|
|
|
90
90
|
any: Set<Subscription>;
|
|
91
91
|
keyed?: Map<Key, Set<Subscription>>;
|
|
92
92
|
};
|
|
93
|
-
type SubscriptionsValues = {
|
|
94
|
-
from: SubscriptionsValuesItem<
|
|
95
|
-
to: SubscriptionsValuesItem<Subscription,
|
|
93
|
+
type SubscriptionsValues<Value = unknown> = {
|
|
94
|
+
from: SubscriptionsValuesItem<Value, Subscription>;
|
|
95
|
+
to: SubscriptionsValuesItem<Subscription, Value>;
|
|
96
96
|
};
|
|
97
97
|
type SubscriptionsValuesItem<MapKey, MapValue> = {
|
|
98
98
|
any: Map<MapKey, MapValue>;
|
|
@@ -118,7 +118,7 @@ declare function isSubscriptions(value: unknown): value is Subscriptions;
|
|
|
118
118
|
* @param parameters Store parameters
|
|
119
119
|
* @returns Subscription store
|
|
120
120
|
*/
|
|
121
|
-
declare function subscriptions(parameters?: SubscriptionsParameters): Subscriptions
|
|
121
|
+
declare function subscriptions<Value = unknown>(parameters?: SubscriptionsParameters): Subscriptions<Value>;
|
|
122
122
|
declare const SUBSCRIPTION_NAME = "subscription";
|
|
123
123
|
//#endregion
|
|
124
124
|
export { SUBSCRIPTION_NAME, Subscription, SubscriptionParameters, SubscriptionProperty, Subscriptions, SubscriptionsParameters, isSubscription, isSubscriptions, subscriptions };
|
package/dist/models.d.mts
CHANGED
|
@@ -43,7 +43,23 @@ type GenericCallback = (...args: any[]) => any;
|
|
|
43
43
|
* A generic key type
|
|
44
44
|
*/
|
|
45
45
|
type Key = number | string;
|
|
46
|
+
/**
|
|
47
|
+
* The `PropertyKey`-safe value of `Item`'s `ItemKey` property
|
|
48
|
+
*/
|
|
46
49
|
type KeyedValue<Item, ItemKey extends keyof Item> = Item[ItemKey] extends PropertyKey ? Item[ItemKey] : never;
|
|
50
|
+
/**
|
|
51
|
+
* A key of `Item`, or a callback returning `Return`, used to derive a value from an item
|
|
52
|
+
*/
|
|
53
|
+
type KeyOrCallback<Item, Return = unknown> = ((item: Item, index: number, array: Item[]) => Return) | (Item extends PlainObject ? keyof Item : never);
|
|
54
|
+
/**
|
|
55
|
+
* The `PropertyKey`-safe value resolved from a `KeyOrCallback<Item, Key>` argument, for use as a
|
|
56
|
+
* `Record` or `Map` key
|
|
57
|
+
*/
|
|
58
|
+
type KeyOrCallbackKey<Item, Arg extends KeyOrCallback<Item, Key>> = Arg extends ((item: Item, index: number, array: Item[]) => Key) ? ReturnType<Arg> : Arg extends keyof Item ? KeyedValue<Item, Arg> : never;
|
|
59
|
+
/**
|
|
60
|
+
* The value resolved from a `KeyOrCallback` argument against `Item`
|
|
61
|
+
*/
|
|
62
|
+
type KeyOrCallbackValue<Item, Arg extends KeyOrCallback<Item>> = Arg extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Arg> : Arg extends keyof Item ? Item[Arg] : never;
|
|
47
63
|
/**
|
|
48
64
|
* A nested array
|
|
49
65
|
*/
|
|
@@ -154,4 +170,4 @@ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Un
|
|
|
154
170
|
*/
|
|
155
171
|
type Unsubscriber = () => void;
|
|
156
172
|
//#endregion
|
|
157
|
-
export { ArrayOrPlainObject, AsyncCancelableCallback, BuiltIns, CancelableCallback, Constructor, GenericAsyncCallback, GenericCallback, Key, KeyedValue, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, RequiredKeys, Simplify, ToString, TypedArray, UnionToIntersection, Unsubscriber };
|
|
173
|
+
export { ArrayOrPlainObject, AsyncCancelableCallback, BuiltIns, CancelableCallback, Constructor, GenericAsyncCallback, GenericCallback, Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, KeyedValue, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, RequiredKeys, Simplify, ToString, TypedArray, UnionToIntersection, Unsubscriber };
|