@oscarpalmer/atoms 0.73.0 → 0.74.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/package.json +127 -63
- package/types/array/index.d.cts +194 -0
- package/types/array/models.d.cts +23 -0
- package/types/colour/index.d.cts +173 -0
- package/types/emitter.d.cts +83 -0
- package/types/function.d.cts +63 -0
- package/types/index.d.cts +285 -742
- package/types/is.d.cts +113 -0
- package/types/logger.d.cts +98 -0
- package/types/math.d.cts +24 -0
- package/types/models.d.cts +1060 -0
- package/types/number.d.cts +19 -0
- package/types/query.d.cts +44 -0
- package/types/queue.d.cts +8 -0
- package/types/random.d.cts +42 -0
- package/types/sized.d.cts +88 -0
- package/types/string/index.d.cts +97 -0
- package/types/touch.d.cts +12 -0
- package/types/value/index.d.cts +1238 -0
package/package.json
CHANGED
|
@@ -14,10 +14,11 @@
|
|
|
14
14
|
"@types/bun": "^1.1.10",
|
|
15
15
|
"bun": "^1.1.29",
|
|
16
16
|
"dts-bundle-generator": "^9.5.1",
|
|
17
|
-
"sass": "^1.79.
|
|
17
|
+
"sass": "^1.79.4",
|
|
18
18
|
"typescript": "^5.6.2"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
21
|
+
"./package.json": "./package.json",
|
|
21
22
|
".": {
|
|
22
23
|
"bun": "./src/js/index.ts",
|
|
23
24
|
"import": {
|
|
@@ -30,16 +31,26 @@
|
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
"./array": {
|
|
33
|
-
"types": "./types/array/index.d.ts",
|
|
34
34
|
"bun": "./src/js/array/index.ts",
|
|
35
|
-
"import":
|
|
36
|
-
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./types/array/index.d.ts",
|
|
37
|
+
"default": "./dist/js/array/index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./types/array/index.d.cts",
|
|
41
|
+
"default": "./dist/js/array/index.js"
|
|
42
|
+
}
|
|
37
43
|
},
|
|
38
44
|
"./colour": {
|
|
39
|
-
"types": "./types/colour/index.d.ts",
|
|
40
45
|
"bun": "./src/js/colour/index.ts",
|
|
41
|
-
"import":
|
|
42
|
-
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./types/colour/index.d.ts",
|
|
48
|
+
"default": "./dist/js/colour/index.mjs"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./types/colour/index.d.cts",
|
|
52
|
+
"default": "./dist/js/colour/index.js"
|
|
53
|
+
}
|
|
43
54
|
},
|
|
44
55
|
"./css/a11y": {
|
|
45
56
|
"sass": "./src/css/a11y.scss",
|
|
@@ -54,93 +65,149 @@
|
|
|
54
65
|
"style": "./dist/css/reset.css"
|
|
55
66
|
},
|
|
56
67
|
"./emitter": {
|
|
57
|
-
"types": "./types/emitter.d.ts",
|
|
58
68
|
"bun": "./src/js/emitter.ts",
|
|
59
|
-
"import":
|
|
60
|
-
|
|
69
|
+
"import": {
|
|
70
|
+
"types": "./types/emitter.d.ts",
|
|
71
|
+
"default": "./dist/js/emitter.mjs"
|
|
72
|
+
},
|
|
73
|
+
"require": {
|
|
74
|
+
"types": "./types/emitter.d.cts",
|
|
75
|
+
"default": "./dist/js/emitter.js"
|
|
76
|
+
}
|
|
61
77
|
},
|
|
62
78
|
"./function": {
|
|
63
|
-
"types": "./types/function.d.ts",
|
|
64
79
|
"bun": "./src/js/function.ts",
|
|
65
|
-
"import":
|
|
66
|
-
|
|
80
|
+
"import": {
|
|
81
|
+
"types": "./types/function.d.ts",
|
|
82
|
+
"default": "./dist/js/function.mjs"
|
|
83
|
+
},
|
|
84
|
+
"require": {
|
|
85
|
+
"types": "./types/function.d.cts",
|
|
86
|
+
"default": "./dist/js/function.js"
|
|
87
|
+
}
|
|
67
88
|
},
|
|
68
89
|
"./is": {
|
|
69
|
-
"types": "./types/is.d.ts",
|
|
70
90
|
"bun": "./src/js/is.ts",
|
|
71
|
-
"import":
|
|
72
|
-
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./types/is.d.ts",
|
|
93
|
+
"default": "./dist/js/is.mjs"
|
|
94
|
+
},
|
|
95
|
+
"require": {
|
|
96
|
+
"types": "./types/is.d.cts",
|
|
97
|
+
"default": "./dist/js/is.js"
|
|
98
|
+
}
|
|
73
99
|
},
|
|
74
100
|
"./logger": {
|
|
75
|
-
"types": "./types/logger.d.ts",
|
|
76
101
|
"bun": "./src/js/logger.ts",
|
|
77
|
-
"import":
|
|
78
|
-
|
|
102
|
+
"import": {
|
|
103
|
+
"types": "./types/logger.d.ts",
|
|
104
|
+
"default": "./dist/js/logger.mjs"
|
|
105
|
+
},
|
|
106
|
+
"require": {
|
|
107
|
+
"types": "./types/logger.d.cts",
|
|
108
|
+
"default": "./dist/js/logger.js"
|
|
109
|
+
}
|
|
79
110
|
},
|
|
80
111
|
"./math": {
|
|
81
|
-
"types": "./types/math.d.ts",
|
|
82
112
|
"bun": "./src/js/math.ts",
|
|
83
|
-
"import":
|
|
84
|
-
|
|
113
|
+
"import": {
|
|
114
|
+
"types": "./types/math.d.ts",
|
|
115
|
+
"default": "./dist/js/math.mjs"
|
|
116
|
+
},
|
|
117
|
+
"require": {
|
|
118
|
+
"types": "./types/math.d.cts",
|
|
119
|
+
"default": "./dist/js/math.js"
|
|
120
|
+
}
|
|
85
121
|
},
|
|
86
122
|
"./models": {
|
|
87
|
-
"
|
|
88
|
-
"
|
|
123
|
+
"bun": "./src/js/models.ts",
|
|
124
|
+
"import": {
|
|
125
|
+
"types": "./types/models.d.ts"
|
|
126
|
+
},
|
|
127
|
+
"require": {
|
|
128
|
+
"types": "./types/models.d.cts"
|
|
129
|
+
}
|
|
89
130
|
},
|
|
90
131
|
"./number": {
|
|
91
|
-
"types": "./types/number.d.ts",
|
|
92
132
|
"bun": "./src/js/number.ts",
|
|
93
|
-
"import":
|
|
94
|
-
|
|
133
|
+
"import": {
|
|
134
|
+
"types": "./types/number.d.ts",
|
|
135
|
+
"default": "./dist/js/number.mjs"
|
|
136
|
+
},
|
|
137
|
+
"require": {
|
|
138
|
+
"types": "./types/number.d.cts",
|
|
139
|
+
"default": "./dist/js/number.js"
|
|
140
|
+
}
|
|
95
141
|
},
|
|
96
142
|
"./query": {
|
|
97
|
-
"types": "./types/query.d.ts",
|
|
98
143
|
"bun": "./src/js/query.ts",
|
|
99
|
-
"import":
|
|
100
|
-
|
|
144
|
+
"import": {
|
|
145
|
+
"types": "./types/query.d.ts",
|
|
146
|
+
"default": "./dist/js/query.mjs"
|
|
147
|
+
},
|
|
148
|
+
"require": {
|
|
149
|
+
"types": "./types/query.d.cts",
|
|
150
|
+
"default": "./dist/js/query.js"
|
|
151
|
+
}
|
|
101
152
|
},
|
|
102
153
|
"./queue": {
|
|
103
|
-
"types": "./types/queue.d.ts",
|
|
104
154
|
"bun": "./src/js/queue.ts",
|
|
105
|
-
"import":
|
|
106
|
-
|
|
155
|
+
"import": {
|
|
156
|
+
"types": "./types/queue.d.ts",
|
|
157
|
+
"default": "./dist/js/queue.mjs"
|
|
158
|
+
},
|
|
159
|
+
"require": {
|
|
160
|
+
"types": "./types/queue.d.cts",
|
|
161
|
+
"default": "./dist/js/queue.js"
|
|
162
|
+
}
|
|
107
163
|
},
|
|
108
164
|
"./random": {
|
|
109
|
-
"types": "./types/random.d.ts",
|
|
110
165
|
"bun": "./src/js/random.ts",
|
|
111
|
-
"import":
|
|
112
|
-
|
|
166
|
+
"import": {
|
|
167
|
+
"types": "./types/random.d.ts",
|
|
168
|
+
"default": "./dist/js/random.mjs"
|
|
169
|
+
},
|
|
170
|
+
"require": {
|
|
171
|
+
"types": "./types/random.d.cts",
|
|
172
|
+
"default": "./dist/js/random.js"
|
|
173
|
+
}
|
|
113
174
|
},
|
|
114
175
|
"./string": {
|
|
115
|
-
"types": "./types/string/index.d.ts",
|
|
116
176
|
"bun": "./src/js/string/index.ts",
|
|
117
|
-
"import":
|
|
118
|
-
|
|
177
|
+
"import": {
|
|
178
|
+
"types": "./types/string/index.d.ts",
|
|
179
|
+
"default": "./dist/js/string/index.mjs"
|
|
180
|
+
},
|
|
181
|
+
"require": {
|
|
182
|
+
"types": "./types/string/index.d.cts",
|
|
183
|
+
"default": "./dist/js/string/index.js"
|
|
184
|
+
}
|
|
119
185
|
},
|
|
120
186
|
"./supports-touch": {
|
|
121
|
-
"types": "./types/touch.d.ts",
|
|
122
187
|
"bun": "./src/js/touch.ts",
|
|
123
|
-
"import":
|
|
124
|
-
|
|
188
|
+
"import": {
|
|
189
|
+
"types": "./types/touch.d.ts",
|
|
190
|
+
"default": "./dist/js/touch.mjs"
|
|
191
|
+
},
|
|
192
|
+
"require": {
|
|
193
|
+
"types": "./types/touch.d.cts",
|
|
194
|
+
"default": "./dist/js/touch.js"
|
|
195
|
+
}
|
|
125
196
|
},
|
|
126
197
|
"./value": {
|
|
127
|
-
"types": "./types/value/index.d.ts",
|
|
128
198
|
"bun": "./src/js/value/index.ts",
|
|
129
|
-
"import":
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
199
|
+
"import": {
|
|
200
|
+
"types": "./types/value/index.d.ts",
|
|
201
|
+
"default": "./dist/js/value/index.mjs"
|
|
202
|
+
},
|
|
203
|
+
"require": {
|
|
204
|
+
"types": "./types/value/index.d.cts",
|
|
205
|
+
"default": "./dist/js/value/index.js"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
133
208
|
},
|
|
134
|
-
"files": [
|
|
135
|
-
|
|
136
|
-
"dist/js/*.js",
|
|
137
|
-
"dist/js/**/index.js",
|
|
138
|
-
"dist/js/element/focusable.js",
|
|
139
|
-
"dist/js/**/*.mjs",
|
|
140
|
-
"src",
|
|
141
|
-
"types"
|
|
142
|
-
],
|
|
143
|
-
"keywords": [],
|
|
209
|
+
"files": ["dist", "src", "types"],
|
|
210
|
+
"keywords": ["helper", "utility"],
|
|
144
211
|
"license": "MIT",
|
|
145
212
|
"main": "./dist/js/index.js",
|
|
146
213
|
"module": "./dist/js/index.mjs",
|
|
@@ -150,18 +217,15 @@
|
|
|
150
217
|
"url": "git+https://github.com/oscarpalmer/atoms.git"
|
|
151
218
|
},
|
|
152
219
|
"scripts": {
|
|
153
|
-
"build": "bun run clean && bun run build:css && bun run build:js
|
|
220
|
+
"build": "bun run clean && bun run build:css && bun run build:js",
|
|
154
221
|
"build:css": "bunx sass ./src/css:./dist/css --no-source-map",
|
|
155
|
-
"build:js": "bunx bun ./.bun.ts && bunx bun ./.bun.ts --
|
|
222
|
+
"build:js": "bunx bun ./.bun.ts && bunx bun ./.bun.ts --esm",
|
|
156
223
|
"clean": "rm -rf ./dist && rm -rf ./types && rm -f ./tsconfig.tsbuildinfo",
|
|
157
224
|
"test": "bun test",
|
|
158
|
-
"types": "bun run types:cjs && bun run types:esm",
|
|
159
|
-
"types:cjs": "bunx dts-bundle-generator --out-file ./types/index.d.cts --external-inlines 'type-fest' --no-check --silent ./src/js/index.ts",
|
|
160
|
-
"types:esm": "bunx tsc -p ./tsconfig.json",
|
|
161
225
|
"watch:css": "bunx sass ./src/css:./dist/css --no-source-map --watch",
|
|
162
226
|
"watch:js": "bun build ./src/js/index.ts --outfile ./dist/js/index.js --watch"
|
|
163
227
|
},
|
|
164
228
|
"type": "module",
|
|
165
229
|
"types": "./types/index.d.cts",
|
|
166
|
-
"version": "0.
|
|
230
|
+
"version": "0.74.0"
|
|
167
231
|
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type NestedArrayType<Value> = Value extends Array<infer NestedValue> ? NestedArrayType<NestedValue> : Value;
|
|
4
|
+
export type Key = number | string;
|
|
5
|
+
/**
|
|
6
|
+
* Chunks an array into smaller arrays of a specified size
|
|
7
|
+
*/
|
|
8
|
+
export declare function chunk<Value>(array: Value[], size?: number): Value[][];
|
|
9
|
+
/**
|
|
10
|
+
* Compacts and returns an array with all falsey values removed
|
|
11
|
+
*/
|
|
12
|
+
export declare function compact<Value>(array: Value[], strict: true): Exclude<Value, 0 | "" | false | null | undefined>[];
|
|
13
|
+
/**
|
|
14
|
+
* Compacts and returns an array with all `null` and `undefined` values removed
|
|
15
|
+
*/
|
|
16
|
+
export declare function compact<Value>(array: Value[]): Exclude<Value, null | undefined>[];
|
|
17
|
+
export type ArrayCallback<Value, Returned> = (value: Value, index: number, array: Value[]) => Returned;
|
|
18
|
+
export type BooleanCallback<Value> = ArrayCallback<Value, boolean>;
|
|
19
|
+
export type KeyCallback<Value> = ArrayCallback<Value, Key>;
|
|
20
|
+
export type SortKey<Value> = {
|
|
21
|
+
direction: "asc" | "desc";
|
|
22
|
+
value: Key | SortKeyCallback<Value>;
|
|
23
|
+
};
|
|
24
|
+
export type SortKeyCallback<Value> = (value: Value) => Key;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the number of items _(count)_ that match the given value
|
|
27
|
+
*/
|
|
28
|
+
export declare function count<Model, Value>(array: Model[], value: Value | BooleanCallback<Model>): number;
|
|
29
|
+
/**
|
|
30
|
+
* - Returns the number of items _(count)_ that match the given value
|
|
31
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
32
|
+
*/
|
|
33
|
+
export declare function count<Model, Value = Model>(array: Model[], value: Value, key: Key | KeyCallback<Model>): number;
|
|
34
|
+
/**
|
|
35
|
+
* Does the value exist in array?
|
|
36
|
+
*/
|
|
37
|
+
export declare function exists<Model, Value>(array: Model[], value: Value | BooleanCallback<Model>): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* - Does the value exist in array?
|
|
40
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
41
|
+
*/
|
|
42
|
+
export declare function exists<Model, Value = Model>(array: Model[], value: Value, key: Key | KeyCallback<Model>): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Returns a filtered array of items matching `value`
|
|
45
|
+
*/
|
|
46
|
+
export declare function filter<Model, Value>(array: Model[], value: Value | BooleanCallback<Model>): Model[];
|
|
47
|
+
/**
|
|
48
|
+
* - Returns a filtered array of items
|
|
49
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
50
|
+
*/
|
|
51
|
+
export declare function filter<Model, Value = Model>(array: Model[], value: Value, key: Key | KeyCallback<Model>): Model[];
|
|
52
|
+
/**
|
|
53
|
+
* Returns the first item matching `value`, or `undefined` if no match is found
|
|
54
|
+
*/
|
|
55
|
+
export declare function find<Model, Value>(array: Model[], value: Value | BooleanCallback<Model>): Model | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* - Returns the first matching item, or `undefined` if no match is found
|
|
58
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
59
|
+
*/
|
|
60
|
+
export declare function find<Model, Value = Model>(array: Model[], value: Value, key: Key | KeyCallback<Model>): Model | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Groups an array of items using a key or callback
|
|
63
|
+
*/
|
|
64
|
+
export declare function groupBy<Value>(array: Value[], key: Key | KeyCallback<Value>): Record<Key, Value[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the index for the first item matching `value`, or `-1` if no match is found
|
|
67
|
+
*/
|
|
68
|
+
export declare function indexOf<Model, Value>(array: Model[], value: Value | BooleanCallback<Model>): number;
|
|
69
|
+
/**
|
|
70
|
+
* - Returns the index for the first matching item, or `-1` if no match is found
|
|
71
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
72
|
+
*/
|
|
73
|
+
export declare function indexOf<Model, Value = Model>(array: Model[], value: Value, key: Key | KeyCallback<Model>): number;
|
|
74
|
+
/**
|
|
75
|
+
* - Inserts values into an array at a specified index
|
|
76
|
+
* - Uses chunking to avoid stack overflow
|
|
77
|
+
*/
|
|
78
|
+
export declare function insert<Value>(array: Value[], index: number, values: Value[]): void;
|
|
79
|
+
/**
|
|
80
|
+
* Shuffles an array
|
|
81
|
+
*/
|
|
82
|
+
export declare function shuffle<Value>(array: Value[]): Value[];
|
|
83
|
+
/**
|
|
84
|
+
* Sorts an array of items _(ascending by default)_
|
|
85
|
+
*/
|
|
86
|
+
export declare function sort<Value>(array: Value[], descending?: boolean): Value[];
|
|
87
|
+
/**
|
|
88
|
+
* - Sorts an array of items, using a `key` to sort by a specific value
|
|
89
|
+
* - Ascending by default, but can be changed by setting `descending` to `true`, or using a `SortKey`
|
|
90
|
+
*/
|
|
91
|
+
export declare function sort<Value>(array: Value[], key: Key | SortKey<Value> | SortKeyCallback<Value>, descending?: boolean): Value[];
|
|
92
|
+
/**
|
|
93
|
+
* - Sorts an array of items, using multiple `keys` to sort by specific values
|
|
94
|
+
* - Ascending by default, but can be changed by setting `descending` to `true`, or using `SortKey`
|
|
95
|
+
*/
|
|
96
|
+
export declare function sort<Value>(array: Value[], keys: Array<Key | SortKey<Value> | SortKeyCallback<Value>>, descending?: boolean): Value[];
|
|
97
|
+
/**
|
|
98
|
+
* Removes and returns all items from an array starting from a specific index
|
|
99
|
+
*/
|
|
100
|
+
export declare function splice<Value>(array: Value[], start: number): Value[];
|
|
101
|
+
/**
|
|
102
|
+
* Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
|
|
103
|
+
*/
|
|
104
|
+
export declare function splice<Value>(array: Value[], start: number, amount: number): Value[];
|
|
105
|
+
/**
|
|
106
|
+
* - Splices values into an array and returns any removed values
|
|
107
|
+
* - Uses chunking to avoid stack overflow
|
|
108
|
+
*/
|
|
109
|
+
export declare function splice<Value>(array: Value[], start: number, values: Value[]): Value[];
|
|
110
|
+
/**
|
|
111
|
+
* - Splices values into an array and returns any removed values
|
|
112
|
+
* - Uses chunking to avoid stack overflow
|
|
113
|
+
*/
|
|
114
|
+
export declare function splice<Value>(array: Value[], start: number, amount: number, values: Value[]): Value[];
|
|
115
|
+
/**
|
|
116
|
+
* Converts an array into a map, using indices as keys
|
|
117
|
+
*/
|
|
118
|
+
export declare function toMap<Value>(array: Value[]): Map<number, Value>;
|
|
119
|
+
/**
|
|
120
|
+
* Converts an array into a map, using indices as keys and grouping values into arrays
|
|
121
|
+
*/
|
|
122
|
+
export declare function toMap<Value>(array: Value[], arrays: true): Map<number, Value[]>;
|
|
123
|
+
/**
|
|
124
|
+
* - Converts an array into a map
|
|
125
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
126
|
+
*/
|
|
127
|
+
export declare function toMap<Value>(array: Value[], key: Key): Map<Key, Value>;
|
|
128
|
+
/**
|
|
129
|
+
* - Converts an array into a map
|
|
130
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
131
|
+
* - Groups values into arrays
|
|
132
|
+
*/
|
|
133
|
+
export declare function toMap<Value>(array: Value[], key: Key, arrays: true): Map<Key, Value[]>;
|
|
134
|
+
/**
|
|
135
|
+
* - Converts an array into a map
|
|
136
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
137
|
+
*/
|
|
138
|
+
export declare function toMap<Value>(array: Value[], key: KeyCallback<Value>): Map<Key, Value>;
|
|
139
|
+
/**
|
|
140
|
+
* - Converts an array into a map
|
|
141
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
142
|
+
* - Groups values into arrays
|
|
143
|
+
*/
|
|
144
|
+
export declare function toMap<Value>(array: Value[], key: KeyCallback<Value>, arrays: true): Map<Key, Value[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Converts an array into a record, using indices as keys
|
|
147
|
+
*/
|
|
148
|
+
export declare function toRecord<Value>(array: Value[]): Record<number, Value>;
|
|
149
|
+
/**
|
|
150
|
+
* Converts an array into a record, using indices as keys and grouping values into arrays
|
|
151
|
+
*/
|
|
152
|
+
export declare function toRecord<Value>(array: Value[], arrays: true): Record<number, Value[]>;
|
|
153
|
+
/**
|
|
154
|
+
* - Converts an array into a record
|
|
155
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
156
|
+
*/
|
|
157
|
+
export declare function toRecord<Value>(array: Value[], key: Key): Record<Key, Value>;
|
|
158
|
+
/**
|
|
159
|
+
* - Converts an array into a record
|
|
160
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
161
|
+
* - Groups values into arrays
|
|
162
|
+
*/
|
|
163
|
+
export declare function toRecord<Value>(array: Value[], key: Key, arrays: true): Record<Key, Value[]>;
|
|
164
|
+
/**
|
|
165
|
+
* - Converts an array into a record
|
|
166
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
167
|
+
*/
|
|
168
|
+
export declare function toRecord<Value>(array: Value[], key: KeyCallback<Value>): Record<Key, Value>;
|
|
169
|
+
/**
|
|
170
|
+
* - Converts an array into a record
|
|
171
|
+
* - Uses `key` to find an identifcation value to use as keys
|
|
172
|
+
* - Groups values into arrays
|
|
173
|
+
*/
|
|
174
|
+
export declare function toRecord<Value>(array: Value[], key: KeyCallback<Value>, arrays: true): Record<Key, Value[]>;
|
|
175
|
+
/**
|
|
176
|
+
* Returns an array of unique items
|
|
177
|
+
*/
|
|
178
|
+
export declare function unique<Value>(array: Value[]): Value[];
|
|
179
|
+
/**
|
|
180
|
+
* - Returns an array of unique items
|
|
181
|
+
* - Use `key` to find a comparison value to match with `value`
|
|
182
|
+
*/
|
|
183
|
+
export declare function unique<Value>(array: Value[], key: Key | KeyCallback<Value>): Value[];
|
|
184
|
+
/**
|
|
185
|
+
* Flattens an array _(using native `flat` and maximum depth)_
|
|
186
|
+
*/
|
|
187
|
+
export declare function flatten<Value>(array: Value[]): NestedArrayType<Value>[];
|
|
188
|
+
/**
|
|
189
|
+
* - Pushes values to the end of an array, returning the new length
|
|
190
|
+
* - Uses chunking to avoid stack overflow
|
|
191
|
+
*/
|
|
192
|
+
export declare function push<Value>(array: Value[], values: Value[]): number;
|
|
193
|
+
|
|
194
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type Key = number | string;
|
|
4
|
+
export type ArrayCallback<Value, Returned> = (value: Value, index: number, array: Value[]) => Returned;
|
|
5
|
+
export type BooleanCallback<Value> = ArrayCallback<Value, boolean>;
|
|
6
|
+
export type Callbacks<Value> = {
|
|
7
|
+
bool?: BooleanCallback<Value>;
|
|
8
|
+
key?: KeyCallback<Value>;
|
|
9
|
+
};
|
|
10
|
+
export type FindType = "index" | "value";
|
|
11
|
+
export type InsertType = "push" | "splice";
|
|
12
|
+
export type KeyCallback<Value> = ArrayCallback<Value, Key>;
|
|
13
|
+
export type SortKey<Value> = {
|
|
14
|
+
direction: "asc" | "desc";
|
|
15
|
+
value: Key | SortKeyCallback<Value>;
|
|
16
|
+
};
|
|
17
|
+
export type SortKeyCallback<Value> = (value: Value) => Key;
|
|
18
|
+
export type SortKeyWithCallback<Value> = {
|
|
19
|
+
callback: SortKeyCallback<Value>;
|
|
20
|
+
direction: "asc" | "desc";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export type HSLColourValue = {
|
|
4
|
+
hue: number;
|
|
5
|
+
lightness: number;
|
|
6
|
+
saturation: number;
|
|
7
|
+
};
|
|
8
|
+
export declare class HSLColour extends Colour<HSLColourValue> {
|
|
9
|
+
/**
|
|
10
|
+
* Gets the current hue
|
|
11
|
+
*/
|
|
12
|
+
get hue(): number;
|
|
13
|
+
/**
|
|
14
|
+
* Sets the current hue
|
|
15
|
+
*/
|
|
16
|
+
set hue(value: number);
|
|
17
|
+
/**
|
|
18
|
+
* Gets the current lightness
|
|
19
|
+
*/
|
|
20
|
+
get lightness(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Sets the current lightness
|
|
23
|
+
*/
|
|
24
|
+
set lightness(value: number);
|
|
25
|
+
/**
|
|
26
|
+
* Gets the current saturation
|
|
27
|
+
*/
|
|
28
|
+
get saturation(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the current saturation
|
|
31
|
+
*/
|
|
32
|
+
set saturation(value: number);
|
|
33
|
+
constructor(value: HSLColourValue);
|
|
34
|
+
toHex(): HexColour;
|
|
35
|
+
/**
|
|
36
|
+
* Converts the colour to an RGB-colour
|
|
37
|
+
*/
|
|
38
|
+
toRgb(): RGBColour;
|
|
39
|
+
toString(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Convert an HSL-colour to an RGB-colour
|
|
42
|
+
*/
|
|
43
|
+
static toRgb(value: HSLColourValue): RGBColour;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get an HSL-colour from a value-object
|
|
47
|
+
*/
|
|
48
|
+
export declare function getHSLColour(value: HSLColourValue): HSLColour;
|
|
49
|
+
export declare class HexColour {
|
|
50
|
+
private readonly $colour;
|
|
51
|
+
private readonly state;
|
|
52
|
+
/**
|
|
53
|
+
* Gets the value of the colour
|
|
54
|
+
*/
|
|
55
|
+
get value(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the value of the colour
|
|
58
|
+
*/
|
|
59
|
+
set value(value: string);
|
|
60
|
+
constructor(value: string);
|
|
61
|
+
/**
|
|
62
|
+
* Convert the colour to an RGB-colour
|
|
63
|
+
*/
|
|
64
|
+
toHsl(): HSLColour;
|
|
65
|
+
/**
|
|
66
|
+
* Convert the colour to an HSL-colour
|
|
67
|
+
*/
|
|
68
|
+
toRgb(): RGBColour;
|
|
69
|
+
/**
|
|
70
|
+
* Get the colour as a string _(prefixed with #)_
|
|
71
|
+
*/
|
|
72
|
+
toString(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Convert a hex-colour to an RGB-colour
|
|
75
|
+
*/
|
|
76
|
+
static toRgb(value: string): RGBColour;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get a hex-colour from a string
|
|
80
|
+
*/
|
|
81
|
+
export declare function getHexColour(value: string): HexColour;
|
|
82
|
+
declare abstract class Colour<Model> {
|
|
83
|
+
private readonly $colour;
|
|
84
|
+
protected readonly state: ColourState<Model>;
|
|
85
|
+
/**
|
|
86
|
+
* Gets the current value of the colour
|
|
87
|
+
*/
|
|
88
|
+
get value(): Model;
|
|
89
|
+
constructor(type: string, value: Model, defaults: Model, properties: Array<keyof Model>);
|
|
90
|
+
/**
|
|
91
|
+
* Convert the colour to a hex-colour
|
|
92
|
+
*/
|
|
93
|
+
abstract toHex(): HexColour;
|
|
94
|
+
/**
|
|
95
|
+
* Get the colour as a _CSS-formatted_ string
|
|
96
|
+
*/
|
|
97
|
+
abstract toString(): string;
|
|
98
|
+
}
|
|
99
|
+
export type ColourState<Model> = {
|
|
100
|
+
value: Model;
|
|
101
|
+
};
|
|
102
|
+
export type RGBColourValue = {
|
|
103
|
+
blue: number;
|
|
104
|
+
green: number;
|
|
105
|
+
red: number;
|
|
106
|
+
};
|
|
107
|
+
export declare class RGBColour extends Colour<RGBColourValue> {
|
|
108
|
+
/**
|
|
109
|
+
* Gets the current blue value
|
|
110
|
+
*/
|
|
111
|
+
get blue(): number;
|
|
112
|
+
/**
|
|
113
|
+
* Sets the current blue value
|
|
114
|
+
*/
|
|
115
|
+
set blue(value: number);
|
|
116
|
+
/**
|
|
117
|
+
* Gets the current green value
|
|
118
|
+
*/
|
|
119
|
+
get green(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Sets the current green value
|
|
122
|
+
*/
|
|
123
|
+
set green(value: number);
|
|
124
|
+
/**
|
|
125
|
+
* Gets the current red value
|
|
126
|
+
*/
|
|
127
|
+
get red(): number;
|
|
128
|
+
/**
|
|
129
|
+
* Sets the current red value
|
|
130
|
+
*/
|
|
131
|
+
set red(value: number);
|
|
132
|
+
constructor(value: RGBColourValue);
|
|
133
|
+
toHex(): HexColour;
|
|
134
|
+
/**
|
|
135
|
+
* Convert the colour to an HSL-colour
|
|
136
|
+
*/
|
|
137
|
+
toHsl(): HSLColour;
|
|
138
|
+
toString(): string;
|
|
139
|
+
/**
|
|
140
|
+
* Convert an RGB-colour to a hex-colour
|
|
141
|
+
*/
|
|
142
|
+
static toHex(value: RGBColourValue): HexColour;
|
|
143
|
+
/**
|
|
144
|
+
* - Convert an RGB-colour to an HSL-colour
|
|
145
|
+
*/
|
|
146
|
+
static toHsl(rgb: RGBColourValue): HSLColour;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get an RGB-colour from a value-object
|
|
150
|
+
*/
|
|
151
|
+
export declare function getRGBColour(value: RGBColourValue): RGBColour;
|
|
152
|
+
/**
|
|
153
|
+
* Is the value a colour?
|
|
154
|
+
*/
|
|
155
|
+
export declare function isColour(value: unknown): value is HexColour | HSLColour | RGBColour;
|
|
156
|
+
/**
|
|
157
|
+
* Is the value a hex-colour?
|
|
158
|
+
*/
|
|
159
|
+
export declare function isHexColour(value: unknown): value is HexColour;
|
|
160
|
+
/**
|
|
161
|
+
* Is the value an HSL-colour?
|
|
162
|
+
*/
|
|
163
|
+
export declare function isHSLColour(value: unknown): value is HSLColour;
|
|
164
|
+
/**
|
|
165
|
+
* Is the value an RGB-colour?
|
|
166
|
+
*/
|
|
167
|
+
export declare function isRGBColour(value: unknown): value is RGBColour;
|
|
168
|
+
/**
|
|
169
|
+
* Get a foreground colour _(usually text)_ based on a background colour's luminance
|
|
170
|
+
*/
|
|
171
|
+
export declare function getForegroundColour(value: RGBColourValue): string;
|
|
172
|
+
|
|
173
|
+
export {};
|