adaptive-extender 0.2.5

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +1 -0
  3. package/dist/core/array.d.ts +42 -0
  4. package/dist/core/array.js +40 -0
  5. package/dist/core/array.js.map +1 -0
  6. package/dist/core/boolean.d.ts +14 -0
  7. package/dist/core/boolean.js +8 -0
  8. package/dist/core/boolean.js.map +1 -0
  9. package/dist/core/color.d.ts +369 -0
  10. package/dist/core/color.js +541 -0
  11. package/dist/core/color.js.map +1 -0
  12. package/dist/core/date.d.ts +27 -0
  13. package/dist/core/date.js +18 -0
  14. package/dist/core/date.js.map +1 -0
  15. package/dist/core/error.d.ts +20 -0
  16. package/dist/core/error.js +20 -0
  17. package/dist/core/error.js.map +1 -0
  18. package/dist/core/global.d.ts +14 -0
  19. package/dist/core/global.js +13 -0
  20. package/dist/core/global.js.map +1 -0
  21. package/dist/core/index.d.ts +17 -0
  22. package/dist/core/index.js +16 -0
  23. package/dist/core/index.js.map +1 -0
  24. package/dist/core/math.d.ts +44 -0
  25. package/dist/core/math.js +43 -0
  26. package/dist/core/math.js.map +1 -0
  27. package/dist/core/number.d.ts +59 -0
  28. package/dist/core/number.js +51 -0
  29. package/dist/core/number.js.map +1 -0
  30. package/dist/core/object.d.ts +30 -0
  31. package/dist/core/object.js +21 -0
  32. package/dist/core/object.js.map +1 -0
  33. package/dist/core/primitives.d.ts +10 -0
  34. package/dist/core/primitives.js +3 -0
  35. package/dist/core/primitives.js.map +1 -0
  36. package/dist/core/promise.d.ts +28 -0
  37. package/dist/core/promise.js +58 -0
  38. package/dist/core/promise.js.map +1 -0
  39. package/dist/core/random.d.ts +103 -0
  40. package/dist/core/random.js +114 -0
  41. package/dist/core/random.js.map +1 -0
  42. package/dist/core/string.d.ts +67 -0
  43. package/dist/core/string.js +44 -0
  44. package/dist/core/string.js.map +1 -0
  45. package/package.json +42 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.2.5 (14.08.2025)
