@naptics/vue-collection 0.2.11 → 0.2.12

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@naptics/vue-collection",
3
3
  "author": "Timo Siegenthaler",
4
4
  "description": "Vue Collection is a collection of styled and fully functional Vue components which can easily be integrated into our projects.",
5
- "version": "0.2.11",
5
+ "version": "0.2.12",
6
6
  "main": "./index.js",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,10 +1,9 @@
1
1
  import { type Nullish } from './utils';
2
- type IdType = string;
3
- export type Identifiable = Readonly<{
4
- id: IdType;
2
+ export type Identifiable<Id = string> = Readonly<{
3
+ id: Id;
5
4
  }>;
6
- export type MaybeIdentifiable = Readonly<{
7
- id?: Nullish<IdType>;
5
+ export type MaybeIdentifiable<Id = string> = Readonly<{
6
+ id?: Nullish<Id>;
8
7
  }>;
9
8
  /**
10
9
  * Looks for the `id` in the given array of `Identifiables`.
@@ -12,14 +11,14 @@ export type MaybeIdentifiable = Readonly<{
12
11
  * @param id The `id` of the desired item.
13
12
  * @returns The first item with the specified `id` or `undefined` if none exists.
14
13
  */
15
- declare function find<T extends Identifiable>(array: Nullish<T[]>, id: IdType): T | undefined;
14
+ declare function find<Id, Item extends Identifiable<Id>>(array: Nullish<Item[]>, id: Id): Item | undefined;
16
15
  /**
17
16
  * Checks if the given array contains an item with the `id`.
18
17
  * @param array The array to search the item in.
19
18
  * @param id The `id` to check the array for.
20
19
  * @returns `true` if there is at least one item in the array with the given `id`.
21
20
  */
22
- declare function contains<T extends Identifiable>(array: T[], id: IdType): boolean;
21
+ declare function contains<Id, Item extends Identifiable<Id>>(array: Item[], id: Id): boolean;
23
22
  /**
24
23
  * Inserts the items into the given array, replacing items with the same `id`.
25
24
  * If no item with the same `id` exists, the item is appended to the array.
@@ -28,14 +27,14 @@ declare function contains<T extends Identifiable>(array: T[], id: IdType): boole
28
27
  * @param insertItems The items to insert into the array.
29
28
  * @returns The reference to the same array, which was passed.
30
29
  */
31
- declare function insert<T extends Identifiable>(array: T[], ...insertItems: T[]): T[];
30
+ declare function insert<Id, Item extends Identifiable<Id>>(array: Item[], ...insertItems: Item[]): Item[];
32
31
  /**
33
32
  * Removes all items with the specified `ids` from the given array.
34
33
  * @param array The array to remove the items from.
35
34
  * @param ids The `ids` of the items which should be removed.
36
35
  * @returns The reference to the same array, which was passed.
37
36
  */
38
- declare function remove<T extends Identifiable>(array: T[], ...ids: IdType[]): T[];
37
+ declare function remove<Id, Item extends Identifiable>(array: Item[], ...ids: Id[]): Item[];
39
38
  /**
40
39
  * Compares the two arrays and checks if they both have
41
40
  * items with the same `ids` in the same order.
@@ -43,7 +42,7 @@ declare function remove<T extends Identifiable>(array: T[], ...ids: IdType[]): T
43
42
  * @param second The second array to compare.
44
43
  * @returns `true` if the arrays contain item with the same `ids` in the same order.
45
44
  */
46
- declare function areSameArrays(first: Identifiable[], second: Identifiable[]): boolean;
45
+ declare function areSameArrays<Id>(first: Identifiable<Id>[], second: Identifiable<Id>[]): boolean;
47
46
  /**
48
47
  * This object contains utility functions to deal with {@link Identifiable} objects.
49
48
  */