@bitbybit-dev/base 0.19.8 → 0.19.9

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 (61) hide show
  1. package/babel.config.cjs +1 -0
  2. package/babel.config.d.cts +5 -0
  3. package/index.d.ts +1 -0
  4. package/{index.ts → index.js} +1 -2
  5. package/lib/api/index.js +1 -0
  6. package/lib/api/inputs/base-inputs.d.ts +35 -0
  7. package/lib/api/inputs/base-inputs.js +1 -0
  8. package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
  9. package/lib/api/inputs/color-inputs.js +164 -0
  10. package/lib/api/inputs/index.js +9 -0
  11. package/lib/api/inputs/inputs.js +9 -0
  12. package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
  13. package/lib/api/inputs/lists-inputs.js +576 -0
  14. package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
  15. package/lib/api/inputs/logic-inputs.js +111 -0
  16. package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
  17. package/lib/api/inputs/math-inputs.js +391 -0
  18. package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
  19. package/lib/api/inputs/point-inputs.js +521 -0
  20. package/lib/api/inputs/text-inputs.d.ts +83 -0
  21. package/lib/api/inputs/text-inputs.js +120 -0
  22. package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
  23. package/lib/api/inputs/transforms-inputs.js +200 -0
  24. package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
  25. package/lib/api/inputs/vector-inputs.js +304 -0
  26. package/lib/api/services/color.d.ts +114 -0
  27. package/lib/api/services/{color.ts → color.js} +15 -34
  28. package/lib/api/services/geometry-helper.d.ts +15 -0
  29. package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
  30. package/lib/api/services/{index.ts → index.d.ts} +1 -1
  31. package/lib/api/services/index.js +9 -0
  32. package/lib/api/services/lists.d.ts +287 -0
  33. package/lib/api/services/{lists.ts → lists.js} +59 -83
  34. package/lib/api/services/logic.d.ts +99 -0
  35. package/lib/api/services/{logic.ts → logic.js} +24 -32
  36. package/lib/api/services/math.d.ts +349 -0
  37. package/lib/api/services/{math.ts → math.js} +71 -136
  38. package/lib/api/services/point.d.ts +222 -0
  39. package/lib/api/services/{point.ts → point.js} +32 -67
  40. package/lib/api/services/text.d.ts +69 -0
  41. package/lib/api/services/{text.ts → text.js} +7 -17
  42. package/lib/api/services/transforms.d.ts +122 -0
  43. package/lib/api/services/{transforms.ts → transforms.js} +37 -83
  44. package/lib/api/services/vector.d.ts +320 -0
  45. package/lib/api/services/{vector.ts → vector.js} +42 -80
  46. package/lib/{index.ts → index.d.ts} +0 -1
  47. package/lib/index.js +1 -0
  48. package/package.json +1 -1
  49. package/lib/api/inputs/base-inputs.ts +0 -18
  50. package/lib/api/inputs/text-inputs.ts +0 -108
  51. package/lib/api/services/color.test.ts +0 -86
  52. package/lib/api/services/lists.test.ts +0 -612
  53. package/lib/api/services/logic.test.ts +0 -187
  54. package/lib/api/services/math.test.ts +0 -622
  55. package/lib/api/services/text.test.ts +0 -55
  56. package/lib/api/services/vector.test.ts +0 -360
  57. package/tsconfig.bitbybit.json +0 -26
  58. package/tsconfig.json +0 -24
  59. /package/lib/api/{index.ts → index.d.ts} +0 -0
  60. /package/lib/api/inputs/{index.ts → index.d.ts} +0 -0
  61. /package/lib/api/inputs/{inputs.ts → inputs.d.ts} +0 -0
@@ -1,10 +1,7 @@
1
- import * as Inputs from "../inputs";
2
-
3
1
  /**
4
2
  * Contains various logic methods.
5
3
  */