2
+ *First stable version*
package/README.md ADDED
@@ -0,0 +1 @@
1
+ ## Adaptive extender
@@ -0,0 +1,42 @@
1
+ import "./global.js";
2
+ declare global {
3
+ interface ArrayConstructor {
4
+ /**
5
+ * Imports an array from a source.
6
+ * @param source The source to import from.
7
+ * @param name The name of the source.
8
+ * @returns The imported array.
9
+ * @throws {TypeError} If the source is not an array.
10
+ */
11
+ import(source: any, name?: string): any[];
12
+ /**
13
+ * Creates an array of integers between the specified minimum and maximum values (exclusive).
14
+ * @param min The minimum value of the range (inclusive).
15
+ * @param max The maximum value of the range (exclusive).
16
+ */
17
+ range(min: number, max: number): number[];
18
+ /**
19
+ * Combines elements from multiple iterables into tuples.
20
+ * Iteration stops when the shortest iterable is exhausted.
21
+ * @returns A generator yielding tuples.
22
+ */
23
+ zip<T extends unknown[]>(...iterables: {
24
+ [K in keyof T]: Iterable<T[K]>;
25
+ }): Generator<T, void>;
26
+ }
27
+ interface Array<T> {
28
+ /**
29
+ * Swaps the elements at the given indices in the array.
30
+ * @param index1 The index of the first element.
31
+ * @param index2 The index of the second element.
32
+ */
33
+ swap(index1: number, index2: number): void;
34
+ /**
35
+ * Resizes the array to a specified length, filling with a default value if extended.
36
+ * @param length The new length of the array.
37
+ * @param _default The value used to fill when the array grows.
38
+ */
39
+ resize(length: number, _default: T): T[];
40
+ }
41
+ }
42
+ export {};
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ import "./global.js";
3
+ const { trunc } = Math;
4
+ Array.import = function (source, name = "[source]") {
5
+ if (!Array.isArray(source))
6
+ throw new TypeError(`Unable to import array from ${name} due its ${typename(source)} type`);
7
+ return source;
8
+ };
9
+ Array.range = function (min, max) {
10
+ min = trunc(min);
11
+ max = trunc(max);
12
+ const array = [];
13
+ for (let index = 0; index < max - min; index++) {
14
+ array.push(index + min);
15
+ }
16
+ return array;
17
+ };
18
+ Array.zip = function* (...iterables) {
19
+ const iterators = iterables.map(iterable => iterable[Symbol.iterator]());
20
+ while (true) {
21
+ const results = iterators.map(iterator => iterator.next());
22
+ if (results.some(result => result.done))
23
+ break;
24
+ yield results.map(result => result.value);
25
+ }
26
+ };
27
+ Array.prototype.swap = function (index1, index2) {
28
+ index1 = trunc(index1);
29
+ index2 = trunc(index2);
30
+ const temporary = this[index1];
31
+ this[index1] = this[index2];
32
+ this[index2] = temporary;
33
+ };
34
+ Array.prototype.resize = function (length, _default) {
35
+ while (length > this.length)
36
+ this.push(_default);
37
+ this.length = length;
38
+ return this;
39
+ };
40
+ //# sourceMappingURL=array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/core/array.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,aAAa,CAAC;AAErB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;AA0CvB,KAAK,CAAC,MAAM,GAAG,UAAU,MAAW,EAAE,OAAe,UAAU;IAC9D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,+BAA+B,IAAI,YAAY,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxH,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,KAAK,CAAC,KAAK,GAAG,UAAU,GAAW,EAAE,GAAW;IAC/C,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,GAAG,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF,KAAK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.
6
+ * @param source The source value to import.
7
+ * @param name The name of the source value.
8
+ * @returns The imported boolean value.
9
+ * @throws {TypeError} If the source is not a boolean.
10
+ */
11
+ import(source: any, name?: string): boolean;
12
+ }
13
+ }
14
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ import "./global.js";
3
+ Boolean.import = function (source, name = "[source]") {
4
+ if (typeof (source) !== "boolean")
5
+ throw new TypeError(`Unable to import boolean from ${name} due its ${typename(source)} type`);
6
+ return source.valueOf();
7
+ };
8
+ //# sourceMappingURL=boolean.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/core/boolean.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,aAAa,CAAC;AAerB,OAAO,CAAC,MAAM,GAAG,UAAU,MAAW,EAAE,OAAe,UAAU;IAChE,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,iCAAiC,IAAI,YAAY,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACjI,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC,CAAC"}
@@ -0,0 +1,369 @@
1
+ import "./number.js";
2
+ import "./string.js";
3
+ /**
4
+ * Represents available color formats.
5
+ */
6
+ declare enum ColorFormats {
7
+ rgb = "RGB",
8
+ hsl = "HSL",
9
+ hex = "HEX"
10
+ }
11
+ interface ColorProperties {
12
+ /**
13
+ * Indicates whether the alpha channel is included.
14
+ */
15
+ deep: boolean;
16
+ /**
17
+ * The output format of the color.
18
+ */
19
+ format: ColorFormats;
20
+ }
21
+ /**
22
+ * Represents a color in RGB, HSL, or HEX format with support for alpha channel,
23
+ * conversion between formats, creation from components, and parsing from strings.
24
+ */
25
+ declare class Color {
26
+ #private;
27
+ /**
28
+ * Gets the red color component.
29
+ */
30
+ get red(): number;
31
+ /**
32
+ * Sets the red color component.
33
+ */
34
+ set red(value: number);
35
+ /**
36
+ * Gets the green color component.
37
+ */
38
+ get green(): number;
39
+ /**
40
+ * Sets the green color component.
41
+ */
42
+ set green(value: number);
43
+ /**
44
+ * Gets the blue color component.
45
+ */
46
+ get blue(): number;
47
+ /**
48
+ * Sets the blue color component.
49
+ */
50
+ set blue(value: number);
51
+ /**
52
+ * Gets the hue color component.
53
+ */
54
+ get hue(): number;
55
+ /**
56
+ * Sets the hue color component.
57
+ */
58
+ set hue(value: number);
59
+ /**
60
+ * Gets the saturation color component.
61
+ */
62
+ get saturation(): number;
63
+ /**
64
+ * Sets the saturation color component.
65
+ */
66
+ set saturation(value: number);
67
+ /**
68
+ * Gets the lightness color component.
69
+ */
70
+ get lightness(): number;
71
+ /**
72
+ * Sets the lightness color component.
73
+ */
74
+ set lightness(value: number);
75
+ /**
76
+ * Gets the alpha color component.
77
+ */
78
+ get alpha(): number;
79
+ /**
80
+ * Sets the alpha color component.
81
+ */
82
+ set alpha(value: number);
83
+ /**
84
+ * Creates a new black color.
85
+ */
86
+ constructor();
87
+ /**
88
+ * Copies values from another color.
89
+ * @param source The source color to copy from.
90
+ */
91
+ constructor(source: Readonly<Color>);
92
+ /**
93
+ * Creates a color from RGB components.
94
+ * @throws {Error} If any component is not a finite number.
95
+ */
96
+ static fromRGB(red: number, green: number, blue: number): Color;
97
+ /**
98
+ * Creates a color from RGB components with alpha channel.
99
+ * @throws {Error} If any component is not a finite number.
100
+ */
101
+ static fromRGB(red: number, green: number, blue: number, alpha: number): Color;
102
+ /**
103
+ * Creates a color from HSL components.
104
+ * @param hue The hue component.
105
+ * @param saturation The saturation component.
106
+ * @param lightness The lightness component.
107
+ * @returns A new color instance.
108
+ * @throws {Error} If any component is not a finite number.
109
+ */
110
+ static fromHSL(hue: number, saturation: number, lightness: number): Color;
111
+ /**
112
+ * Creates a color from HSL components with alpha channel.
113
+ * @param hue The hue component.
114
+ * @param saturation The saturation component.
115
+ * @param lightness The lightness component.
116
+ * @param alpha The alpha channel value.
117
+ * @returns A new color instance.
118
+ * @throws {Error} If any component is not a finite number.
119
+ */
120
+ static fromHSL(hue: number, saturation: number, lightness: number, alpha: number): Color;
121
+ /**
122
+ * Attempts to create a color from a string using all color variations.
123
+ * @param string The string to parse.
124
+ * @returns The parsed color or null if parsing fails.
125
+ */
126
+ static tryParse(string: string): Color | null;
127
+ /**
128
+ * Attempts to create a color from a string using the specified variations.
129
+ * @param string The string to parse.
130
+ * @param options The options for variations.
131
+ * @returns The parsed color or null if parsing fails.
132
+ */
133
+ static tryParse(string: string, options: Partial<ColorProperties>): Color | null;
134
+ /**
135
+ * Parses a color from a string using all color variations.
136
+ * @param string The string to parse.
137
+ * @returns The parsed color.
138
+ * @throws {SyntaxError} If parsing fails for all color variations.
139
+ */
140
+ static parse(string: string): Color;
141
+ /**
142
+ * Parses a color from a string using the specified variations.
143
+ * @param string The string to parse.
144
+ * @param options The options for variations.
145
+ * @returns The parsed color.
146
+ * @throws {SyntaxError} If parsing fails for the specified variations.
147
+ */
148
+ static parse(string: string, options: Partial<ColorProperties>): Color;
149
+ /**
150
+ * Returns a string representation of the color in RGB format by default.
151
+ * @returns The string representation of the color.
152
+ */
153
+ toString(): string;
154
+ /**
155
+ * Returns a string representation of the color using the specified options.
156
+ * @param options The options to define the output format and alpha channel inclusion.
157
+ * @returns The string representation of the color.
158
+ * @throws {Error} If the specified color format is invalid.
159
+ */
160
+ toString(options: Partial<ColorProperties>): string;
161
+ /**
162
+ * Transparent color preset.
163
+ * @readonly
164
+ */
165
+ static get newTransparent(): Color;
166
+ /**
167
+ * Maroon color preset.
168
+ * @readonly
169
+ */
170
+ static get newMaroon(): Color;
171
+ /**
172
+ * Red color preset.
173
+ * @readonly
174
+ */
175
+ static get newRed(): Color;
176
+ /**
177
+ * Orange color preset.
178
+ * @readonly
179
+ */
180
+ static get newOrange(): Color;
181
+ /**
182
+ * Yellow color preset.
183
+ * @readonly
184
+ */
185
+ static get newYellow(): Color;
186
+ /**
187
+ * Olive color preset.
188
+ * @readonly
189
+ */
190
+ static get newOlive(): Color;
191
+ /**
192
+ * Green color preset.
193
+ * @readonly
194
+ */
195
+ static get newGreen(): Color;
196
+ /**
197
+ * Purple color preset.
198
+ * @readonly
199
+ */
200
+ static get newPurple(): Color;
201
+ /**
202
+ * Fuchsia color preset.
203
+ * @readonly
204
+ */
205
+ static get newFuchsia(): Color;
206
+ /**
207
+ * Lime color preset.
208
+ * @readonly
209
+ */
210
+ static get newLime(): Color;
211
+ /**
212
+ * Teal color preset.
213
+ * @readonly
214
+ */
215
+ static get newTeal(): Color;
216
+ /**
217
+ * Aqua color preset.
218
+ * @readonly
219
+ */
220
+ static get newAqua(): Color;
221
+ /**
222
+ * Blue color preset.
223
+ * @readonly
224
+ */
225
+ static get newBlue(): Color;
226
+ /**
227
+ * Navy color preset.
228
+ * @readonly
229
+ */
230
+ static get newNavy(): Color;
231
+ /**
232
+ * Black color preset.
233
+ * @readonly
234
+ */
235
+ static get newBlack(): Color;
236
+ /**
237
+ * Gray color preset.
238
+ * @readonly
239
+ */
240
+ static get newGray(): Color;
241
+ /**
242
+ * Silver color preset.
243
+ * @readonly
244
+ */
245
+ static get newSilver(): Color;
246
+ /**
247
+ * White color preset.
248
+ * @readonly
249
+ */
250
+ static get newWhite(): Color;
251
+ /**
252
+ * Creates a new color by mixing two colors evenly.
253
+ * @param first The first color.
254
+ * @param second The second color.
255
+ * @returns The new mixed color.
256
+ */
257
+ static mix(first: Readonly<Color>, second: Readonly<Color>): Color;
258
+ /**
259
+ * Creates a new color by mixing two colors by the given ratio.
260
+ * @param first The first color.
261
+ * @param second The second color.
262
+ * @param ratio Ratio between the first and second color [0 - 1].
263
+ * @returns The new mixed color.
264
+ * @throws {Error} If `ratio` is not a finite number.
265
+ */
266
+ static mix(first: Readonly<Color>, second: Readonly<Color>, ratio: number): Color;
267
+ /**
268
+ * Converts the current color to grayscale with full scale.
269
+ * @returns The modified current color.
270
+ */
271
+ grayscale(): Color;
272
+ /**
273
+ * Converts the current color to grayscale by the given scale.
274
+ * @param scale Grayscale scale [0 - 1].
275
+ * @returns The modified current color.
276
+ * @throws {Error} If `scale` is not a finite number.
277
+ */
278
+ grayscale(scale: number): Color;
279
+ /**
280
+ * Emphasizes the red channel fully on the current color.
281
+ * @returns The modified current color.
282
+ */
283
+ redEmphasis(): Color;
284
+ /**
285
+ * Emphasizes the red channel by the given scale on the current color.
286
+ * @param scale Emphasis scale [0 - 1].
287
+ * @returns The modified current color.
288
+ * @throws {Error} If `scale` is not a finite number.
289
+ */
290
+ redEmphasis(scale: number): Color;
291
+ /**
292
+ * Emphasizes the green channel fully on the current color.
293
+ * @returns The modified current color.
294
+ */
295
+ greenEmphasis(): Color;
296
+ /**
297
+ * Emphasizes the green channel by the given scale on the current color.
298
+ * @param scale Emphasis scale [0 - 1].
299
+ * @returns The modified current color.
300
+ * @throws {Error} If `scale` is not a finite number.
301
+ */
302
+ greenEmphasis(scale: number): Color;
303
+ /**
304
+ * Emphasizes the blue channel fully on the current color.
305
+ * @returns The modified current color.
306
+ */
307
+ blueEmphasis(): Color;
308
+ /**
309
+ * Emphasizes the blue channel by the given scale on the current color.
310
+ * @param scale Emphasis scale [0 - 1].
311
+ * @returns The modified current color.
312
+ * @throws {Error} If `scale` is not a finite number.
313
+ */
314
+ blueEmphasis(scale: number): Color;
315
+ /**
316
+ * Inverts the current color fully.
317
+ * @returns The modified current color.
318
+ */
319
+ invert(): Color;
320
+ /**
321
+ * Inverts the current color by the given scale.
322
+ * @param scale Inversion scale [0 - 1].
323
+ * @returns The modified current color.
324
+ * @throws {Error} If `scale` is not a finite number.
325
+ */
326
+ invert(scale: number): Color;
327
+ /**
328
+ * Applies full sepia filter on the current color.
329
+ * @returns The modified current color.
330
+ */
331
+ sepia(): Color;
332
+ /**
333
+ * Applies sepia filter by the given scale on the current color.
334
+ * @param scale Sepia scale [0 - 1].
335
+ * @returns The modified current color.
336
+ * @throws {Error} If `scale` is not a finite number.
337
+ */
338
+ sepia(scale: number): Color;
339
+ /**
340
+ * Rotates the hue of the current color by the given angle in degrees.
341
+ * @param angle Rotation angle in degrees.
342
+ * @returns The modified current color.
343
+ * @throws {Error} If `angle` is not a finite number.
344
+ */
345
+ rotate(angle: number): Color;
346
+ /**
347
+ * Sets the saturation of the current color by scale.
348
+ * @param scale Saturation scale [0 - 1].
349
+ * @returns The modified current color.
350
+ * @throws {Error} If `scale` is not a finite number.
351
+ */
352
+ saturate(scale: number): Color;
353
+ /**
354
+ * Sets the lightness of the current color by scale.
355
+ * @param scale Lightness scale [0 - 1].
356
+ * @returns The modified current color.
357
+ * @throws {Error} If `scale` is not a finite number.
358
+ */
359
+ illuminate(scale: number): Color;
360
+ /**
361
+ * Sets the alpha of the current color.
362
+ * @param scale Alpha value [0 - 1].
363
+ * @returns The modified current color.
364
+ * @throws {Error} If `scale` is not a finite number.
365
+ */
366
+ pass(scale: number): Color;
367
+ }
368
+ export { ColorProperties };
369
+ export { ColorFormats, Color };