@hkdigital/lib-sveltekit 0.0.45 → 0.0.47
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
CHANGED
@@ -29,9 +29,26 @@ pnpm add @hkdigital/lib-sveltekit
|
|
29
29
|
|
30
30
|
### Update
|
31
31
|
|
32
|
+
We use a global installion of the `ncu` package to upgrade our `package.json`. Install `ncu` first if you don't have it yet
|
33
|
+
|
34
|
+
```bash
|
35
|
+
npm install -g npm-check-updates
|
36
|
+
```
|
37
|
+
|
38
|
+
Upgrading works as follows:
|
39
|
+
|
32
40
|
```bash
|
33
41
|
ncu "@hkdigital/*" -u && pnpm install
|
34
42
|
```
|
43
|
+
We use a wildcard to upgrade all installed `node_modules` in the scope `@hkdigital`.
|
44
|
+
|
45
|
+
You can also add this command to your project's `package.json`. E.g. add the lines:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
"scripts": {
|
49
|
+
"upgrade:hklib": "ncu '@hkdigital/*' -u && pnpm install",
|
50
|
+
"upgrade:all": "ncu -u && pnpm install"
|
51
|
+
```
|
35
52
|
|
36
53
|
### Import JS & Svelte
|
37
54
|
|
@@ -107,5 +124,5 @@ npm publish --access public
|
|
107
124
|
pnpm run publish:npm
|
108
125
|
```
|
109
126
|
|
110
|
-
|
127
|
+
## Contribute
|
111
128
|
If your wish to contribute to this library, please contact us [HKdigital](https://hkdigital.nl/contact). Alternatively, the license permits you to fork the library and publish under an alternative name. Change the package name in [package.json](./package.json) to do so.
|
@@ -11,18 +11,20 @@ export default class Selector {
|
|
11
11
|
/**
|
12
12
|
* Returns the first item from the list of items that matches the selector
|
13
13
|
*
|
14
|
-
* @
|
14
|
+
* @template {object} T
|
15
|
+
* @param {T[]|null} items
|
15
16
|
*
|
16
|
-
* @returns {
|
17
|
+
* @returns {T|null} item or null if not found
|
17
18
|
*/
|
18
|
-
findFirst(items:
|
19
|
+
findFirst<T extends unknown>(items: T[] | null): T | null;
|
19
20
|
/**
|
20
21
|
* Returns all items from the list of items that match the selector
|
21
22
|
*
|
22
|
-
* @
|
23
|
+
* @template {object} T
|
24
|
+
* @param {T[]|null} items
|
23
25
|
*
|
24
|
-
* @returns {
|
26
|
+
* @returns {T|null} item or null if not found
|
25
27
|
*/
|
26
|
-
findAll(items:
|
28
|
+
findAll<T extends unknown>(items: T[] | null): T | null;
|
27
29
|
#private;
|
28
30
|
}
|
@@ -53,9 +53,10 @@ export default class Selector {
|
|
53
53
|
/**
|
54
54
|
* Returns the first item from the list of items that matches the selector
|
55
55
|
*
|
56
|
-
* @
|
56
|
+
* @template {object} T
|
57
|
+
* @param {T[]|null} items
|
57
58
|
*
|
58
|
-
* @returns {
|
59
|
+
* @returns {T|null} item or null if not found
|
59
60
|
*/
|
60
61
|
findFirst(items) {
|
61
62
|
if (!items) {
|
@@ -76,9 +77,10 @@ export default class Selector {
|
|
76
77
|
/**
|
77
78
|
* Returns all items from the list of items that match the selector
|
78
79
|
*
|
79
|
-
* @
|
80
|
+
* @template {object} T
|
81
|
+
* @param {T[]|null} items
|
80
82
|
*
|
81
|
-
* @returns {
|
83
|
+
* @returns {T|null} item or null if not found
|
82
84
|
*/
|
83
85
|
findAll(items) {
|
84
86
|
const result = [];
|
@@ -135,22 +135,24 @@ export function sortByPathValue(items: any[], path: string[] | string, compareFn
|
|
135
135
|
* Find the first item in the list of objects that matches the selector
|
136
136
|
* - All items in the supplied array must be objects
|
137
137
|
*
|
138
|
-
* @
|
138
|
+
* @template {object} T
|
139
|
+
* @param {T[]} arr
|
139
140
|
* @param {object|null} selector
|
140
141
|
*
|
141
|
-
* @returns {
|
142
|
+
* @returns {T|null} first matched item
|
142
143
|
*/
|
143
|
-
export function findFirst(arr:
|
144
|
+
export function findFirst<T extends unknown>(arr: T[], selector: object | null): T | null;
|
144
145
|
/**
|
145
146
|
* Returns all items from the list of items that match the selector
|
146
147
|
* - All items in the supplied array must be objects
|
147
148
|
*
|
148
|
-
* @
|
149
|
+
* @template {object} T
|
150
|
+
* @param {T[]} arr
|
149
151
|
* @param {object|null} selector
|
150
152
|
*
|
151
|
-
* @returns {
|
153
|
+
* @returns {T[]} matching items
|
152
154
|
*/
|
153
|
-
export function findAll(arr:
|
155
|
+
export function findAll<T extends unknown>(arr: T[], selector: object | null): T[];
|
154
156
|
/**
|
155
157
|
* Convert array to an object using a list of keys for each index
|
156
158
|
*
|
package/dist/util/array/index.js
CHANGED
@@ -378,10 +378,11 @@ export function sortByPathValue(items, path, compareFn = smallestFirst) {
|
|
378
378
|
* Find the first item in the list of objects that matches the selector
|
379
379
|
* - All items in the supplied array must be objects
|
380
380
|
*
|
381
|
-
* @
|
381
|
+
* @template {object} T
|
382
|
+
* @param {T[]} arr
|
382
383
|
* @param {object|null} selector
|
383
384
|
*
|
384
|
-
* @returns {
|
385
|
+
* @returns {T|null} first matched item
|
385
386
|
*/
|
386
387
|
export function findFirst(arr, selector) {
|
387
388
|
const selectorObj = new Selector(selector);
|
@@ -395,10 +396,11 @@ export function findFirst(arr, selector) {
|
|
395
396
|
* Returns all items from the list of items that match the selector
|
396
397
|
* - All items in the supplied array must be objects
|
397
398
|
*
|
398
|
-
* @
|
399
|
+
* @template {object} T
|
400
|
+
* @param {T[]} arr
|
399
401
|
* @param {object|null} selector
|
400
402
|
*
|
401
|
-
* @returns {
|
403
|
+
* @returns {T[]} matching items
|
402
404
|
*/
|
403
405
|
export function findAll(arr, selector) {
|
404
406
|
const selectorObj = new Selector(selector);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hkdigital/lib-sveltekit",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.47",
|
4
4
|
"author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
|
5
5
|
"license": "ISC",
|
6
6
|
"repository": {
|
@@ -50,6 +50,10 @@
|
|
50
50
|
"types": "./dist/classes/index.d.ts",
|
51
51
|
"svelte": "./dist/classes/index.js"
|
52
52
|
},
|
53
|
+
"./classes/data": {
|
54
|
+
"types": "./dist/classes/data/index.d.ts",
|
55
|
+
"svelte": "./dist/classes/data/index.js"
|
56
|
+
},
|
53
57
|
"./classes/streams": {
|
54
58
|
"types": "./dist/classes/streams/index.d.ts",
|
55
59
|
"svelte": "./dist/classes/streams/index.js"
|
@@ -74,6 +78,10 @@
|
|
74
78
|
"types": "./dist/components/icon/index.d.ts",
|
75
79
|
"svelte": "./dist/components/icon/index.js"
|
76
80
|
},
|
81
|
+
"./components/input": {
|
82
|
+
"types": "./dist/components/input/index.d.ts",
|
83
|
+
"svelte": "./dist/components/input/index.js"
|
84
|
+
},
|
77
85
|
"./components/tab-bar": {
|
78
86
|
"types": "./dist/components/tab-bar/index.d.ts",
|
79
87
|
"svelte": "./dist/components/tab-bar/index.js"
|
@@ -102,14 +110,38 @@
|
|
102
110
|
"types": "./dist/util/index.d.ts",
|
103
111
|
"svelte": "./dist/util/index.js"
|
104
112
|
},
|
113
|
+
"./util/array": {
|
114
|
+
"types": "./dist/util/array/index.d.ts",
|
115
|
+
"svelte": "./dist/util/array/index.js"
|
116
|
+
},
|
117
|
+
"./util/compare": {
|
118
|
+
"types": "./dist/util/compare/index.d.ts",
|
119
|
+
"svelte": "./dist/util/compare/index.js"
|
120
|
+
},
|
105
121
|
"./util/expect": {
|
106
122
|
"types": "./dist/util/expect/index.d.ts",
|
107
123
|
"svelte": "./dist/util/expect/index.js"
|
108
124
|
},
|
125
|
+
"./util/is": {
|
126
|
+
"types": "./dist/util/is/index.d.ts",
|
127
|
+
"svelte": "./dist/util/is/index.js"
|
128
|
+
},
|
129
|
+
"./util/iterate": {
|
130
|
+
"types": "./dist/util/iterate/index.d.ts",
|
131
|
+
"svelte": "./dist/util/iterate/index.js"
|
132
|
+
},
|
133
|
+
"./util/object": {
|
134
|
+
"types": "./dist/util/object/index.d.ts",
|
135
|
+
"svelte": "./dist/util/object/index.js"
|
136
|
+
},
|
109
137
|
"./util/singleton": {
|
110
138
|
"types": "./dist/util/singleton/index.d.ts",
|
111
139
|
"svelte": "./dist/util/singleton/index.js"
|
112
140
|
},
|
141
|
+
"./util/string": {
|
142
|
+
"types": "./dist/util/string/index.d.ts",
|
143
|
+
"svelte": "./dist/util/string/index.js"
|
144
|
+
},
|
113
145
|
"./util/svelte": {
|
114
146
|
"types": "./dist/util/svelte/index.d.ts",
|
115
147
|
"svelte": "./dist/util/svelte/index.js"
|