6
4
  export class Logic {
7
-
8
5
  /**
9
6
  * Creates a boolean value - true or false
10
7
  * @param inputs a true or false boolean
@@ -13,10 +10,9 @@ export class Logic {
13
10
  * @shortname boolean
14
11
  * @drawable false
15
12
  */
16
- boolean(inputs: Inputs.Logic.BooleanDto): boolean {
13
+ boolean(inputs) {
17
14
  return inputs.boolean;
18
15
  }
19
-
20
16
  /**
21
17
  * Creates a random boolean list of predefined length
22
18
  * @param inputs a length and a threshold for randomization of true values
@@ -25,17 +21,16 @@ export class Logic {
25
21
  * @shortname random booleans
26
22
  * @drawable false
27
23
  */
28
- randomBooleans(inputs: Inputs.Logic.RandomBooleansDto): boolean[] {
24
+ randomBooleans(inputs) {
29
25
  const booleans = [];
30
26
  for (let i = 0; i < inputs.length; i++) {
31
27
  booleans.push(Math.random() < inputs.trueThreshold);
32
28
  }
33
29
  return booleans;
34
30
  }
35
-
36
31
  /**
37
- * Creates a random boolean list of true and false values based on a list of numbers.
38
- * All values between true threshold will be true, all values above false threshold will be false,
32
+ * Creates a random boolean list of true and false values based on a list of numbers.
33
+ * All values between true threshold will be true, all values above false threshold will be false,
39
34
  * and the rest will be distributed between true and false based on the number of levels in a gradient pattern.
40
35
  * That means that the closer the number gets to the false threshold the bigger the chance will be to get random false value.
41
36
  * @param inputs a length and a threshold for randomization of true values
@@ -44,14 +39,16 @@ export class Logic {
44
39
  * @shortname 2 threshold random gradient
45
40
  * @drawable false
46
41
  */
47
- twoThresholdRandomGradient(inputs: Inputs.Logic.TwoThresholdRandomGradientDto): boolean[] {
42
+ twoThresholdRandomGradient(inputs) {
48
43
  const booleans = [];
49
44
  inputs.numbers.forEach(n => {
50
45
  if (n < inputs.thresholdTotalTrue) {
51
46
  booleans.push(true);
52
- } else if (n > inputs.thresholdTotalFalse) {
47
+ }
48
+ else if (n > inputs.thresholdTotalFalse) {
53
49
  booleans.push(false);
54
- } else {
50
+ }
51
+ else {
55
52
  const leveledNr = n - inputs.thresholdTotalTrue;
56
53
  const step = (inputs.thresholdTotalFalse - inputs.thresholdTotalTrue) / inputs.nrLevels;
57
54
  const whichCat = Math.ceil(leveledNr / step);
@@ -59,14 +56,14 @@ export class Logic {
59
56
  const random = Math.random();
60
57
  if (random > bound) {
61
58
  booleans.push(true);
62
- } else {
59
+ }
60
+ else {
63
61
  booleans.push(false);
64
62
  }
65
63
  }
66
64
  });
67
65
  return booleans;
68
66
  }
69
-
70
67
  /**
71
68
  * Creates a boolean list based on a list of numbers and a threshold.
72
69
  * @param inputs a length and a threshold for randomization of true values
@@ -75,12 +72,13 @@ export class Logic {
75
72
  * @shortname threshold boolean list
76
73
  * @drawable false
77
74
  */
78
- thresholdBooleanList(inputs: Inputs.Logic.ThresholdBooleanListDto): boolean[] {
75
+ thresholdBooleanList(inputs) {
79
76
  const booleans = [];
80
77
  inputs.numbers.forEach(n => {
81
78
  if (n < inputs.threshold) {
82
79
  booleans.push(true);
83
- } else {
80
+ }
81
+ else {
84
82
  booleans.push(false);
85
83
  }
86
84
  });
@@ -89,7 +87,6 @@ export class Logic {
89
87
  }
90
88
  return booleans;
91
89
  }
92
-
93
90
  /**
94
91
  * Creates a boolean list based on a list of numbers and a gap thresholds. Gap thresholds are pairs of numbers that define a range of numbers that will be true.
95
92
  * @param inputs a length and a threshold for randomization of true values
@@ -98,9 +95,8 @@ export class Logic {
98
95
  * @shortname threshold gaps boolean list
99
96
  * @drawable false
100
97
  */
101
- thresholdGapsBooleanList(inputs: Inputs.Logic.ThresholdGapsBooleanListDto): boolean[] {
98
+ thresholdGapsBooleanList(inputs) {
102
99
  const booleans = [];
103
-
104
100
  inputs.numbers.forEach(n => {
105
101
  let foundInThresholds = false;
106
102
  inputs.gapThresholds.forEach(t => {
@@ -120,7 +116,6 @@ export class Logic {
120
116
  }
121
117
  return booleans;
122
118
  }
123
-
124
119
  /**
125
120
  * Apply not operator on the boolean
126
121
  * @param inputs a true or false boolean
@@ -129,10 +124,9 @@ export class Logic {
129
124
  * @shortname not
130
125
  * @drawable false
131
126
  */
132
- not(inputs: Inputs.Logic.BooleanDto): boolean {
127
+ not(inputs) {
133
128
  return !inputs.boolean;
134
129
  }
135
-
136
130
  /**
137
131
  * Apply not operator on a list of booleans
138
132
  * @param inputs a list of true or false booleans
@@ -141,10 +135,9 @@ export class Logic {
141
135
  * @shortname not list
142
136
  * @drawable false
143
137
  */
144
- notList(inputs: Inputs.Logic.BooleanListDto): boolean[] {
138
+ notList(inputs) {
145
139
  return inputs.booleans.map(b => !b);
146
140
  }
147
-
148
141
  /**
149
142
  * Does comparison between first and second values
150
143
  * @param inputs two values to be compared
@@ -153,7 +146,7 @@ export class Logic {
153
146
  * @shortname compare
154
147
  * @drawable false
155
148
  */
156
- compare<T>(inputs: Inputs.Logic.ComparisonDto<T>): boolean {
149
+ compare(inputs) {
157
150
  switch (inputs.operator) {
158
151
  case "==":
159
152
  return inputs.first == inputs.second;
@@ -175,7 +168,6 @@ export class Logic {
175
168
  return false;
176
169
  }
177
170
  }
178
-
179
171
  /**
180
172
  * Transmits a value if boolean provided is true and undefined if boolean provided is false
181
173
  * @param inputs a value and a boolean value
@@ -184,10 +176,9 @@ export class Logic {
184
176
  * @shortname value gate
185
177
  * @drawable false
186
178
  */
187
- valueGate<T>(inputs: Inputs.Logic.ValueGateDto<T>): T | undefined {
179
+ valueGate(inputs) {
188
180
  return inputs.boolean ? inputs.value : undefined;
189
181
  }
190
-
191
182
  /**
192
183
  * Returns first defined value out of two
193
184
  * @param inputs two values
@@ -196,16 +187,17 @@ export class Logic {
196
187
  * @shortname first defined value gate
197
188
  * @drawable false
198
189
  */
199
- firstDefinedValueGate<T, U>(inputs: Inputs.Logic.TwoValueGateDto<T, U>): T | U | undefined {
190
+ firstDefinedValueGate(inputs) {
200
191
  let res;
201
192
  if (inputs.value1 !== undefined) {
202
193
  res = inputs.value1;
203
- } else if (inputs.value2 !== undefined) {
194
+ }
195
+ else if (inputs.value2 !== undefined) {
204
196
  res = inputs.value2;
205
- } else {
197
+ }
198
+ else {
206
199
  res = undefined;
207
200
  }
208
201
  return res;
209
202
  }
210
-
211
203
  }
@@ -0,0 +1,349 @@
1
+ import * as Inputs from "../inputs";
2
+ /**
3
+ * Contains various math methods.
4
+ */
5
+ export declare class MathBitByBit {
6
+ /**
7
+ * Creates a number
8
+ * @param inputs a number to be created
9
+ * @returns number
10
+ * @group create
11
+ * @shortname number
12
+ * @drawable false
13
+ */
14
+ number(inputs: Inputs.Math.NumberDto): number;
15
+ /**
16
+ * Does basic math operations
17
+ * @param inputs two numbers and operator
18
+ * @returns Result of math operation action
19
+ * @group operations
20
+ * @shortname two numbers
21
+ * @drawable false
22
+ */
23
+ twoNrOperation(inputs: Inputs.Math.ActionOnTwoNumbersDto): number;
24
+ /**
25
+ * Does modulus operation
26
+ * @param inputs two numbers and operator
27
+ * @returns Result of modulus operation
28
+ * @group operations
29
+ * @shortname modulus
30
+ * @drawable false
31
+ */
32
+ modulus(inputs: Inputs.Math.ModulusDto): number;
33
+ /**
34
+ * Does rounding to decimals
35
+ * @param inputs a number and decimal places
36
+ * @returns Result of rounding
37
+ * @group operations
38
+ * @shortname round to decimals
39
+ * @drawable false
40
+ */
41
+ roundToDecimals(inputs: Inputs.Math.RoundToDecimalsDto): number;
42
+ /**
43
+ * Does basic math operations on one number
44
+ * @param inputs one number and operator action
45
+ * @returns Result of math operation
46
+ * @group operations
47
+ * @shortname one number
48
+ * @drawable false
49
+ */
50
+ oneNrOperation(inputs: Inputs.Math.ActionOnOneNumberDto): number;
51
+ /**
52
+ * Remaps a number from one range to another
53
+ * @param inputs one number and operator action
54
+ * @returns Result of mapping
55
+ * @group operations
56
+ * @shortname remap
57
+ * @drawable false
58
+ */
59
+ remap(inputs: Inputs.Math.RemapNumberDto): number;
60
+ /**
61
+ * Creates a random number between 0 and 1
62
+ * @returns A random number between 0 and 1
63
+ * @group generate
64
+ * @shortname random 0 - 1
65
+ * @drawable false
66
+ */
67
+ random(): number;
68
+ /**
69
+ * Creates a random number between low and high value
70
+ * @param inputs low and high numbers
71
+ * @returns A random number
72
+ * @group generate
73
+ * @shortname random number
74
+ * @drawable false
75
+ */
76
+ randomNumber(inputs: Inputs.Math.RandomNumberDto): number;
77
+ /**
78
+ * Creates random numbers between low and high values
79
+ * @param inputs low and high numbers
80
+ * @returns A list of random numbers
81
+ * @group generate
82
+ * @shortname random numbers
83
+ * @drawable false
84
+ */
85
+ randomNumbers(inputs: Inputs.Math.RandomNumbersDto): number[];
86
+ /**
87
+ * Creates a PI number
88
+ * @returns A number PI
89
+ * @group generate
90
+ * @shortname π
91
+ * @drawable false
92
+ */
93
+ pi(): number;
94
+ /**
95
+ * Rounds the number to decimal places
96
+ * @param inputs a number to be rounded to decimal places
97
+ * @returns number
98
+ * @group operations
99
+ * @shortname to fixed
100
+ * @drawable false
101
+ */
102
+ toFixed(inputs: Inputs.Math.ToFixedDto): string;
103
+ /**
104
+ * Adds two numbers
105
+ * @param inputs two numbers
106
+ * @returns number
107
+ * @group basics
108
+ * @shortname add
109
+ * @drawable false
110
+ */
111
+ add(inputs: Inputs.Math.TwoNumbersDto): number;
112
+ /**
113
+ * Subtracts two numbers
114
+ * @param inputs two numbers
115
+ * @returns number
116
+ * @group basics
117
+ * @shortname subtract
118
+ * @drawable false
119
+ */
120
+ subtract(inputs: Inputs.Math.TwoNumbersDto): number;
121
+ /**
122
+ * Multiplies two numbers
123
+ * @param inputs two numbers
124
+ * @returns number
125
+ * @group basics
126
+ * @shortname multiply
127
+ * @drawable false
128
+ */
129
+ multiply(inputs: Inputs.Math.TwoNumbersDto): number;
130
+ /**
131
+ * Divides two numbers
132
+ * @param inputs two numbers
133
+ * @returns number
134
+ * @group basics
135
+ * @shortname divide
136
+ * @drawable false
137
+ */
138
+ divide(inputs: Inputs.Math.TwoNumbersDto): number;
139
+ /**
140
+ * Powers a number
141
+ * @param inputs two numbers
142
+ * @returns number
143
+ * @group basics
144
+ * @shortname power
145
+ * @drawable false
146
+ */
147
+ power(inputs: Inputs.Math.TwoNumbersDto): number;
148
+ /**
149
+ * Gets the square root of a number
150
+ * @param inputs a number
151
+ * @returns number
152
+ * @group basics
153
+ * @shortname sqrt
154
+ * @drawable false
155
+ */
156
+ sqrt(inputs: Inputs.Math.NumberDto): number;
157
+ /**
158
+ * Gets the absolute value of a number
159
+ * @param inputs a number
160
+ * @returns number
161
+ * @group basics
162
+ * @shortname abs
163
+ * @drawable false
164
+ */
165
+ abs(inputs: Inputs.Math.NumberDto): number;
166
+ /**
167
+ * Rounds a number
168
+ * @param inputs a number
169
+ * @returns number
170
+ * @group basics
171
+ * @shortname round
172
+ * @drawable false
173
+ */
174
+ round(inputs: Inputs.Math.NumberDto): number;
175
+ /**
176
+ * Floors a number
177
+ * @param inputs a number
178
+ * @returns number
179
+ * @group basics
180
+ * @shortname floor
181
+ * @drawable false
182
+ */
183
+ floor(inputs: Inputs.Math.NumberDto): number;
184
+ /**
185
+ * Ceils a number
186
+ * @param inputs a number
187
+ * @returns number
188
+ * @group basics
189
+ * @shortname ceil
190
+ * @drawable false
191
+ */
192
+ ceil(inputs: Inputs.Math.NumberDto): number;
193
+ /**
194
+ * Negates a number
195
+ * @param inputs a number
196
+ * @returns number
197
+ * @group basics
198
+ * @shortname negate
199
+ * @drawable false
200
+ */
201
+ negate(inputs: Inputs.Math.NumberDto): number;
202
+ /**
203
+ * Gets the natural logarithm of a number
204
+ * @param inputs a number
205
+ * @returns number
206
+ * @group basics
207
+ * @shortname ln
208
+ * @drawable false
209
+ */
210
+ ln(inputs: Inputs.Math.NumberDto): number;
211
+ /**
212
+ * Gets the base 10 logarithm of a number
213
+ * @param inputs a number
214
+ * @returns number
215
+ * @group basics
216
+ * @shortname log10
217
+ * @drawable false
218
+ */
219
+ log10(inputs: Inputs.Math.NumberDto): number;
220
+ /**
221
+ * Raises 10 to the power of a number
222
+ * @param inputs a number
223
+ * @returns number
224
+ * @group basics
225
+ * @shortname ten pow
226
+ * @drawable false
227
+ */
228
+ tenPow(inputs: Inputs.Math.NumberDto): number;
229
+ /**
230
+ * Gets the sine of a number
231
+ * @param inputs a number
232
+ * @returns number
233
+ * @group basics
234
+ * @shortname sin
235
+ * @drawable false
236
+ */
237
+ sin(inputs: Inputs.Math.NumberDto): number;
238
+ /**
239
+ * Gets the cosine of a number
240
+ * @param inputs a number
241
+ * @returns number
242
+ * @group basics
243
+ * @shortname cos
244
+ * @drawable false
245
+ */
246
+ cos(inputs: Inputs.Math.NumberDto): number;
247
+ /**
248
+ * Gets the tangent of a number
249
+ * @param inputs a number
250
+ * @returns number
251
+ * @group basics
252
+ * @shortname tan
253
+ * @drawable false
254
+ */
255
+ tan(inputs: Inputs.Math.NumberDto): number;
256
+ /**
257
+ * Gets the arcsine of a number
258
+ * @param inputs a number
259
+ * @returns number
260
+ * @group basics
261
+ * @shortname asin
262
+ * @drawable false
263
+ */
264
+ asin(inputs: Inputs.Math.NumberDto): number;
265
+ /**
266
+ * Gets the arccosine of a number
267
+ * @param inputs a number
268
+ * @returns number
269
+ * @group basics
270
+ * @shortname acos
271
+ * @drawable false
272
+ */
273
+ acos(inputs: Inputs.Math.NumberDto): number;
274
+ /**
275
+ * Gets the arctangent of a number
276
+ * @param inputs a number
277
+ * @returns number
278
+ * @group basics
279
+ * @shortname atan
280
+ * @drawable false
281
+ */
282
+ atan(inputs: Inputs.Math.NumberDto): number;
283
+ /**
284
+ * Gets the natural exponent of a number
285
+ * @param inputs a number
286
+ * @returns number
287
+ * @group basics
288
+ * @shortname exp
289
+ * @drawable false
290
+ */
291
+ exp(inputs: Inputs.Math.NumberDto): number;
292
+ /**
293
+ * Converts degrees to radians
294
+ * @param inputs a number in degrees
295
+ * @returns number
296
+ * @group basics
297
+ * @shortname deg to rad
298
+ * @drawable false
299
+ */
300
+ degToRad(inputs: Inputs.Math.NumberDto): number;
301
+ /**
302
+ * Converts radians to degrees
303
+ * @param inputs a number in radians
304
+ * @returns number
305
+ * @group basics
306
+ * @shortname rad to deg
307
+ * @drawable false
308
+ */
309
+ radToDeg(inputs: Inputs.Math.NumberDto): number;
310
+ /**
311
+ * Eases a number by providing x parameter 0-1 and a range of output values
312
+ * @param inputs a number, min and max values, and ease type
313
+ * @returns number
314
+ * @group operations
315
+ * @shortname ease
316
+ * @drawable false
317
+ */
318
+ ease(inputs: Inputs.Math.EaseDto): number;
319
+ private easeInSine;
320
+ private easeOutSine;
321
+ private easeInOutSine;
322
+ private easeInQuad;
323
+ private easeOutQuad;
324
+ private easeInOutQuad;
325
+ private easeInCubic;
326
+ private easeOutCubic;
327
+ private easeInOutCubic;
328
+ private easeInQuart;
329
+ private easeOutQuart;
330
+ private easeInOutQuart;
331
+ private easeInQuint;
332
+ private easeOutQuint;
333
+ private easeInOutQuint;
334
+ private easeInExpo;
335
+ private easeOutExpo;
336
+ private easeInOutExpo;
337
+ private easeInCirc;
338
+ private easeOutCirc;
339
+ private easeInOutCirc;
340
+ private easeInBack;
341
+ private easeOutBack;
342
+ private easeInOutBack;
343
+ private easeInElastic;
344
+ private easeOutElastic;
345
+ private easeInOutElastic;
346
+ private easeInBounce;
347
+ private easeOutBounce;
348
+ private easeInOutBounce;
349
+ }