@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.
- package/babel.config.cjs +1 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/{index.ts → index.js} +1 -2
- package/lib/api/index.js +1 -0
- package/lib/api/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +1 -0
- package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/index.js +9 -0
- package/lib/api/inputs/inputs.js +9 -0
- package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
- package/lib/api/inputs/point-inputs.js +521 -0
- package/lib/api/inputs/text-inputs.d.ts +83 -0
- package/lib/api/inputs/text-inputs.js +120 -0
- package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/{color.ts → color.js} +15 -34
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
- package/lib/api/services/{index.ts → index.d.ts} +1 -1
- package/lib/api/services/index.js +9 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/{lists.ts → lists.js} +59 -83
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/{logic.ts → logic.js} +24 -32
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/{math.ts → math.js} +71 -136
- package/lib/api/services/point.d.ts +222 -0
- package/lib/api/services/{point.ts → point.js} +32 -67
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/{text.ts → text.js} +7 -17
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/{transforms.ts → transforms.js} +37 -83
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/{vector.ts → vector.js} +42 -80
- package/lib/{index.ts → index.d.ts} +0 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/lib/api/inputs/base-inputs.ts +0 -18
- package/lib/api/inputs/text-inputs.ts +0 -108
- package/lib/api/services/color.test.ts +0 -86
- package/lib/api/services/lists.test.ts +0 -612
- package/lib/api/services/logic.test.ts +0 -187
- package/lib/api/services/math.test.ts +0 -622
- package/lib/api/services/text.test.ts +0 -55
- package/lib/api/services/vector.test.ts +0 -360
- package/tsconfig.bitbybit.json +0 -26
- package/tsconfig.json +0 -24
- /package/lib/api/{index.ts → index.d.ts} +0 -0
- /package/lib/api/inputs/{index.ts → index.d.ts} +0 -0
- /package/lib/api/inputs/{inputs.ts → inputs.d.ts} +0 -0
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Logic } from "./logic";
|
|
2
|
-
import * as Inputs from "../inputs";
|
|
3
|
-
|
|
4
|
-
describe("Logic unit tests", () => {
|
|
5
|
-
let logic: Logic;
|
|
6
|
-
beforeAll(() => {
|
|
7
|
-
logic = new Logic();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("should create boolean true", () => {
|
|
11
|
-
const res = logic.boolean({ boolean: true });
|
|
12
|
-
expect(res).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("should create boolean false", () => {
|
|
16
|
-
const res = logic.boolean({ boolean: false });
|
|
17
|
-
expect(res).toBe(false);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should create reandom list of boolean values", () => {
|
|
21
|
-
const res = logic.randomBooleans({ length: 10, trueThreshold: 0.5 });
|
|
22
|
-
expect(res.length).toBe(10);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("should create reandom list of boolean values with true threshold on 1", () => {
|
|
26
|
-
const res = logic.randomBooleans({ length: 10, trueThreshold: 1 });
|
|
27
|
-
expect(res).toEqual([true, true, true, true, true, true, true, true, true, true]);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should create reandom list of boolean values with true threshold on 0", () => {
|
|
31
|
-
const res = logic.randomBooleans({ length: 10, trueThreshold: 0 });
|
|
32
|
-
expect(res).toEqual([false, false, false, false, false, false, false, false, false, false]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("should create threshold boolean list", () => {
|
|
36
|
-
const res = logic.thresholdBooleanList({ numbers: [0.1, 0.2, 0.3], threshold: 0.2, inverse: false });
|
|
37
|
-
expect(res).toEqual([true, false, false]);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("should create inverted threshold boolean list", () => {
|
|
41
|
-
const res = logic.thresholdBooleanList({ numbers: [0.1, 0.2, 0.3], threshold: 0.2, inverse: true });
|
|
42
|
-
expect(res).toEqual([false, true, true]);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should create two threshold random gradient", () => {
|
|
46
|
-
const res = logic.twoThresholdRandomGradient({ numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], thresholdTotalTrue: 5, thresholdTotalFalse: 21, nrLevels: 10 });
|
|
47
|
-
expect(res.length).toEqual(23);
|
|
48
|
-
expect(res.filter(r => r === true).length).toBeGreaterThan(5);
|
|
49
|
-
expect(res.filter(r => r === false).length).toBeGreaterThan(3);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("should create boolean list based on gap thresholds", () => {
|
|
53
|
-
const res = logic.thresholdGapsBooleanList({ numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], gapThresholds: [[2, 4], [6, 8]], inverse: false });
|
|
54
|
-
expect(res).toEqual([
|
|
55
|
-
false, true, true,
|
|
56
|
-
true, false, true,
|
|
57
|
-
true, true, false,
|
|
58
|
-
false
|
|
59
|
-
]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("should create inverted boolean list based on gap thresholds", () => {
|
|
63
|
-
const res = logic.thresholdGapsBooleanList({ numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], gapThresholds: [[2, 4], [6, 8]], inverse: true });
|
|
64
|
-
expect(res).toEqual([
|
|
65
|
-
true, false, false,
|
|
66
|
-
false, true, false,
|
|
67
|
-
false, false, true,
|
|
68
|
-
true
|
|
69
|
-
]);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should invert true value with not", () => {
|
|
73
|
-
const res = logic.not({ boolean: true });
|
|
74
|
-
expect(res).toEqual(false);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it("should invert false value with not", () => {
|
|
78
|
-
const res = logic.not({ boolean: false });
|
|
79
|
-
expect(res).toEqual(true);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("should invert a boolean list", () => {
|
|
83
|
-
const res = logic.notList({ booleans: [false, false, true, false, true] });
|
|
84
|
-
expect(res).toEqual([true, true, false, true, false]);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("should compare two unequal values", () => {
|
|
88
|
-
const res = logic.compare({ first: false, second: true, operator: Inputs.Logic.BooleanOperatorsEnum.equal });
|
|
89
|
-
expect(res).toBe(false);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("should compare two unequal values as equal without strict mode", () => {
|
|
93
|
-
const res = logic.compare({ first: "1", second: 1 as any, operator: Inputs.Logic.BooleanOperatorsEnum.equal });
|
|
94
|
-
expect(res).toBe(true);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should compare two unequal values as not equal without strict mode", () => {
|
|
98
|
-
const res = logic.compare({ first: "1", second: 1 as any, operator: Inputs.Logic.BooleanOperatorsEnum.notEqual });
|
|
99
|
-
expect(res).toBe(false);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("should compare two unequal values as equal with strict mode", () => {
|
|
103
|
-
const res = logic.compare({ first: "1", second: 1 as any, operator: Inputs.Logic.BooleanOperatorsEnum.tripleEqual });
|
|
104
|
-
expect(res).toBe(false);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should compare two unequal values as not equal with strict mode", () => {
|
|
108
|
-
const res = logic.compare({ first: "1", second: 1 as any, operator: Inputs.Logic.BooleanOperatorsEnum.tripleNotEqual });
|
|
109
|
-
expect(res).toBe(true);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should compare two unequal values", () => {
|
|
113
|
-
const res = logic.compare({ first: false, second: true, operator: Inputs.Logic.BooleanOperatorsEnum.notEqual });
|
|
114
|
-
expect(res).toBe(true);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("should compare two equal values", () => {
|
|
118
|
-
const res = logic.compare({ first: false, second: false, operator: Inputs.Logic.BooleanOperatorsEnum.equal });
|
|
119
|
-
expect(res).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("should compare two equal values", () => {
|
|
123
|
-
const res = logic.compare({ first: false, second: false, operator: Inputs.Logic.BooleanOperatorsEnum.notEqual });
|
|
124
|
-
expect(res).toBe(false);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("should check if 4 is less than 5", () => {
|
|
128
|
-
const res = logic.compare({ first: 4, second: 5, operator: Inputs.Logic.BooleanOperatorsEnum.less });
|
|
129
|
-
expect(res).toBe(true);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("should check if 4 is greater than 5", () => {
|
|
133
|
-
const res = logic.compare({ first: 4, second: 5, operator: Inputs.Logic.BooleanOperatorsEnum.greater });
|
|
134
|
-
expect(res).toBe(false);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("should check if 4 is less or equal to 5", () => {
|
|
138
|
-
const res = logic.compare({ first: 5, second: 5, operator: Inputs.Logic.BooleanOperatorsEnum.lessOrEqual });
|
|
139
|
-
expect(res).toBe(true);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("should check if 5 is less or equal to 5", () => {
|
|
143
|
-
const res = logic.compare({ first: 5, second: 5, operator: Inputs.Logic.BooleanOperatorsEnum.lessOrEqual });
|
|
144
|
-
expect(res).toBe(true);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("should check if 5 is greater or equal to 5", () => {
|
|
148
|
-
const res = logic.compare({ first: 5, second: 5, operator: Inputs.Logic.BooleanOperatorsEnum.greaterOrEqual });
|
|
149
|
-
expect(res).toBe(true);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it("should check if 6 is greater or equal to 5", () => {
|
|
153
|
-
const res = logic.compare({ first: 5, second: 5, operator: Inputs.Logic.BooleanOperatorsEnum.greaterOrEqual });
|
|
154
|
-
expect(res).toBe(true);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("should return false if unknown operator is provided", () => {
|
|
158
|
-
const res = logic.compare({ first: 5, second: 5, operator: "whatever" as any });
|
|
159
|
-
expect(res).toBe(false);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("should return value through the gate if boolean is true", () => {
|
|
163
|
-
const res = logic.valueGate({ value: { d: "a" }, boolean: true });
|
|
164
|
-
expect(res).toEqual({ d: "a" });
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("should not return value through the gate if boolean is false", () => {
|
|
168
|
-
const res = logic.valueGate({ value: { d: "a" }, boolean: false });
|
|
169
|
-
expect(res).toEqual(undefined);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it("should return first defined value", () => {
|
|
173
|
-
const res = logic.firstDefinedValueGate({ value1: { d: "a" }, value2: { c: "x" } });
|
|
174
|
-
expect(res).toEqual({ d: "a" });
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("should return first defined value", () => {
|
|
178
|
-
const res = logic.firstDefinedValueGate({ value1: undefined, value2: { c: "x" } });
|
|
179
|
-
expect(res).toEqual({ c: "x" });
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("should not return defined value if no values are defined", () => {
|
|
183
|
-
const res = logic.firstDefinedValueGate({ value1: undefined, value2: undefined });
|
|
184
|
-
expect(res).toEqual(undefined);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|